SidebarSimple.qml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  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. Item
  22. {
  23. id: infillCellLeft
  24. anchors.top: parent.top
  25. anchors.left: parent.left
  26. width: base.width * .45 - 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 * .55
  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. Item
  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 * .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", "Enable support structures. These structures support parts of the model with severe overhangs."));
  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 * .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 * .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. Behavior on height { NumberAnimation { duration: 100 } }
  303. style: UM.Theme.styles.combobox_color
  304. enabled: base.settingsEnabled
  305. property alias _hovered: supportExtruderMouseArea.containsMouse
  306. currentIndex: supportExtruderNr.properties !== null ? parseFloat(supportExtruderNr.properties.value) : 0
  307. onActivated:
  308. {
  309. // Send the extruder nr as a string.
  310. supportExtruderNr.setPropertyValue("value", String(index));
  311. }
  312. MouseArea
  313. {
  314. id: supportExtruderMouseArea
  315. anchors.fill: parent
  316. hoverEnabled: true
  317. enabled: base.settingsEnabled
  318. acceptedButtons: Qt.NoButton
  319. onEntered:
  320. {
  321. base.showTooltip(supportExtruderCombobox, Qt.point(-supportExtruderCombobox.x, 0),
  322. 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."));
  323. }
  324. onExited:
  325. {
  326. base.hideTooltip();
  327. }
  328. }
  329. function updateCurrentColor()
  330. {
  331. var current_extruder = extruderModel.get(currentIndex);
  332. if (current_extruder !== undefined) {
  333. supportExtruderCombobox.color_override = current_extruder.color;
  334. }
  335. }
  336. }
  337. Label
  338. {
  339. id: adhesionHelperLabel
  340. anchors.left: parent.left
  341. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  342. anchors.verticalCenter: adhesionCheckBox.verticalCenter
  343. width: parent.width * .45 - 3 * UM.Theme.getSize("default_margin").width
  344. text: catalog.i18nc("@label", "Build Plate Adhesion");
  345. font: UM.Theme.getFont("default");
  346. color: UM.Theme.getColor("text");
  347. }
  348. CheckBox
  349. {
  350. id: adhesionCheckBox
  351. property alias _hovered: adhesionMouseArea.containsMouse
  352. anchors.top: supportExtruderCombobox.bottom
  353. anchors.topMargin: UM.Theme.getSize("default_margin").height
  354. anchors.left: adhesionHelperLabel.right
  355. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  356. //: Setting enable printing build-plate adhesion helper checkbox
  357. style: UM.Theme.styles.checkbox;
  358. enabled: base.settingsEnabled
  359. checked: platformAdhesionType.properties.value != "skirt" && platformAdhesionType.properties.value != "none"
  360. MouseArea
  361. {
  362. id: adhesionMouseArea
  363. anchors.fill: parent
  364. hoverEnabled: true
  365. enabled: base.settingsEnabled
  366. onClicked:
  367. {
  368. var adhesionType = "skirt";
  369. if(!parent.checked)
  370. {
  371. // Remove the "user" setting to see if the rest of the stack prescribes a brim or a raft
  372. platformAdhesionType.removeFromContainer(0);
  373. adhesionType = platformAdhesionType.properties.value;
  374. if(adhesionType == "skirt")
  375. {
  376. // If the rest of the stack doesn't prescribe an adhesion-type, default to a brim
  377. adhesionType = "brim";
  378. }
  379. }
  380. platformAdhesionType.setPropertyValue("value", adhesionType);
  381. }
  382. onEntered:
  383. {
  384. base.showTooltip(adhesionCheckBox, Qt.point(-adhesionCheckBox.x, 0),
  385. 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."));
  386. }
  387. onExited:
  388. {
  389. base.hideTooltip();
  390. }
  391. }
  392. }
  393. ListModel
  394. {
  395. id: extruderModel
  396. Component.onCompleted: populateExtruderModel()
  397. }
  398. //: Model used to populate the extrudelModel
  399. Cura.ExtrudersModel
  400. {
  401. id: extruders
  402. onModelChanged: populateExtruderModel()
  403. }
  404. }
  405. function populateExtruderModel()
  406. {
  407. extruderModel.clear();
  408. for(var extruderNumber = 0; extruderNumber < extruders.rowCount() ; extruderNumber++)
  409. {
  410. extruderModel.append({
  411. text: extruders.getItem(extruderNumber).name,
  412. color: extruders.getItem(extruderNumber).color
  413. })
  414. }
  415. supportExtruderCombobox.updateCurrentColor();
  416. }
  417. Item
  418. {
  419. id: tipsCell
  420. anchors.top: helpersCell.bottom
  421. anchors.topMargin: UM.Theme.getSize("default_margin").height
  422. anchors.left: parent.left
  423. width: parent.width
  424. height: childrenRect.height
  425. Label
  426. {
  427. anchors.left: parent.left
  428. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  429. anchors.right: parent.right
  430. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  431. wrapMode: Text.WordWrap
  432. //: Tips label
  433. text: catalog.i18nc("@label", "Need help improving your prints? Read the <a href='%1'>Ultimaker Troubleshooting Guides</a>").arg("https://ultimaker.com/en/troubleshooting");
  434. font: UM.Theme.getFont("default");
  435. color: UM.Theme.getColor("text");
  436. linkColor: UM.Theme.getColor("text_link")
  437. onLinkActivated: Qt.openUrlExternally(link)
  438. }
  439. }
  440. UM.SettingPropertyProvider
  441. {
  442. id: infillDensity
  443. containerStackId: Cura.MachineManager.activeStackId
  444. key: "infill_sparse_density"
  445. watchedProperties: [ "value" ]
  446. storeIndex: 0
  447. }
  448. UM.SettingPropertyProvider
  449. {
  450. id: platformAdhesionType
  451. containerStackId: Cura.MachineManager.activeMachineId
  452. key: "adhesion_type"
  453. watchedProperties: [ "value" ]
  454. storeIndex: 0
  455. }
  456. UM.SettingPropertyProvider
  457. {
  458. id: supportEnabled
  459. containerStackId: Cura.MachineManager.activeMachineId
  460. key: "support_enable"
  461. watchedProperties: [ "value", "description" ]
  462. storeIndex: 0
  463. }
  464. UM.SettingPropertyProvider
  465. {
  466. id: machineExtruderCount
  467. containerStackId: Cura.MachineManager.activeMachineId
  468. key: "machine_extruder_count"
  469. watchedProperties: [ "value" ]
  470. storeIndex: 0
  471. }
  472. UM.SettingPropertyProvider
  473. {
  474. id: supportExtruderNr
  475. containerStackId: Cura.MachineManager.activeMachineId
  476. key: "support_extruder_nr"
  477. watchedProperties: [ "value" ]
  478. storeIndex: 0
  479. }
  480. }