WorkspaceDialog.qml 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. // Copyright (c) 2022 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.6 as UM
  8. import Cura 1.1 as Cura
  9. UM.Dialog
  10. {
  11. id: workspaceDialog
  12. title: manager.isUcp? catalog.i18nc("@title:window", "Open Universal Cura Project (UCP)"): catalog.i18nc("@title:window", "Open Project")
  13. margin: UM.Theme.getSize("default_margin").width
  14. minimumWidth: UM.Theme.getSize("modal_window_minimum").width
  15. minimumHeight: UM.Theme.getSize("modal_window_minimum").height
  16. backgroundColor: UM.Theme.getColor("detail_background")
  17. headerComponent: Rectangle
  18. {
  19. height: childrenRect.height + 2 * UM.Theme.getSize("default_margin").height
  20. color: UM.Theme.getColor("main_background")
  21. UM.Label
  22. {
  23. id: titleLabel
  24. text: manager.isUcp? catalog.i18nc("@action:title", "Summary - Open Universal Cura Project (UCP)"): catalog.i18nc("@action:title", "Summary - Cura Project")
  25. font: UM.Theme.getFont("large")
  26. anchors.top: parent.top
  27. anchors.left: parent.left
  28. anchors.topMargin: UM.Theme.getSize("default_margin").height
  29. anchors.leftMargin: UM.Theme.getSize("default_margin").height
  30. }
  31. }
  32. Rectangle
  33. {
  34. anchors.fill: parent
  35. UM.I18nCatalog { id: catalog; name: "cura" }
  36. color: UM.Theme.getColor("main_background")
  37. Flickable
  38. {
  39. id: dialogSummaryItem
  40. width: parent.width
  41. height: parent.height
  42. clip: true
  43. contentHeight: contentColumn.height
  44. ScrollBar.vertical: UM.ScrollBar { id: scrollbar }
  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. id: contentColumn
  60. width: parent.width - scrollbar.width - UM.Theme.getSize("default_margin").width
  61. height: childrenRect.height
  62. spacing: UM.Theme.getSize("default_margin").height
  63. leftPadding: UM.Theme.getSize("default_margin").width
  64. rightPadding: UM.Theme.getSize("default_margin").width
  65. WorkspaceSection
  66. {
  67. id: printerSection
  68. title: catalog.i18nc("@action:label", "Printer settings")
  69. iconSource: UM.Theme.getIcon("Printer")
  70. content: Column
  71. {
  72. spacing: UM.Theme.getSize("default_margin").height
  73. leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width
  74. WorkspaceRow
  75. {
  76. leftLabelText: catalog.i18nc("@action:label", "Type")
  77. rightLabelText: manager.machineType
  78. }
  79. WorkspaceRow
  80. {
  81. leftLabelText: catalog.i18nc("@action:label", manager.isPrinterGroup ? "Printer Group" : "Printer Name")
  82. rightLabelText: manager.isUcp? manager.machineType: manager.machineName == catalog.i18nc("@button", "Create new") ? "" : manager.machineName
  83. }
  84. }
  85. comboboxTitle: catalog.i18nc("@action:label", "Open With")
  86. comboboxTooltipText: catalog.i18nc("@info:tooltip", "Printer settings will be updated to match the settings saved with the project.")
  87. comboboxVisible: workspaceDialog.visible && manager.updatableMachinesModel.count > 1
  88. combobox: Cura.MachineSelector
  89. {
  90. id: machineSelector
  91. headerCornerSide: Cura.RoundedRectangle.Direction.All
  92. width: parent.width
  93. height: parent.height
  94. machineListModel: manager.updatableMachinesModel
  95. machineName: manager.machineName
  96. isConnectedCloudPrinter: false
  97. isCloudRegistered: false
  98. isNetworkPrinter: manager.isNetworked
  99. isGroup: manager.isAbstractMachine
  100. connectionStatus: ""
  101. minDropDownWidth: machineSelector.width
  102. Component
  103. {
  104. id: componentNewPrinter
  105. Cura.SecondaryButton
  106. {
  107. id: createNewPrinter
  108. text: catalog.i18nc("@button", "Create new")
  109. fixedWidthMode: true
  110. width: parent.width - leftPadding * 1.5
  111. visible: manager.allowCreateMachine
  112. onClicked:
  113. {
  114. toggleContent()
  115. manager.setResolveStrategy("machine", "new")
  116. machineSelector.machineName = catalog.i18nc("@button", "Create new")
  117. manager.setIsAbstractMachine(false)
  118. manager.setIsNetworkedMachine(false)
  119. }
  120. }
  121. }
  122. buttons: manager.allowCreateMachine ? [componentNewPrinter.createObject()] : []
  123. onSelectPrinter: function(machine)
  124. {
  125. toggleContent();
  126. machineSelector.machineName = machine.name
  127. manager.setResolveStrategy("machine", "override")
  128. manager.setMachineToOverride(machine.id)
  129. manager.setIsAbstractMachine(machine.isAbstractMachine)
  130. manager.setIsNetworkedMachine(machine.isNetworked)
  131. }
  132. }
  133. }
  134. WorkspaceSection
  135. {
  136. id: profileSection
  137. title: manager.isUcp? catalog.i18nc("@action:label", "Suggested Profile settings"):catalog.i18nc("@action:label", "Profile settings")
  138. iconSource: UM.Theme.getIcon("Sliders")
  139. content: Column
  140. {
  141. id: profileSettingsValuesTable
  142. spacing: UM.Theme.getSize("default_margin").height
  143. leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width
  144. WorkspaceRow
  145. {
  146. leftLabelText: catalog.i18nc("@action:label", "Name")
  147. rightLabelText: manager.qualityName
  148. visible: manager.isCompatibleMachine
  149. }
  150. WorkspaceRow
  151. {
  152. leftLabelText: catalog.i18nc("@action:label", "Intent")
  153. rightLabelText: manager.intentName
  154. visible: manager.isCompatibleMachine
  155. }
  156. WorkspaceRow
  157. {
  158. leftLabelText: catalog.i18nc("@action:label", "Not in profile")
  159. rightLabelText: catalog.i18ncp("@action:label", "%1 override", "%1 overrides", manager.numUserSettings).arg(manager.numUserSettings)
  160. visible: manager.numUserSettings != 0 && manager.isCompatibleMachine
  161. }
  162. WorkspaceRow
  163. {
  164. leftLabelText: catalog.i18nc("@action:label", "Derivative from")
  165. rightLabelText: catalog.i18ncp("@action:label", "%1, %2 override", "%1, %2 overrides", manager.numSettingsOverridenByQualityChanges).arg(manager.qualityType).arg(manager.numSettingsOverridenByQualityChanges)
  166. visible: manager.numSettingsOverridenByQualityChanges != 0 && manager.isCompatibleMachine
  167. }
  168. }
  169. }
  170. WorkspaceSection
  171. {
  172. id: ucpProfileSection
  173. visible: manager.isUcp
  174. title: catalog.i18nc("@action:label", "Settings Loaded from UCP file")
  175. iconSource: UM.Theme.getIcon("Settings")
  176. content: Column
  177. {
  178. id: ucpProfileSettingsValuesTable
  179. spacing: UM.Theme.getSize("default_margin").height
  180. leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width
  181. WorkspaceRow
  182. {
  183. leftLabelText: catalog.i18nc("@action:label", "Settings Loaded from UCP file")
  184. rightLabelText: catalog.i18ncp("@action:label", "%1 override", "%1 overrides", manager.exportedSettingModel.rowCount()).arg(manager.exportedSettingModel.rowCount())
  185. buttonText: tableViewSpecificSettings.shouldBeVisible ? catalog.i18nc("@action:button", "Hide settings") : catalog.i18nc("@action:button", "Show settings")
  186. onButtonClicked: tableViewSpecificSettings.shouldBeVisible = !tableViewSpecificSettings.shouldBeVisible
  187. }
  188. Cura.TableView
  189. {
  190. id: tableViewSpecificSettings
  191. width: parent.width - parent.leftPadding - UM.Theme.getSize("default_margin").width
  192. height: UM.Theme.getSize("card").height
  193. visible: shouldBeVisible && manager.isUcp
  194. property bool shouldBeVisible: true
  195. columnHeaders:
  196. [
  197. catalog.i18nc("@title:column", "Applies on"),
  198. catalog.i18nc("@title:column", "Setting"),
  199. catalog.i18nc("@title:column", "Value")
  200. ]
  201. model: UM.TableModel
  202. {
  203. id: tableModel
  204. headers: ["category", "label", "value"]
  205. rows: manager.exportedSettingModel.items
  206. }
  207. }
  208. property var modelRows: manager.exportedSettingModel.items
  209. onModelRowsChanged:
  210. {
  211. tableModel.clear()
  212. tableModel.rows = modelRows
  213. }
  214. }
  215. comboboxVisible: manager.qualityChangesConflict
  216. combobox: Cura.ComboBox
  217. {
  218. id: qualityChangesResolveComboBox
  219. model: resolveStrategiesModel
  220. textRole: "label"
  221. visible: manager.qualityChangesConflict && !manager.isUcp
  222. contentLeftPadding: UM.Theme.getSize("default_margin").width + UM.Theme.getSize("narrow_margin").width
  223. textFont: UM.Theme.getFont("medium")
  224. background: Cura.RoundedRectangle
  225. {
  226. border.width: UM.Theme.getSize("default_lining").width
  227. border.color: UM.Theme.getColor("lining")
  228. color: qualityChangesResolveComboBox.hovered ? UM.Theme.getColor("expandable_hover") : UM.Theme.getColor("action_button")
  229. cornerSide: Cura.RoundedRectangle.Direction.All
  230. radius: UM.Theme.getSize("default_radius").width
  231. }
  232. // This is a hack. This will trigger onCurrentIndexChanged and set the index when this component in loaded
  233. currentIndex:
  234. {
  235. currentIndex = 0
  236. }
  237. onCurrentIndexChanged:
  238. {
  239. manager.setResolveStrategy("quality_changes", resolveStrategiesModel.get(currentIndex).key)
  240. }
  241. }
  242. }
  243. WorkspaceSection
  244. {
  245. id: materialSection
  246. title: manager.isUcp? catalog.i18nc("@action:label", "Suggested Material settings"): catalog.i18nc("@action:label", "Material settings")
  247. iconSource: UM.Theme.getIcon("Spool")
  248. content: Column
  249. {
  250. spacing: UM.Theme.getSize("default_margin").height
  251. leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width
  252. Repeater
  253. {
  254. model: manager.materialLabels
  255. delegate: WorkspaceRow
  256. {
  257. leftLabelText: catalog.i18nc("@action:label", "Name")
  258. rightLabelText: modelData
  259. }
  260. }
  261. }
  262. comboboxVisible: manager.materialConflict
  263. combobox: Cura.ComboBox
  264. {
  265. id: materialResolveComboBox
  266. model: resolveStrategiesModel
  267. textRole: "label"
  268. visible: manager.materialConflict && !manager.isUcp
  269. contentLeftPadding: UM.Theme.getSize("default_margin").width + UM.Theme.getSize("narrow_margin").width
  270. textFont: UM.Theme.getFont("medium")
  271. background: Cura.RoundedRectangle
  272. {
  273. border.width: UM.Theme.getSize("default_lining").width
  274. border.color: UM.Theme.getColor("lining")
  275. color: materialResolveComboBox.hovered ? UM.Theme.getColor("expandable_hover") : UM.Theme.getColor("action_button")
  276. cornerSide: Cura.RoundedRectangle.Direction.All
  277. radius: UM.Theme.getSize("default_radius").width
  278. }
  279. // This is a hack. This will trigger onCurrentIndexChanged and set the index when this component in loaded
  280. currentIndex:
  281. {
  282. currentIndex = 0
  283. }
  284. onCurrentIndexChanged:
  285. {
  286. manager.setResolveStrategy("material", resolveStrategiesModel.get(currentIndex).key)
  287. }
  288. }
  289. }
  290. WorkspaceSection
  291. {
  292. id: visibilitySection
  293. title: catalog.i18nc("@action:label", "Setting visibility")
  294. iconSource: UM.Theme.getIcon("Eye")
  295. visible : !manager.isUcp
  296. content: Column
  297. {
  298. spacing: UM.Theme.getSize("default_margin").height
  299. leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width
  300. bottomPadding: UM.Theme.getSize("narrow_margin").height
  301. WorkspaceRow
  302. {
  303. leftLabelText: catalog.i18nc("@action:label", "Mode")
  304. rightLabelText: manager.activeMode
  305. }
  306. WorkspaceRow
  307. {
  308. leftLabelText: catalog.i18nc("@action:label", "%1 out of %2" ).arg(manager.numVisibleSettings).arg(manager.totalNumberOfSettings)
  309. rightLabelText: manager.activeMode
  310. visible: manager.hasVisibleSettingsField
  311. }
  312. }
  313. }
  314. Row
  315. {
  316. id: clearBuildPlateWarning
  317. width: parent.width
  318. height: childrenRect.height
  319. spacing: UM.Theme.getSize("default_margin").width
  320. visible: manager.hasObjectsOnPlate
  321. UM.ColorImage
  322. {
  323. width: warningLabel.height
  324. height: width
  325. source: UM.Theme.getIcon("Information")
  326. color: UM.Theme.getColor("text")
  327. }
  328. UM.Label
  329. {
  330. id: warningLabel
  331. text: catalog.i18nc("@action:warning", "Loading a project will clear all models on the build plate.")
  332. }
  333. }
  334. }
  335. }
  336. }
  337. property bool warning: manager.missingPackages.length > 0
  338. footerComponent: Rectangle
  339. {
  340. color: warning ? UM.Theme.getColor("warning") : "transparent"
  341. anchors.bottom: parent.bottom
  342. width: parent.width
  343. height: childrenRect.height + (warning ? 2 * workspaceDialog.margin : workspaceDialog.margin)
  344. Column
  345. {
  346. height: childrenRect.height
  347. spacing: workspaceDialog.margin
  348. anchors.leftMargin: workspaceDialog.margin
  349. anchors.rightMargin: workspaceDialog.margin
  350. anchors.bottomMargin: workspaceDialog.margin
  351. anchors.topMargin: warning ? workspaceDialog.margin : 0
  352. anchors.left: parent.left
  353. anchors.right: parent.right
  354. anchors.top: parent.top
  355. RowLayout
  356. {
  357. id: warningRow
  358. height: childrenRect.height
  359. visible: warning
  360. spacing: workspaceDialog.margin
  361. UM.ColorImage
  362. {
  363. width: UM.Theme.getSize("extruder_icon").width
  364. height: UM.Theme.getSize("extruder_icon").height
  365. source: UM.Theme.getIcon("Warning")
  366. }
  367. UM.Label
  368. {
  369. id: warningText
  370. text: catalog.i18nc("@label", "This project contains materials or plugins that are currently not installed in Cura.<br/>Install the missing packages and reopen the project.")
  371. }
  372. }
  373. Loader
  374. {
  375. width: parent.width
  376. height: childrenRect.height
  377. sourceComponent: buttonRow
  378. }
  379. }
  380. }
  381. buttonSpacing: UM.Theme.getSize("wide_margin").width
  382. rightButtons: [
  383. Cura.TertiaryButton
  384. {
  385. visible: !warning
  386. text: catalog.i18nc("@action:button", "Cancel")
  387. onClicked: reject()
  388. },
  389. Cura.PrimaryButton
  390. {
  391. visible: !warning
  392. text: catalog.i18nc("@action:button", "Open")
  393. onClicked: accept()
  394. },
  395. Cura.TertiaryButton
  396. {
  397. visible: warning
  398. text: catalog.i18nc("@action:button", "Open project anyway")
  399. onClicked: {
  400. manager.showMissingMaterialsWarning();
  401. accept();
  402. }
  403. },
  404. Cura.PrimaryButton
  405. {
  406. visible: warning
  407. text: catalog.i18nc("@action:button", "Install missing packages")
  408. onClicked: manager.installMissingPackages()
  409. }
  410. ]
  411. onClosing: manager.notifyClosed()
  412. onRejected: manager.onCancelButtonClicked()
  413. onAccepted: manager.onOkButtonClicked()
  414. onVisibleChanged:
  415. {
  416. if (visible)
  417. {
  418. // Force reload the comboboxes
  419. // Since this dialog is only created once the first time you open it, these comboxes need to be reloaded
  420. // each time it is shown after the first time so that the indexes will update correctly.
  421. materialSection.reloadValues()
  422. profileSection.reloadValues()
  423. printerSection.reloadValues()
  424. ucpProfileSection.reloadValues()
  425. }
  426. }
  427. }