WorkspaceDialog.qml 15 KB

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