WorkspaceDialog.qml 20 KB

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