WorkspaceDialog.qml 16 KB

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