WorkspaceDialog.qml 16 KB

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