SidebarSimple.qml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. // Copyright (c) 2016 Ultimaker B.V.
  2. // Cura is released under the terms of the AGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 1.1
  5. import QtQuick.Controls.Styles 1.1
  6. import QtQuick.Layouts 1.1
  7. import UM 1.2 as UM
  8. import Cura 1.0 as Cura
  9. Item
  10. {
  11. id: base;
  12. signal showTooltip(Item item, point location, string text);
  13. signal hideTooltip();
  14. property Action configureSettings;
  15. property variant minimumPrintTime: PrintInformation.minimumPrintTime;
  16. property variant maximumPrintTime: PrintInformation.maximumPrintTime;
  17. property bool settingsEnabled: ExtruderManager.activeExtruderStackId || ExtruderManager.extruderCount == 0
  18. Component.onCompleted: PrintInformation.enabled = true
  19. Component.onDestruction: PrintInformation.enabled = false
  20. UM.I18nCatalog { id: catalog; name:"cura"}
  21. Rectangle
  22. {
  23. id: infillCellLeft
  24. anchors.top: parent.top
  25. anchors.left: parent.left
  26. width: base.width / 100 * 35 - UM.Theme.getSize("default_margin").width
  27. height: childrenRect.height
  28. Label
  29. {
  30. id: infillLabel
  31. //: Infill selection label
  32. text: catalog.i18nc("@label", "Infill");
  33. font: UM.Theme.getFont("default");
  34. color: UM.Theme.getColor("text");
  35. anchors.top: parent.top
  36. anchors.topMargin: UM.Theme.getSize("default_margin").height
  37. anchors.left: parent.left
  38. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  39. }
  40. }
  41. Flow
  42. {
  43. id: infillCellRight
  44. height: childrenRect.height;
  45. width: base.width / 100 * 65
  46. spacing: UM.Theme.getSize("default_margin").width
  47. anchors.left: infillCellLeft.right
  48. anchors.top: infillCellLeft.top
  49. Repeater
  50. {
  51. id: infillListView
  52. property int activeIndex:
  53. {
  54. var density = parseInt(infillDensity.properties.value)
  55. for(var i = 0; i < infillModel.count; ++i)
  56. {
  57. if(density > infillModel.get(i).percentageMin && density <= infillModel.get(i).percentageMax )
  58. {
  59. return i;
  60. }
  61. }
  62. return -1;
  63. }
  64. model: infillModel;
  65. Item
  66. {
  67. width: childrenRect.width;
  68. height: childrenRect.height;
  69. Rectangle
  70. {
  71. id: infillIconLining
  72. width: (infillCellRight.width - 3 * UM.Theme.getSize("default_margin").width) / 4;
  73. height: width
  74. border.color:
  75. {
  76. if(!base.settingsEnabled)
  77. {
  78. return UM.Theme.getColor("setting_control_disabled_border")
  79. }
  80. else if(infillListView.activeIndex == index)
  81. {
  82. return UM.Theme.getColor("setting_control_selected")
  83. }
  84. else if(infillMouseArea.containsMouse)
  85. {
  86. return UM.Theme.getColor("setting_control_border_highlight")
  87. }
  88. return UM.Theme.getColor("setting_control_border")
  89. }
  90. border.width: UM.Theme.getSize("default_lining").width
  91. color:
  92. {
  93. if(infillListView.activeIndex == index)
  94. {
  95. if(!base.settingsEnabled)
  96. {
  97. return UM.Theme.getColor("setting_control_disabled_text")
  98. }
  99. return UM.Theme.getColor("setting_control_selected")
  100. }
  101. return "transparent"
  102. }
  103. UM.RecolorImage
  104. {
  105. id: infillIcon
  106. anchors.fill: parent;
  107. anchors.margins: UM.Theme.getSize("infill_button_margin").width
  108. sourceSize.width: width
  109. sourceSize.height: width
  110. source: UM.Theme.getIcon(model.icon);
  111. color: {
  112. if(infillListView.activeIndex == index)
  113. {
  114. return UM.Theme.getColor("text_reversed")
  115. }
  116. if(!base.settingsEnabled)
  117. {
  118. return UM.Theme.getColor("setting_control_disabled_text")
  119. }
  120. return UM.Theme.getColor("setting_control_disabled_text")
  121. }
  122. }
  123. MouseArea
  124. {
  125. id: infillMouseArea
  126. anchors.fill: parent
  127. hoverEnabled: true
  128. enabled: base.settingsEnabled
  129. onClicked: {
  130. if (infillListView.activeIndex != index)
  131. {
  132. infillDensity.setPropertyValue("value", model.percentage)
  133. }
  134. }
  135. onEntered:
  136. {
  137. base.showTooltip(infillCellRight, Qt.point(-infillCellRight.x, 0), model.text);
  138. }
  139. onExited:
  140. {
  141. base.hideTooltip();
  142. }
  143. }
  144. }
  145. Label
  146. {
  147. id: infillLabel
  148. font: UM.Theme.getFont("default")
  149. anchors.top: infillIconLining.bottom
  150. anchors.horizontalCenter: infillIconLining.horizontalCenter
  151. color: infillListView.activeIndex == index ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_border")
  152. text: name
  153. }
  154. }
  155. }
  156. ListModel
  157. {
  158. id: infillModel
  159. Component.onCompleted:
  160. {
  161. infillModel.append({
  162. name: catalog.i18nc("@label", "Hollow"),
  163. percentage: 0,
  164. percentageMin: -1,
  165. percentageMax: 0,
  166. text: catalog.i18nc("@label", "No (0%) infill will leave your model hollow at the cost of low strength"),
  167. icon: "hollow"
  168. })
  169. infillModel.append({
  170. name: catalog.i18nc("@label", "Light"),
  171. percentage: 20,
  172. percentageMin: 0,
  173. percentageMax: 30,
  174. text: catalog.i18nc("@label", "Light (20%) infill will give your model an average strength"),
  175. icon: "sparse"
  176. })
  177. infillModel.append({
  178. name: catalog.i18nc("@label", "Dense"),
  179. percentage: 50,
  180. percentageMin: 30,
  181. percentageMax: 70,
  182. text: catalog.i18nc("@label", "Dense (50%) infill will give your model an above average strength"),
  183. icon: "dense"
  184. })
  185. infillModel.append({
  186. name: catalog.i18nc("@label", "Solid"),
  187. percentage: 100,
  188. percentageMin: 70,
  189. percentageMax: 100,
  190. text: catalog.i18nc("@label", "Solid (100%) infill will make your model completely solid"),
  191. icon: "solid"
  192. })
  193. }
  194. }
  195. }
  196. Rectangle
  197. {
  198. id: helpersCell
  199. anchors.top: infillCellRight.bottom
  200. anchors.topMargin: UM.Theme.getSize("default_margin").height
  201. anchors.left: parent.left
  202. anchors.right: parent.right
  203. height: childrenRect.height
  204. Label
  205. {
  206. id: enableSupportLabel
  207. anchors.left: parent.left
  208. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  209. anchors.verticalCenter: enableSupportCheckBox.verticalCenter
  210. width: parent.width / 100 * 45 - 3 * UM.Theme.getSize("default_margin").width
  211. text: catalog.i18nc("@label", "Enable Support");
  212. font: UM.Theme.getFont("default");
  213. color: UM.Theme.getColor("text");
  214. }
  215. CheckBox
  216. {
  217. id: enableSupportCheckBox
  218. anchors.top: parent.top
  219. anchors.left: enableSupportLabel.right
  220. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  221. style: UM.Theme.styles.checkbox;
  222. enabled: base.settingsEnabled
  223. checked: supportEnabled.properties.value == "True";
  224. MouseArea
  225. {
  226. id: enableSupportMouseArea
  227. anchors.fill: parent
  228. hoverEnabled: true
  229. enabled: true
  230. onClicked:
  231. {
  232. // The value is a string "True" or "False"
  233. supportEnabled.setPropertyValue("value", supportEnabled.properties.value != "True");
  234. }
  235. onEntered:
  236. {
  237. base.showTooltip(enableSupportCheckBox, Qt.point(-enableSupportCheckBox.x, 0),
  238. catalog.i18nc("@label", supportEnabled.properties.description));
  239. }
  240. onExited:
  241. {
  242. base.hideTooltip();
  243. }
  244. }
  245. }
  246. Label
  247. {
  248. id: supportExtruderLabel
  249. visible: (supportEnabled.properties.value == "True") && (machineExtruderCount.properties.value > 1)
  250. anchors.left: parent.left
  251. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  252. anchors.verticalCenter: supportExtruderCombobox.verticalCenter
  253. width: parent.width / 100 * 45 - 3 * UM.Theme.getSize("default_margin").width
  254. text: catalog.i18nc("@label", "Support Extruder");
  255. font: UM.Theme.getFont("default");
  256. color: UM.Theme.getColor("text");
  257. }
  258. ComboBox
  259. {
  260. id: supportExtruderCombobox
  261. visible: (supportEnabled.properties.value == "True") && (machineExtruderCount.properties.value > 1)
  262. model: extruderModel
  263. property string color_override: "" // for manually setting values
  264. property string color: // is evaluated automatically, but the first time is before extruderModel being filled
  265. {
  266. var current_extruder = extruderModel.get(currentIndex);
  267. color_override = "";
  268. if (current_extruder === undefined) {
  269. return "";
  270. }
  271. var model_color = current_extruder.color;
  272. return (model_color) ? model_color : "";
  273. }
  274. textRole: 'text' // this solves that the combobox isn't populated in the first time Cura is started
  275. anchors.top: enableSupportCheckBox.bottom
  276. anchors.topMargin:
  277. {
  278. if ((supportEnabled.properties.value == "True") && (machineExtruderCount.properties.value > 1))
  279. {
  280. return UM.Theme.getSize("default_margin").height;
  281. }
  282. else
  283. {
  284. return 0;
  285. }
  286. }
  287. anchors.left: supportExtruderLabel.right
  288. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  289. width: parent.width / 100 * 55
  290. height:
  291. {
  292. if ((supportEnabled.properties.value == "True") && (machineExtruderCount.properties.value > 1))
  293. {
  294. // default height when control is enabled
  295. return UM.Theme.getSize("setting_control").height;
  296. }
  297. else
  298. {
  299. return 0;
  300. }
  301. }
  302. style: UM.Theme.styles.combobox_color
  303. enabled: base.settingsEnabled
  304. property alias _hovered: supportExtruderMouseArea.containsMouse
  305. currentIndex: supportExtruderNr.properties !== null ? parseFloat(supportExtruderNr.properties.value) : 0
  306. onActivated:
  307. {
  308. // Send the extruder nr as a string.
  309. supportExtruderNr.setPropertyValue("value", String(index));
  310. }
  311. MouseArea
  312. {
  313. id: supportExtruderMouseArea
  314. anchors.fill: parent
  315. hoverEnabled: true
  316. enabled: base.settingsEnabled
  317. acceptedButtons: Qt.NoButton
  318. onEntered:
  319. {
  320. base.showTooltip(supportExtruderCombobox, Qt.point(-supportExtruderCombobox.x, 0),
  321. catalog.i18nc("@label", "Select which extruder to use for support. This will build up supporting structures below the model to prevent the model from sagging or printing in mid air."));
  322. }
  323. onExited:
  324. {
  325. base.hideTooltip();
  326. }
  327. }
  328. function updateCurrentColor()
  329. {
  330. var current_extruder = extruderModel.get(currentIndex);
  331. if (current_extruder !== undefined) {
  332. supportExtruderCombobox.color_override = current_extruder.color;
  333. }
  334. }
  335. }
  336. Label
  337. {
  338. id: adhesionHelperLabel
  339. anchors.left: parent.left
  340. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  341. anchors.verticalCenter: adhesionCheckBox.verticalCenter
  342. width: parent.width / 100 * 45 - 3 * UM.Theme.getSize("default_margin").width
  343. text: catalog.i18nc("@label", "Build Plate Adhesion");
  344. font: UM.Theme.getFont("default");
  345. color: UM.Theme.getColor("text");
  346. }
  347. CheckBox
  348. {
  349. id: adhesionCheckBox
  350. property alias _hovered: adhesionMouseArea.containsMouse
  351. anchors.top: supportExtruderCombobox.bottom
  352. anchors.topMargin: UM.Theme.getSize("default_margin").height
  353. anchors.left: adhesionHelperLabel.right
  354. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  355. //: Setting enable printing build-plate adhesion helper checkbox
  356. style: UM.Theme.styles.checkbox;
  357. enabled: base.settingsEnabled
  358. checked: platformAdhesionType.properties.value != "skirt"
  359. MouseArea
  360. {
  361. id: adhesionMouseArea
  362. anchors.fill: parent
  363. hoverEnabled: true
  364. enabled: base.settingsEnabled
  365. onClicked:
  366. {
  367. var adhesionType = "skirt";
  368. if(!parent.checked)
  369. {
  370. // Remove the "user" setting to see if the rest of the stack prescribes a brim or a raft
  371. platformAdhesionType.removeFromContainer(0);
  372. adhesionType = platformAdhesionType.properties.value;
  373. if(adhesionType == "skirt")
  374. {
  375. // If the rest of the stack doesn't prescribe an adhesion-type, default to a brim
  376. adhesionType = "brim";
  377. }
  378. }
  379. platformAdhesionType.setPropertyValue("value", adhesionType);
  380. }
  381. onEntered:
  382. {
  383. base.showTooltip(adhesionCheckBox, Qt.point(-adhesionCheckBox.x, 0),
  384. catalog.i18nc("@label", "Enable printing a brim or raft. This will add a flat area around or under your object which is easy to cut off afterwards."));
  385. }
  386. onExited:
  387. {
  388. base.hideTooltip();
  389. }
  390. }
  391. }
  392. ListModel
  393. {
  394. id: extruderModel
  395. Component.onCompleted: populateExtruderModel()
  396. }
  397. //: Model used to populate the extrudelModel
  398. Cura.ExtrudersModel
  399. {
  400. id: extruders
  401. onModelChanged: populateExtruderModel()
  402. }
  403. }
  404. function populateExtruderModel()
  405. {
  406. extruderModel.clear();
  407. for(var extruderNumber = 0; extruderNumber < extruders.rowCount() ; extruderNumber++)
  408. {
  409. extruderModel.append({
  410. text: extruders.getItem(extruderNumber).name,
  411. color: extruders.getItem(extruderNumber).color
  412. })
  413. }
  414. supportExtruderCombobox.updateCurrentColor();
  415. }
  416. Rectangle
  417. {
  418. id: tipsCell
  419. anchors.top: helpersCell.bottom
  420. anchors.topMargin: UM.Theme.getSize("default_margin").height
  421. anchors.left: parent.left
  422. width: parent.width
  423. height: childrenRect.height
  424. Label
  425. {
  426. anchors.left: parent.left
  427. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  428. anchors.right: parent.right
  429. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  430. wrapMode: Text.WordWrap
  431. //: Tips label
  432. text: catalog.i18nc("@label", "Need help improving your prints? Read the <a href='%1'>Ultimaker Troubleshooting Guides</a>").arg("https://ultimaker.com/en/troubleshooting");
  433. font: UM.Theme.getFont("default");
  434. color: UM.Theme.getColor("text");
  435. linkColor: UM.Theme.getColor("text_link")
  436. onLinkActivated: Qt.openUrlExternally(link)
  437. }
  438. }
  439. UM.SettingPropertyProvider
  440. {
  441. id: infillDensity
  442. containerStackId: Cura.MachineManager.activeStackId
  443. key: "infill_sparse_density"
  444. watchedProperties: [ "value" ]
  445. storeIndex: 0
  446. }
  447. UM.SettingPropertyProvider
  448. {
  449. id: platformAdhesionType
  450. containerStackId: Cura.MachineManager.activeMachineId
  451. key: "adhesion_type"
  452. watchedProperties: [ "value" ]
  453. storeIndex: 0
  454. }
  455. UM.SettingPropertyProvider
  456. {
  457. id: supportEnabled
  458. containerStackId: Cura.MachineManager.activeMachineId
  459. key: "support_enable"
  460. watchedProperties: [ "value", "description" ]
  461. storeIndex: 0
  462. }
  463. UM.SettingPropertyProvider
  464. {
  465. id: machineExtruderCount
  466. containerStackId: Cura.MachineManager.activeMachineId
  467. key: "machine_extruder_count"
  468. watchedProperties: [ "value" ]
  469. storeIndex: 0
  470. }
  471. UM.SettingPropertyProvider
  472. {
  473. id: supportExtruderNr
  474. containerStackId: Cura.MachineManager.activeMachineId
  475. key: "support_extruder_nr"
  476. watchedProperties: [ "value" ]
  477. storeIndex: 0
  478. }
  479. }