WorkspaceDialog.qml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. // Copyright (c) 2020 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.10
  4. import QtQuick.Controls 2.3
  5. import QtQuick.Layouts 1.3
  6. import QtQuick.Window 2.2
  7. import UM 1.5 as UM
  8. import Cura 1.1 as Cura
  9. UM.Dialog
  10. {
  11. id: base
  12. title: catalog.i18nc("@title:window", "Open Project")
  13. minimumWidth: UM.Theme.getSize("popup_dialog").width
  14. minimumHeight: UM.Theme.getSize("popup_dialog").height
  15. width: minimumWidth
  16. backgroundColor: UM.Theme.getColor("main_background")
  17. margin: UM.Theme.getSize("default_margin").width
  18. property int comboboxHeight: UM.Theme.getSize("default_margin").height
  19. onClosing: manager.notifyClosed()
  20. onVisibleChanged:
  21. {
  22. if (visible)
  23. {
  24. machineResolveComboBox.currentIndex = 0
  25. qualityChangesResolveComboBox.currentIndex = 0
  26. materialResolveComboBox.currentIndex = 0
  27. }
  28. }
  29. Flickable
  30. {
  31. clip: true
  32. width: parent.width
  33. height: parent.height
  34. contentHeight: dialogSummaryItem.height
  35. ScrollBar.vertical: UM.ScrollBar { id: verticalScrollBar }
  36. Item
  37. {
  38. id: dialogSummaryItem
  39. width: verticalScrollBar.visible ? parent.width - verticalScrollBar.width - UM.Theme.getSize("default_margin").width : parent.width
  40. height: childrenRect.height
  41. anchors.margins: 10 * screenScaleFactor
  42. UM.I18nCatalog
  43. {
  44. id: catalog
  45. name: "cura"
  46. }
  47. ListModel
  48. {
  49. id: resolveStrategiesModel
  50. // Instead of directly adding the list elements, we add them afterwards.
  51. // This is because it's impossible to use setting function results to be bound to listElement properties directly.
  52. // See http://stackoverflow.com/questions/7659442/listelement-fields-as-properties
  53. Component.onCompleted:
  54. {
  55. append({"key": "override", "label": catalog.i18nc("@action:ComboBox Update/override existing profile", "Update existing")});
  56. append({"key": "new", "label": catalog.i18nc("@action:ComboBox Save settings in a new profile", "Create new")});
  57. }
  58. }
  59. Column
  60. {
  61. width: parent.width
  62. height: childrenRect.height
  63. spacing: UM.Theme.getSize("default_margin").height
  64. Column
  65. {
  66. width: parent.width
  67. height: childrenRect.height
  68. UM.Label
  69. {
  70. id: titleLabel
  71. text: catalog.i18nc("@action:title", "Summary - Cura Project")
  72. font: UM.Theme.getFont("large")
  73. }
  74. Rectangle
  75. {
  76. id: separator
  77. color: UM.Theme.getColor("text")
  78. width: parent.width
  79. height: UM.Theme.getSize("default_lining").height
  80. }
  81. }
  82. Item
  83. {
  84. width: parent.width
  85. height: childrenRect.height
  86. UM.TooltipArea
  87. {
  88. id: machineResolveStrategyTooltip
  89. anchors.top: parent.top
  90. anchors.right: parent.right
  91. width: (parent.width / 3) | 0
  92. height: visible ? comboboxHeight : 0
  93. visible: base.visible && machineResolveComboBox.model.count > 1
  94. text: catalog.i18nc("@info:tooltip", "How should the conflict in the machine be resolved?")
  95. Cura.ComboBox
  96. {
  97. id: machineResolveComboBox
  98. model: manager.updatableMachinesModel
  99. visible: machineResolveStrategyTooltip.visible
  100. textRole: "displayName"
  101. width: parent.width
  102. height: UM.Theme.getSize("button").height
  103. onCurrentIndexChanged:
  104. {
  105. if (model.getItem(currentIndex).id == "new"
  106. && model.getItem(currentIndex).type == "default_option")
  107. {
  108. manager.setResolveStrategy("machine", "new")
  109. }
  110. else
  111. {
  112. manager.setResolveStrategy("machine", "override")
  113. manager.setMachineToOverride(model.getItem(currentIndex).id)
  114. }
  115. }
  116. onVisibleChanged:
  117. {
  118. if (!visible) {return}
  119. currentIndex = 0
  120. // If the project printer exists in Cura, set it as the default dropdown menu option.
  121. // No need to check object 0, which is the "Create new" option
  122. for (var i = 1; i < model.count; i++)
  123. {
  124. if (model.getItem(i).name == manager.machineName)
  125. {
  126. currentIndex = i
  127. break
  128. }
  129. }
  130. // The project printer does not exist in Cura. If there is at least one printer of the same
  131. // type, select the first one, else set the index to "Create new"
  132. if (currentIndex == 0 && model.count > 1)
  133. {
  134. currentIndex = 1
  135. }
  136. }
  137. }
  138. }
  139. Column
  140. {
  141. width: parent.width
  142. height: childrenRect.height
  143. UM.Label
  144. {
  145. id: printer_settings_label
  146. text: catalog.i18nc("@action:label", "Printer settings")
  147. font: UM.Theme.getFont("default_bold")
  148. }
  149. Row
  150. {
  151. width: parent.width
  152. height: childrenRect.height
  153. UM.Label
  154. {
  155. text: catalog.i18nc("@action:label", "Type")
  156. width: (parent.width / 3) | 0
  157. }
  158. UM.Label
  159. {
  160. text: manager.machineType
  161. width: (parent.width / 3) | 0
  162. }
  163. }
  164. Row
  165. {
  166. width: parent.width
  167. height: childrenRect.height
  168. UM.Label
  169. {
  170. text: catalog.i18nc("@action:label", manager.isPrinterGroup ? "Printer Group" : "Printer Name")
  171. width: (parent.width / 3) | 0
  172. }
  173. UM.Label
  174. {
  175. text: manager.machineName
  176. width: (parent.width / 3) | 0
  177. wrapMode: Text.WordWrap
  178. }
  179. }
  180. }
  181. }
  182. Item
  183. {
  184. width: parent.width
  185. height: childrenRect.height
  186. UM.TooltipArea
  187. {
  188. anchors.right: parent.right
  189. anchors.top: parent.top
  190. width: (parent.width / 3) | 0
  191. height: visible ? comboboxHeight : 0
  192. visible: manager.qualityChangesConflict
  193. text: catalog.i18nc("@info:tooltip", "How should the conflict in the profile be resolved?")
  194. Cura.ComboBox
  195. {
  196. model: resolveStrategiesModel
  197. textRole: "label"
  198. id: qualityChangesResolveComboBox
  199. width: parent.width
  200. height: UM.Theme.getSize("button").height
  201. onActivated:
  202. {
  203. manager.setResolveStrategy("quality_changes", resolveStrategiesModel.get(index).key)
  204. }
  205. }
  206. }
  207. Column
  208. {
  209. width: parent.width
  210. height: childrenRect.height
  211. UM.Label
  212. {
  213. text: catalog.i18nc("@action:label", "Profile settings")
  214. font: UM.Theme.getFont("default_bold")
  215. }
  216. Row
  217. {
  218. width: parent.width
  219. height: childrenRect.height
  220. UM.Label
  221. {
  222. text: catalog.i18nc("@action:label", "Name")
  223. width: (parent.width / 3) | 0
  224. }
  225. UM.Label
  226. {
  227. text: manager.qualityName
  228. width: (parent.width / 3) | 0
  229. wrapMode: Text.WordWrap
  230. }
  231. }
  232. Row
  233. {
  234. width: parent.width
  235. height: childrenRect.height
  236. UM.Label
  237. {
  238. text: catalog.i18nc("@action:label", "Intent")
  239. width: (parent.width / 3) | 0
  240. }
  241. UM.Label
  242. {
  243. text: manager.intentName
  244. width: (parent.width / 3) | 0
  245. wrapMode: Text.WordWrap
  246. }
  247. }
  248. Row
  249. {
  250. width: parent.width
  251. height: childrenRect.height
  252. UM.Label
  253. {
  254. text: catalog.i18nc("@action:label", "Not in profile")
  255. visible: manager.numUserSettings != 0
  256. width: (parent.width / 3) | 0
  257. }
  258. UM.Label
  259. {
  260. text: catalog.i18ncp("@action:label", "%1 override", "%1 overrides", manager.numUserSettings).arg(manager.numUserSettings)
  261. visible: manager.numUserSettings != 0
  262. width: (parent.width / 3) | 0
  263. }
  264. }
  265. Row
  266. {
  267. width: parent.width
  268. height: childrenRect.height
  269. UM.Label
  270. {
  271. text: catalog.i18nc("@action:label", "Derivative from")
  272. visible: manager.numSettingsOverridenByQualityChanges != 0
  273. width: (parent.width / 3) | 0
  274. }
  275. UM.Label
  276. {
  277. text: catalog.i18ncp("@action:label", "%1, %2 override", "%1, %2 overrides", manager.numSettingsOverridenByQualityChanges).arg(manager.qualityType).arg(manager.numSettingsOverridenByQualityChanges)
  278. width: (parent.width / 3) | 0
  279. visible: manager.numSettingsOverridenByQualityChanges != 0
  280. wrapMode: Text.WordWrap
  281. }
  282. }
  283. }
  284. }
  285. Item
  286. {
  287. width: parent.width
  288. height: childrenRect.height
  289. UM.TooltipArea
  290. {
  291. id: materialResolveTooltip
  292. anchors.right: parent.right
  293. anchors.top: parent.top
  294. width: (parent.width / 3) | 0
  295. height: visible ? comboboxHeight : 0
  296. visible: manager.materialConflict
  297. text: catalog.i18nc("@info:tooltip", "How should the conflict in the material be resolved?")
  298. Cura.ComboBox
  299. {
  300. model: resolveStrategiesModel
  301. textRole: "label"
  302. id: materialResolveComboBox
  303. width: parent.width
  304. height: UM.Theme.getSize("button").height
  305. onActivated:
  306. {
  307. manager.setResolveStrategy("material", resolveStrategiesModel.get(index).key)
  308. }
  309. }
  310. }
  311. Column
  312. {
  313. width: parent.width
  314. height: childrenRect.height
  315. Row
  316. {
  317. height: childrenRect.height
  318. width: parent.width
  319. spacing: UM.Theme.getSize("narrow_margin").width
  320. UM.Label
  321. {
  322. text: catalog.i18nc("@action:label", "Material settings")
  323. font: UM.Theme.getFont("default_bold")
  324. width: (parent.width / 3) | 0
  325. }
  326. }
  327. Repeater
  328. {
  329. model: manager.materialLabels
  330. delegate: Row
  331. {
  332. width: parent.width
  333. height: childrenRect.height
  334. UM.Label
  335. {
  336. text: catalog.i18nc("@action:label", "Name")
  337. width: (parent.width / 3) | 0
  338. }
  339. UM.Label
  340. {
  341. text: modelData
  342. width: (parent.width / 3) | 0
  343. wrapMode: Text.WordWrap
  344. }
  345. }
  346. }
  347. }
  348. }
  349. Column
  350. {
  351. width: parent.width
  352. height: childrenRect.height
  353. UM.Label
  354. {
  355. text: catalog.i18nc("@action:label", "Setting visibility")
  356. font: UM.Theme.getFont("default_bold")
  357. }
  358. Row
  359. {
  360. width: parent.width
  361. height: childrenRect.height
  362. UM.Label
  363. {
  364. text: catalog.i18nc("@action:label", "Mode")
  365. width: (parent.width / 3) | 0
  366. }
  367. UM.Label
  368. {
  369. text: manager.activeMode
  370. width: (parent.width / 3) | 0
  371. }
  372. }
  373. Row
  374. {
  375. width: parent.width
  376. height: childrenRect.height
  377. visible: manager.hasVisibleSettingsField
  378. UM.Label
  379. {
  380. text: catalog.i18nc("@action:label", "Visible settings:")
  381. width: (parent.width / 3) | 0
  382. }
  383. UM.Label
  384. {
  385. text: catalog.i18nc("@action:label", "%1 out of %2" ).arg(manager.numVisibleSettings).arg(manager.totalNumberOfSettings)
  386. width: (parent.width / 3) | 0
  387. }
  388. }
  389. }
  390. Row
  391. {
  392. width: parent.width
  393. height: childrenRect.height
  394. visible: manager.hasObjectsOnPlate
  395. UM.ColorImage
  396. {
  397. width: warningLabel.height
  398. height: width
  399. source: UM.Theme.getIcon("Information")
  400. color: UM.Theme.getColor("text")
  401. }
  402. UM.Label
  403. {
  404. id: warningLabel
  405. text: catalog.i18nc("@action:warning", "Loading a project will clear all models on the build plate.")
  406. }
  407. }
  408. }
  409. }
  410. }
  411. property bool warning: manager.missingPackages.length > 0
  412. footerComponent: Rectangle
  413. {
  414. color: warning ? UM.Theme.getColor("warning") : "transparent"
  415. anchors.bottom: parent.bottom
  416. width: parent.width
  417. height: childrenRect.height + 2 * base.margin
  418. Column
  419. {
  420. height: childrenRect.height
  421. spacing: base.margin
  422. anchors.margins: base.margin
  423. anchors.left: parent.left
  424. anchors.right: parent.right
  425. anchors.top: parent.top
  426. RowLayout
  427. {
  428. id: warningRow
  429. height: childrenRect.height
  430. visible: warning
  431. spacing: base.margin
  432. UM.ColorImage
  433. {
  434. width: UM.Theme.getSize("extruder_icon").width
  435. height: UM.Theme.getSize("extruder_icon").height
  436. source: UM.Theme.getIcon("Warning")
  437. }
  438. UM.Label
  439. {
  440. id: warningText
  441. text: "The material used in this project is currently not installed in Cura.<br/>Install the material profile and reopen the project."
  442. }
  443. }
  444. Loader
  445. {
  446. width: parent.width
  447. height: childrenRect.height
  448. sourceComponent: buttonRow
  449. }
  450. }
  451. }
  452. buttonSpacing: UM.Theme.getSize("default_margin").width
  453. rightButtons: [
  454. Cura.TertiaryButton
  455. {
  456. visible: !warning
  457. text: catalog.i18nc("@action:button", "Cancel")
  458. onClicked: reject()
  459. },
  460. Cura.PrimaryButton
  461. {
  462. visible: !warning
  463. text: catalog.i18nc("@action:button", "Open")
  464. onClicked: accept()
  465. },
  466. Cura.TertiaryButton
  467. {
  468. visible: warning
  469. text: catalog.i18nc("@action:button", "Open project anyway")
  470. onClicked: {
  471. manager.showMissingMaterialsWarning();
  472. accept();
  473. }
  474. },
  475. Cura.PrimaryButton
  476. {
  477. visible: warning
  478. text: catalog.i18nc("@action:button", "Install missing material")
  479. onClicked: manager.installMissingPackages()
  480. }
  481. ]
  482. onRejected: manager.onCancelButtonClicked()
  483. onAccepted: manager.onOkButtonClicked()
  484. }