WorkspaceDialog.qml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  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.5 as UM
  8. import Cura 1.1 as Cura
  9. UM.Dialog
  10. {
  11. id: workspaceDialog
  12. title: 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: 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.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. buttons: [
  103. Cura.SecondaryButton
  104. {
  105. id: createNewPrinter
  106. text: catalog.i18nc("@button", "Create new")
  107. fixedWidthMode: true
  108. width: parent.width - leftPadding * 1.5
  109. onClicked:
  110. {
  111. toggleContent()
  112. manager.setResolveStrategy("machine", "new")
  113. machineSelector.machineName = catalog.i18nc("@button", "Create new")
  114. manager.setIsAbstractMachine(false)
  115. manager.setIsNetworkedMachine(false)
  116. }
  117. }
  118. ]
  119. onSelectPrinter: function(machine)
  120. {
  121. toggleContent();
  122. machineSelector.machineName = machine.name
  123. manager.setResolveStrategy("machine", "override")
  124. manager.setMachineToOverride(machine.id)
  125. manager.setIsAbstractMachine(machine.isAbstractMachine)
  126. manager.setIsNetworkedMachine(machine.isNetworked)
  127. }
  128. }
  129. }
  130. WorkspaceSection
  131. {
  132. id: profileSection
  133. title: catalog.i18nc("@action:label", "Profile settings")
  134. iconSource: UM.Theme.getIcon("Sliders")
  135. content: Column
  136. {
  137. id: profileSettingsValuesTable
  138. spacing: UM.Theme.getSize("default_margin").height
  139. leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width
  140. WorkspaceRow
  141. {
  142. leftLabelText: catalog.i18nc("@action:label", "Name")
  143. rightLabelText: manager.qualityName
  144. }
  145. WorkspaceRow
  146. {
  147. leftLabelText: catalog.i18nc("@action:label", "Intent")
  148. rightLabelText: manager.intentName
  149. }
  150. WorkspaceRow
  151. {
  152. leftLabelText: catalog.i18nc("@action:label", "Not in profile")
  153. rightLabelText: catalog.i18ncp("@action:label", "%1 override", "%1 overrides", manager.numUserSettings).arg(manager.numUserSettings)
  154. visible: manager.numUserSettings != 0
  155. }
  156. WorkspaceRow
  157. {
  158. leftLabelText: catalog.i18nc("@action:label", "Derivative from")
  159. rightLabelText: catalog.i18ncp("@action:label", "%1, %2 override", "%1, %2 overrides", manager.numSettingsOverridenByQualityChanges).arg(manager.qualityType).arg(manager.numSettingsOverridenByQualityChanges)
  160. visible: manager.numSettingsOverridenByQualityChanges != 0
  161. }
  162. }
  163. comboboxVisible: manager.qualityChangesConflict
  164. combobox: Cura.ComboBox
  165. {
  166. id: qualityChangesResolveComboBox
  167. model: resolveStrategiesModel
  168. textRole: "label"
  169. visible: manager.qualityChangesConflict
  170. contentLeftPadding: UM.Theme.getSize("default_margin").width + UM.Theme.getSize("narrow_margin").width
  171. textFont: UM.Theme.getFont("medium")
  172. background: Cura.RoundedRectangle
  173. {
  174. border.width: UM.Theme.getSize("default_lining").width
  175. border.color: UM.Theme.getColor("lining")
  176. color: qualityChangesResolveComboBox.hovered ? UM.Theme.getColor("expandable_hover") : UM.Theme.getColor("action_button")
  177. cornerSide: Cura.RoundedRectangle.Direction.All
  178. radius: UM.Theme.getSize("default_radius").width
  179. }
  180. // This is a hack. This will trigger onCurrentIndexChanged and set the index when this component in loaded
  181. currentIndex:
  182. {
  183. currentIndex = 0
  184. }
  185. onCurrentIndexChanged:
  186. {
  187. manager.setResolveStrategy("quality_changes", resolveStrategiesModel.get(currentIndex).key)
  188. }
  189. }
  190. }
  191. WorkspaceSection
  192. {
  193. id: materialSection
  194. title: catalog.i18nc("@action:label", "Material settings")
  195. iconSource: UM.Theme.getIcon("Spool")
  196. content: Column
  197. {
  198. spacing: UM.Theme.getSize("default_margin").height
  199. leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width
  200. Repeater
  201. {
  202. model: manager.materialLabels
  203. delegate: WorkspaceRow
  204. {
  205. leftLabelText: catalog.i18nc("@action:label", "Name")
  206. rightLabelText: modelData
  207. }
  208. }
  209. }
  210. comboboxVisible: manager.materialConflict
  211. combobox: Cura.ComboBox
  212. {
  213. id: materialResolveComboBox
  214. model: resolveStrategiesModel
  215. textRole: "label"
  216. visible: manager.materialConflict
  217. contentLeftPadding: UM.Theme.getSize("default_margin").width + UM.Theme.getSize("narrow_margin").width
  218. textFont: UM.Theme.getFont("medium")
  219. background: Cura.RoundedRectangle
  220. {
  221. border.width: UM.Theme.getSize("default_lining").width
  222. border.color: UM.Theme.getColor("lining")
  223. color: materialResolveComboBox.hovered ? UM.Theme.getColor("expandable_hover") : UM.Theme.getColor("action_button")
  224. cornerSide: Cura.RoundedRectangle.Direction.All
  225. radius: UM.Theme.getSize("default_radius").width
  226. }
  227. // This is a hack. This will trigger onCurrentIndexChanged and set the index when this component in loaded
  228. currentIndex:
  229. {
  230. currentIndex = 0
  231. }
  232. onCurrentIndexChanged:
  233. {
  234. manager.setResolveStrategy("material", resolveStrategiesModel.get(currentIndex).key)
  235. }
  236. }
  237. }
  238. WorkspaceSection
  239. {
  240. id: visibilitySection
  241. title: catalog.i18nc("@action:label", "Setting visibility")
  242. iconSource: UM.Theme.getIcon("Eye")
  243. content: Column
  244. {
  245. spacing: UM.Theme.getSize("default_margin").height
  246. leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width
  247. bottomPadding: UM.Theme.getSize("narrow_margin").height
  248. WorkspaceRow
  249. {
  250. leftLabelText: catalog.i18nc("@action:label", "Mode")
  251. rightLabelText: manager.activeMode
  252. }
  253. WorkspaceRow
  254. {
  255. leftLabelText: catalog.i18nc("@action:label", "%1 out of %2" ).arg(manager.numVisibleSettings).arg(manager.totalNumberOfSettings)
  256. rightLabelText: manager.activeMode
  257. visible: manager.hasVisibleSettingsField
  258. }
  259. }
  260. }
  261. Row
  262. {
  263. id: dropToBuildPlate
  264. width: parent.width
  265. height: childrenRect.height
  266. spacing: UM.Theme.getSize("default_margin").width
  267. UM.CheckBox
  268. {
  269. id: checkDropModels
  270. text: catalog.i18nc("@text:window", "Drop models to buildplate")
  271. checked: UM.Preferences.getValue("physics/automatic_drop_down")
  272. onCheckedChanged: manager.setDropToBuildPlateForModel(checked)
  273. }
  274. function reloadValue()
  275. {
  276. checkDropModels.checked = UM.Preferences.getValue("physics/automatic_drop_down")
  277. }
  278. }
  279. Row
  280. {
  281. id: clearBuildPlateWarning
  282. width: parent.width
  283. height: childrenRect.height
  284. spacing: UM.Theme.getSize("default_margin").width
  285. visible: manager.hasObjectsOnPlate
  286. UM.ColorImage
  287. {
  288. width: warningLabel.height
  289. height: width
  290. source: UM.Theme.getIcon("Information")
  291. color: UM.Theme.getColor("text")
  292. }
  293. UM.Label
  294. {
  295. id: warningLabel
  296. text: catalog.i18nc("@action:warning", "Loading a project will clear all models on the build plate.")
  297. }
  298. }
  299. }
  300. }
  301. }
  302. property bool warning: manager.missingPackages.length > 0
  303. footerComponent: Rectangle
  304. {
  305. color: warning ? UM.Theme.getColor("warning") : "transparent"
  306. anchors.bottom: parent.bottom
  307. width: parent.width
  308. height: childrenRect.height + (warning ? 2 * workspaceDialog.margin : workspaceDialog.margin)
  309. Column
  310. {
  311. height: childrenRect.height
  312. spacing: workspaceDialog.margin
  313. anchors.leftMargin: workspaceDialog.margin
  314. anchors.rightMargin: workspaceDialog.margin
  315. anchors.bottomMargin: workspaceDialog.margin
  316. anchors.topMargin: warning ? workspaceDialog.margin : 0
  317. anchors.left: parent.left
  318. anchors.right: parent.right
  319. anchors.top: parent.top
  320. RowLayout
  321. {
  322. id: warningRow
  323. height: childrenRect.height
  324. visible: warning
  325. spacing: workspaceDialog.margin
  326. UM.ColorImage
  327. {
  328. width: UM.Theme.getSize("extruder_icon").width
  329. height: UM.Theme.getSize("extruder_icon").height
  330. source: UM.Theme.getIcon("Warning")
  331. }
  332. UM.Label
  333. {
  334. id: warningText
  335. 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.")
  336. }
  337. }
  338. Loader
  339. {
  340. width: parent.width
  341. height: childrenRect.height
  342. sourceComponent: buttonRow
  343. }
  344. }
  345. }
  346. buttonSpacing: UM.Theme.getSize("wide_margin").width
  347. rightButtons: [
  348. Cura.TertiaryButton
  349. {
  350. visible: !warning
  351. text: catalog.i18nc("@action:button", "Cancel")
  352. onClicked: reject()
  353. },
  354. Cura.PrimaryButton
  355. {
  356. visible: !warning
  357. text: catalog.i18nc("@action:button", "Open")
  358. onClicked: accept()
  359. },
  360. Cura.TertiaryButton
  361. {
  362. visible: warning
  363. text: catalog.i18nc("@action:button", "Open project anyway")
  364. onClicked: {
  365. manager.showMissingMaterialsWarning();
  366. accept();
  367. }
  368. },
  369. Cura.PrimaryButton
  370. {
  371. visible: warning
  372. text: catalog.i18nc("@action:button", "Install missing packages")
  373. onClicked: manager.installMissingPackages()
  374. }
  375. ]
  376. onClosing: manager.notifyClosed()
  377. onRejected: manager.onCancelButtonClicked()
  378. onAccepted: manager.onOkButtonClicked()
  379. onVisibleChanged:
  380. {
  381. if (visible)
  382. {
  383. // Force relead the comboboxes
  384. // Since this dialog is only created once the first time you open it, these comboxes need to be reloaded
  385. // each time it is shown after the first time so that the indexes will update correctly.
  386. materialSection.reloadValues()
  387. profileSection.reloadValues()
  388. printerSection.reloadValues()
  389. dropToBuildPlate.reloadValue()
  390. }
  391. }
  392. }