WorkspaceDialog.qml 20 KB

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