SidebarSimple.qml 15 KB

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