WorkspaceDialog.qml 17 KB

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