WorkspaceDialog.qml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  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
  61. height: childrenRect.height
  62. Column
  63. {
  64. width: parent.width - UM.Theme.getSize("default_margin").width
  65. height: childrenRect.height
  66. spacing: UM.Theme.getSize("default_margin").height
  67. leftPadding: UM.Theme.getSize("default_margin").width
  68. rightPadding: UM.Theme.getSize("default_margin").width
  69. WorkspaceSection
  70. {
  71. id: printerSection
  72. title: catalog.i18nc("@action:label", "Printer settings")
  73. iconSource: UM.Theme.getIcon("Printer")
  74. content: Column
  75. {
  76. spacing: UM.Theme.getSize("default_margin").height
  77. leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width
  78. WorkspaceRow
  79. {
  80. leftLabelText: catalog.i18nc("@action:label", "Type")
  81. rightLabelText: manager.machineType
  82. }
  83. WorkspaceRow
  84. {
  85. leftLabelText: catalog.i18nc("@action:label", manager.isPrinterGroup ? "Printer Group" : "Printer Name")
  86. rightLabelText: manager.machineName
  87. }
  88. }
  89. comboboxTitle: catalog.i18nc("@action:label", "Open With")
  90. comboboxTooltipText: catalog.i18nc("@info:tooltip", "How should the conflict in the machine be resolved?")
  91. comboboxVisible: workspaceDialog.visible && manager.updatableMachinesModel.count > 1
  92. combobox: Cura.MachineSelector
  93. {
  94. id: machineSelector
  95. headerCornerSide: Cura.RoundedRectangle.Direction.All
  96. width: UM.Theme.getSize("machine_selector_widget").width
  97. height: parent.height
  98. anchors.centerIn: parent
  99. machineListModel: manager.updatableMachinesModel
  100. machineName: manager.machineName
  101. isNetworkPrinter: false
  102. isConnectedCloudPrinter: false
  103. isCloudRegistered: false
  104. isGroup: false
  105. onSelectPrinter: function(machine)
  106. {
  107. toggleContent();
  108. manager.setResolveStrategy("machine", "override")
  109. manager.setMachineToOverride(machine.id)
  110. machineSelector.machineName = machine.name
  111. }
  112. }
  113. }
  114. WorkspaceSection
  115. {
  116. id: profileSection
  117. title: catalog.i18nc("@action:label", "Profile settings")
  118. iconSource: UM.Theme.getIcon("Sliders")
  119. content: Column
  120. {
  121. id: profileSettingsValuesTable
  122. spacing: UM.Theme.getSize("default_margin").height
  123. leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width
  124. WorkspaceRow
  125. {
  126. leftLabelText: catalog.i18nc("@action:label", "Name")
  127. rightLabelText: manager.qualityName
  128. }
  129. WorkspaceRow
  130. {
  131. leftLabelText: catalog.i18nc("@action:label", "Intent")
  132. rightLabelText: manager.intentName
  133. }
  134. WorkspaceRow
  135. {
  136. leftLabelText: catalog.i18nc("@action:label", "Not in profile")
  137. rightLabelText: catalog.i18ncp("@action:label", "%1 override", "%1 overrides", manager.numUserSettings).arg(manager.numUserSettings)
  138. visible: manager.numUserSettings != 0
  139. }
  140. WorkspaceRow
  141. {
  142. leftLabelText: catalog.i18nc("@action:label", "Derivative from")
  143. rightLabelText: catalog.i18ncp("@action:label", "%1, %2 override", "%1, %2 overrides", manager.numSettingsOverridenByQualityChanges).arg(manager.qualityType).arg(manager.numSettingsOverridenByQualityChanges)
  144. visible: manager.numSettingsOverridenByQualityChanges != 0
  145. }
  146. }
  147. comboboxTooltipText: catalog.i18nc("@info:tooltip", "How should the conflict in the profile be resolved?")
  148. comboboxVisible: manager.qualityChangesConflict
  149. combobox: Cura.ComboBox
  150. {
  151. id: qualityChangesResolveComboBox
  152. model: resolveStrategiesModel
  153. textRole: "label"
  154. visible: manager.qualityChangesConflict
  155. // This is a hack. This will trigger onCurrentIndexChanged and set the index when this component in loaded
  156. currentIndex:
  157. {
  158. currentIndex = 0
  159. }
  160. onCurrentIndexChanged:
  161. {
  162. manager.setResolveStrategy("quality_changes", resolveStrategiesModel.get(currentIndex).key)
  163. }
  164. }
  165. }
  166. WorkspaceSection
  167. {
  168. id: materialSection
  169. title: catalog.i18nc("@action:label", "Material settings")
  170. iconSource: UM.Theme.getIcon("Spool")
  171. content: Column
  172. {
  173. spacing: UM.Theme.getSize("default_margin").height
  174. leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width
  175. Repeater
  176. {
  177. model: manager.materialLabels
  178. delegate: WorkspaceRow
  179. {
  180. leftLabelText: catalog.i18nc("@action:label", "Name")
  181. rightLabelText: modelData
  182. }
  183. }
  184. }
  185. comboboxTooltipText: catalog.i18nc("@info:tooltip", "How should the conflict in the material be resolved?")
  186. comboboxVisible: manager.materialConflict
  187. combobox: Cura.ComboBox
  188. {
  189. id: materialResolveComboBox
  190. model: resolveStrategiesModel
  191. textRole: "label"
  192. visible: manager.materialConflict
  193. // This is a hack. This will trigger onCurrentIndexChanged and set the index when this component in loaded
  194. currentIndex:
  195. {
  196. currentIndex = 0
  197. }
  198. onCurrentIndexChanged:
  199. {
  200. manager.setResolveStrategy("material", resolveStrategiesModel.get(currentIndex).key)
  201. }
  202. }
  203. }
  204. WorkspaceSection
  205. {
  206. id: visibilitySection
  207. title: catalog.i18nc("@action:label", "Setting visibility")
  208. iconSource: UM.Theme.getIcon("Eye")
  209. content: Column
  210. {
  211. spacing: UM.Theme.getSize("default_margin").height
  212. leftPadding: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width
  213. bottomPadding: UM.Theme.getSize("narrow_margin").height
  214. WorkspaceRow
  215. {
  216. leftLabelText: catalog.i18nc("@action:label", "Mode")
  217. rightLabelText: manager.activeMode
  218. }
  219. WorkspaceRow
  220. {
  221. leftLabelText: catalog.i18nc("@action:label", "%1 out of %2" ).arg(manager.numVisibleSettings).arg(manager.totalNumberOfSettings)
  222. rightLabelText: manager.activeMode
  223. visible: manager.hasVisibleSettingsField
  224. }
  225. }
  226. }
  227. Row
  228. {
  229. id: clearBuildPlateWarning
  230. width: parent.width
  231. height: childrenRect.height
  232. spacing: UM.Theme.getSize("default_margin").width
  233. visible: manager.hasObjectsOnPlate
  234. UM.ColorImage
  235. {
  236. width: warningLabel.height
  237. height: width
  238. source: UM.Theme.getIcon("Information")
  239. color: UM.Theme.getColor("text")
  240. }
  241. UM.Label
  242. {
  243. id: warningLabel
  244. text: catalog.i18nc("@action:warning", "Loading a project will clear all models on the build plate.")
  245. }
  246. }
  247. }
  248. }
  249. }
  250. }
  251. property bool warning: manager.missingPackages.length > 0
  252. footerComponent: Rectangle
  253. {
  254. color: warning ? UM.Theme.getColor("warning") : "transparent"
  255. anchors.bottom: parent.bottom
  256. width: parent.width
  257. height: childrenRect.height + (warning ? 2 * workspaceDialog.margin : workspaceDialog.margin)
  258. Column
  259. {
  260. height: childrenRect.height
  261. spacing: workspaceDialog.margin
  262. anchors.leftMargin: workspaceDialog.margin
  263. anchors.rightMargin: workspaceDialog.margin
  264. anchors.bottomMargin: workspaceDialog.margin
  265. anchors.topMargin: warning ? workspaceDialog.margin : 0
  266. anchors.left: parent.left
  267. anchors.right: parent.right
  268. anchors.top: parent.top
  269. RowLayout
  270. {
  271. id: warningRow
  272. height: childrenRect.height
  273. visible: warning
  274. spacing: workspaceDialog.margin
  275. UM.ColorImage
  276. {
  277. width: UM.Theme.getSize("extruder_icon").width
  278. height: UM.Theme.getSize("extruder_icon").height
  279. source: UM.Theme.getIcon("Warning")
  280. }
  281. UM.Label
  282. {
  283. id: warningText
  284. text: catalog.i18nc("@label", "The material used in this project is currently not installed in Cura.<br/>Install the material profile and reopen the project.")
  285. }
  286. }
  287. Loader
  288. {
  289. width: parent.width
  290. height: childrenRect.height
  291. sourceComponent: buttonRow
  292. }
  293. }
  294. }
  295. buttonSpacing: UM.Theme.getSize("wide_margin").width
  296. rightButtons: [
  297. Cura.TertiaryButton
  298. {
  299. visible: !warning
  300. text: catalog.i18nc("@action:button", "Cancel")
  301. onClicked: reject()
  302. },
  303. Cura.PrimaryButton
  304. {
  305. visible: !warning
  306. text: catalog.i18nc("@action:button", "Open")
  307. onClicked: accept()
  308. },
  309. Cura.TertiaryButton
  310. {
  311. visible: warning
  312. text: catalog.i18nc("@action:button", "Open project anyway")
  313. onClicked: {
  314. manager.showMissingMaterialsWarning();
  315. accept();
  316. }
  317. },
  318. Cura.PrimaryButton
  319. {
  320. visible: warning
  321. text: catalog.i18nc("@action:button", "Install missing material")
  322. onClicked: manager.installMissingPackages()
  323. }
  324. ]
  325. onClosing: manager.notifyClosed()
  326. onRejected: manager.onCancelButtonClicked()
  327. onAccepted: manager.onOkButtonClicked()
  328. onVisibleChanged:
  329. {
  330. if (visible)
  331. {
  332. // Force relead the comboboxes
  333. // Since this dialog is only created once the first time you open it, these comboxes need to be reloaded
  334. // each time it is shown after the first time so that the indexes will update correctly.
  335. materialSection.reloadValues()
  336. profileSection.reloadValues()
  337. printerSection.reloadValues()
  338. }
  339. }
  340. }