WorkspaceDialog.qml 17 KB

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