SidebarSimple.qml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. // Copyright (c) 2015 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. id: infillCellLeft
  23. anchors.top: parent.top
  24. anchors.left: parent.left
  25. width: base.width / 100 * 35 - UM.Theme.getSize("default_margin").width
  26. height: childrenRect.height
  27. Label{
  28. id: infillLabel
  29. //: Infill selection label
  30. text: catalog.i18nc("@label", "Infill:");
  31. font: UM.Theme.getFont("default");
  32. color: UM.Theme.getColor("text");
  33. anchors.top: parent.top
  34. anchors.topMargin: UM.Theme.getSize("default_margin").height
  35. anchors.left: parent.left
  36. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  37. }
  38. }
  39. Flow {
  40. id: infillCellRight
  41. height: childrenRect.height;
  42. width: base.width / 100 * 65
  43. spacing: UM.Theme.getSize("default_margin").width
  44. anchors.left: infillCellLeft.right
  45. anchors.top: infillCellLeft.top
  46. Repeater {
  47. id: infillListView
  48. property int activeIndex: {
  49. var density = parseInt(infillDensity.properties.value)
  50. for(var i = 0; i < infillModel.count; ++i)
  51. {
  52. if(density > infillModel.get(i).percentageMin && density <= infillModel.get(i).percentageMax )
  53. {
  54. return i;
  55. }
  56. }
  57. return -1;
  58. }
  59. model: infillModel;
  60. Item {
  61. width: childrenRect.width;
  62. height: childrenRect.height;
  63. Rectangle{
  64. id: infillIconLining
  65. width: (infillCellRight.width - 3 * UM.Theme.getSize("default_margin").width) / 4;
  66. height: width
  67. border.color: {
  68. if(!base.settingsEnabled)
  69. {
  70. return UM.Theme.getColor("setting_control_disabled_border")
  71. }
  72. else if(infillListView.activeIndex == index)
  73. {
  74. return UM.Theme.getColor("setting_control_selected")
  75. }
  76. else if(infillMouseArea.containsMouse)
  77. {
  78. return UM.Theme.getColor("setting_control_border_highlight")
  79. }
  80. return UM.Theme.getColor("setting_control_border")
  81. }
  82. border.width: UM.Theme.getSize("default_lining").width
  83. color: {
  84. if(infillListView.activeIndex == index)
  85. {
  86. if(!base.settingsEnabled)
  87. {
  88. return UM.Theme.getColor("setting_control_disabled_text")
  89. }
  90. return UM.Theme.getColor("setting_control_selected")
  91. }
  92. return "transparent"
  93. }
  94. UM.RecolorImage {
  95. id: infillIcon
  96. anchors.fill: parent;
  97. anchors.margins: UM.Theme.getSize("infill_button_margin").width
  98. sourceSize.width: width
  99. sourceSize.height: width
  100. source: UM.Theme.getIcon(model.icon);
  101. color: {
  102. if(infillListView.activeIndex == index)
  103. {
  104. return UM.Theme.getColor("text_reversed")
  105. }
  106. if(!base.settingsEnabled)
  107. {
  108. return UM.Theme.getColor("setting_control_disabled_text")
  109. }
  110. return UM.Theme.getColor("text")
  111. }
  112. }
  113. MouseArea {
  114. id: infillMouseArea
  115. anchors.fill: parent
  116. hoverEnabled: true
  117. enabled: base.settingsEnabled
  118. onClicked: {
  119. if (infillListView.activeIndex != index)
  120. {
  121. infillDensity.setPropertyValue("value", model.percentage)
  122. }
  123. }
  124. onEntered: {
  125. base.showTooltip(infillCellRight, Qt.point(-infillCellRight.x, 0), model.text);
  126. }
  127. onExited: {
  128. base.hideTooltip();
  129. }
  130. }
  131. }
  132. Label{
  133. id: infillLabel
  134. font: UM.Theme.getFont("default")
  135. anchors.top: infillIconLining.bottom
  136. anchors.horizontalCenter: infillIconLining.horizontalCenter
  137. color: infillListView.activeIndex == index ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_border")
  138. text: name
  139. }
  140. }
  141. }
  142. ListModel {
  143. id: infillModel
  144. Component.onCompleted:
  145. {
  146. infillModel.append({
  147. name: catalog.i18nc("@label", "Hollow"),
  148. percentage: 0,
  149. percentageMin: -1,
  150. percentageMax: 0,
  151. text: catalog.i18nc("@label", "No (0%) infill will leave your model hollow at the cost of low strength"),
  152. icon: "hollow"
  153. })
  154. infillModel.append({
  155. name: catalog.i18nc("@label", "Light"),
  156. percentage: 20,
  157. percentageMin: 0,
  158. percentageMax: 30,
  159. text: catalog.i18nc("@label", "Light (20%) infill will give your model an average strength"),
  160. icon: "sparse"
  161. })
  162. infillModel.append({
  163. name: catalog.i18nc("@label", "Dense"),
  164. percentage: 50,
  165. percentageMin: 30,
  166. percentageMax: 70,
  167. text: catalog.i18nc("@label", "Dense (50%) infill will give your model an above average strength"),
  168. icon: "dense"
  169. })
  170. infillModel.append({
  171. name: catalog.i18nc("@label", "Solid"),
  172. percentage: 100,
  173. percentageMin: 70,
  174. percentageMax: 100,
  175. text: catalog.i18nc("@label", "Solid (100%) infill will make your model completely solid"),
  176. icon: "solid"
  177. })
  178. }
  179. }
  180. }
  181. Rectangle {
  182. id: helpersCell
  183. anchors.top: infillCellRight.bottom
  184. anchors.topMargin: UM.Theme.getSize("default_margin").height
  185. anchors.left: parent.left
  186. anchors.right: parent.right
  187. height: childrenRect.height
  188. Label{
  189. id: adhesionHelperLabel
  190. anchors.left: parent.left
  191. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  192. anchors.verticalCenter: adhesionCheckBox.verticalCenter
  193. width: parent.width / 100 * 35 - 3 * UM.Theme.getSize("default_margin").width
  194. //: Bed adhesion label
  195. text: catalog.i18nc("@label", "Helper Parts:");
  196. font: UM.Theme.getFont("default");
  197. color: UM.Theme.getColor("text");
  198. }
  199. CheckBox{
  200. id: adhesionCheckBox
  201. property alias _hovered: adhesionMouseArea.containsMouse
  202. anchors.top: parent.top
  203. anchors.left: adhesionHelperLabel.right
  204. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  205. //: Setting enable printing build-plate adhesion helper checkbox
  206. text: catalog.i18nc("@option:check", "Print Build Plate Adhesion");
  207. style: UM.Theme.styles.checkbox;
  208. enabled: base.settingsEnabled
  209. checked: platformAdhesionType.properties.value != "skirt"
  210. MouseArea {
  211. id: adhesionMouseArea
  212. anchors.fill: parent
  213. hoverEnabled: true
  214. enabled: base.settingsEnabled
  215. onClicked:
  216. {
  217. var adhesionType = "skirt";
  218. if(!parent.checked)
  219. {
  220. // Remove the "user" setting to see if the rest of the stack prescribes a brim or a raft
  221. platformAdhesionType.removeFromContainer(0);
  222. adhesionType = platformAdhesionType.properties.value;
  223. if(adhesionType == "skirt")
  224. {
  225. // If the rest of the stack doesn't prescribe an adhesion-type, default to a brim
  226. adhesionType = "brim";
  227. }
  228. }
  229. platformAdhesionType.setPropertyValue("value", adhesionType);
  230. }
  231. onEntered:
  232. {
  233. base.showTooltip(adhesionCheckBox, Qt.point(-adhesionCheckBox.x, 0),
  234. 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."));
  235. }
  236. onExited:
  237. {
  238. base.hideTooltip();
  239. }
  240. }
  241. }
  242. Label{
  243. id: supportHelperLabel
  244. anchors.left: parent.left
  245. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  246. anchors.verticalCenter: supportCheckBox.verticalCenter
  247. width: parent.width / 100 * 35 - 3 * UM.Theme.getSize("default_margin").width
  248. //: Support label
  249. text: "";
  250. font: UM.Theme.getFont("default");
  251. color: UM.Theme.getColor("text");
  252. }
  253. CheckBox{
  254. id: supportCheckBox
  255. visible: machineExtruderCount.properties.value <= 1
  256. property alias _hovered: supportMouseArea.containsMouse
  257. anchors.top: adhesionCheckBox.bottom
  258. anchors.topMargin: UM.Theme.getSize("default_margin").height
  259. anchors.left: supportHelperLabel.right
  260. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  261. //: Setting enable support checkbox
  262. text: catalog.i18nc("@option:check", "Print Support Structure");
  263. style: UM.Theme.styles.checkbox;
  264. enabled: base.settingsEnabled
  265. checked: supportEnabled.properties.value == "True"
  266. MouseArea {
  267. id: supportMouseArea
  268. anchors.fill: parent
  269. hoverEnabled: true
  270. enabled: base.settingsEnabled
  271. onClicked:
  272. {
  273. supportEnabled.setPropertyValue("value", !parent.checked)
  274. }
  275. onEntered:
  276. {
  277. base.showTooltip(supportCheckBox, Qt.point(-supportCheckBox.x, 0),
  278. catalog.i18nc("@label", "Enable printing support structures. This will build up supporting structures below the model to prevent the model from sagging or printing in mid air."));
  279. }
  280. onExited:
  281. {
  282. base.hideTooltip();
  283. }
  284. }
  285. }
  286. ComboBox {
  287. id: supportExtruderCombobox
  288. visible: machineExtruderCount.properties.value > 1
  289. model: extruderModel
  290. anchors.top: adhesionCheckBox.bottom
  291. anchors.topMargin: UM.Theme.getSize("default_margin").height
  292. anchors.left: supportHelperLabel.right
  293. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  294. width: parent.width / 100 * 45
  295. style: UM.Theme.styles.combobox
  296. enabled: base.settingsEnabled
  297. property alias _hovered: supportExtruderMouseArea.containsMouse
  298. currentIndex: supportEnabled.properties.value == "True" ? parseFloat(supportExtruderNr.properties.value) + 1 : 0
  299. onActivated: {
  300. if(index==0) {
  301. supportEnabled.setPropertyValue("value", false);
  302. } else {
  303. supportEnabled.setPropertyValue("value", true);
  304. // Send the extruder nr as a string.
  305. supportExtruderNr.setPropertyValue("value", String(index - 1));
  306. }
  307. }
  308. MouseArea {
  309. id: supportExtruderMouseArea
  310. anchors.fill: parent
  311. hoverEnabled: true
  312. enabled: base.settingsEnabled
  313. acceptedButtons: Qt.NoButton
  314. onEntered:
  315. {
  316. base.showTooltip(supportExtruderCombobox, Qt.point(-supportExtruderCombobox.x, 0),
  317. 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."));
  318. }
  319. onExited:
  320. {
  321. base.hideTooltip();
  322. }
  323. }
  324. }
  325. ListModel {
  326. id: extruderModel
  327. Component.onCompleted: populateExtruderModel()
  328. }
  329. //: Model used to populate the extrudelModel
  330. Cura.ExtrudersModel
  331. {
  332. id: extruders
  333. onModelChanged: populateExtruderModel()
  334. }
  335. }
  336. function populateExtruderModel()
  337. {
  338. extruderModel.clear();
  339. extruderModel.append({
  340. text: catalog.i18nc("@label", "Don't print support"),
  341. color: ""
  342. })
  343. for(var extruderNumber = 0; extruderNumber < extruders.rowCount() ; extruderNumber++) {
  344. extruderModel.append({
  345. text: catalog.i18nc("@label", "Print support using %1").arg(extruders.getItem(extruderNumber).name),
  346. color: extruders.getItem(extruderNumber).color
  347. })
  348. }
  349. }
  350. Rectangle {
  351. id: tipsCell
  352. anchors.top: helpersCell.bottom
  353. anchors.topMargin: UM.Theme.getSize("default_margin").height
  354. anchors.left: parent.left
  355. width: parent.width
  356. height: childrenRect.height
  357. Label{
  358. anchors.left: parent.left
  359. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  360. anchors.right: parent.right
  361. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  362. wrapMode: Text.WordWrap
  363. //: Tips label
  364. text: catalog.i18nc("@label", "Need help improving your prints? Read the <a href='%1'>Ultimaker Troubleshooting Guides</a>").arg("https://ultimaker.com/en/troubleshooting");
  365. font: UM.Theme.getFont("default");
  366. color: UM.Theme.getColor("text");
  367. linkColor: UM.Theme.getColor("text_link")
  368. onLinkActivated: Qt.openUrlExternally(link)
  369. }
  370. }
  371. UM.SettingPropertyProvider
  372. {
  373. id: infillDensity
  374. containerStackId: Cura.MachineManager.activeStackId
  375. key: "infill_sparse_density"
  376. watchedProperties: [ "value" ]
  377. storeIndex: 0
  378. }
  379. UM.SettingPropertyProvider
  380. {
  381. id: platformAdhesionType
  382. containerStackId: Cura.MachineManager.activeMachineId
  383. key: "adhesion_type"
  384. watchedProperties: [ "value" ]
  385. storeIndex: 0
  386. }
  387. UM.SettingPropertyProvider
  388. {
  389. id: supportEnabled
  390. containerStackId: Cura.MachineManager.activeMachineId
  391. key: "support_enable"
  392. watchedProperties: [ "value" ]
  393. storeIndex: 0
  394. }
  395. UM.SettingPropertyProvider
  396. {
  397. id: machineExtruderCount
  398. containerStackId: Cura.MachineManager.activeMachineId
  399. key: "machine_extruder_count"
  400. watchedProperties: [ "value" ]
  401. storeIndex: 0
  402. }
  403. UM.SettingPropertyProvider
  404. {
  405. id: supportExtruderNr
  406. containerStackId: Cura.MachineManager.activeMachineId
  407. key: "support_extruder_nr"
  408. watchedProperties: [ "value" ]
  409. storeIndex: 0
  410. }
  411. }