SidebarSimple.qml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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.1 as UM
  8. Item
  9. {
  10. id: base;
  11. anchors.fill: parent;
  12. property Action configureSettings;
  13. property variant minimumPrintTime: PrintInformation.minimumPrintTime;
  14. property variant maximumPrintTime: PrintInformation.maximumPrintTime;
  15. Component.onCompleted: PrintInformation.enabled = true
  16. Component.onDestruction: PrintInformation.enabled = false
  17. UM.I18nCatalog { id: catalog; name:"cura"}
  18. Rectangle{
  19. id: infillCellLeft
  20. anchors.top: parent.top
  21. anchors.left: parent.left
  22. width: base.width/100* 45 - UM.Theme.sizes.default_margin.width
  23. height: childrenRect.height < UM.Theme.sizes.simple_mode_infill_caption.height ? UM.Theme.sizes.simple_mode_infill_caption.height : childrenRect.height
  24. Label{
  25. id: infillLabel
  26. //: Infill selection label
  27. text: catalog.i18nc("@label","Infill:");
  28. font: UM.Theme.fonts.default;
  29. color: UM.Theme.colors.text_default;
  30. anchors.top: parent.top
  31. anchors.topMargin: UM.Theme.sizes.default_margin.height
  32. anchors.left: parent.left
  33. anchors.leftMargin: UM.Theme.sizes.default_margin.width
  34. }
  35. Label{
  36. id: infillCaption
  37. width: infillCellLeft.width - UM.Theme.sizes.default_margin.width
  38. text: infillModel.count > 0 && infillListView.activeIndex != -1 ? infillModel.get(infillListView.activeIndex).text : ""
  39. font: UM.Theme.fonts.caption
  40. wrapMode: Text.Wrap
  41. color: UM.Theme.colors.text_subtext
  42. anchors.top: infillLabel.bottom
  43. anchors.left: parent.left
  44. anchors.leftMargin: UM.Theme.sizes.default_margin.width
  45. }
  46. }
  47. Flow {
  48. id: infillCellRight
  49. height: childrenRect.height;
  50. width: base.width / 100 * 55
  51. spacing: 12
  52. anchors.right: parent.right
  53. anchors.rightMargin: UM.Theme.sizes.default_margin.width - (UM.Theme.sizes.default_margin.width/4)
  54. anchors.top: parent.top
  55. anchors.topMargin: UM.Theme.sizes.default_margin.height
  56. Repeater {
  57. id: infillListView
  58. property int activeIndex: {
  59. if(!UM.ActiveProfile.valid)
  60. {
  61. return -1;
  62. }
  63. var density = parseInt(UM.ActiveProfile.settingValues.infill_sparse_density);
  64. for(var i = 0; i < infillModel.count; ++i)
  65. {
  66. if(infillModel.get(i).percentage == density)
  67. {
  68. return i;
  69. }
  70. }
  71. return -1;
  72. }
  73. model: infillModel;
  74. Item {
  75. width: childrenRect.width;
  76. height: childrenRect.height;
  77. Rectangle{
  78. id: infillIconLining
  79. width: infillCellRight.width / 3 - UM.Theme.sizes.default_margin.width;
  80. height: width
  81. border.color: infillListView.activeIndex == index ? UM.Theme.colors.setting_control_text : UM.Theme.colors.setting_control_border
  82. border.width: infillListView.activeIndex == index ? 2 : 1
  83. color: infillListView.activeIndex == index ? UM.Theme.colors.setting_category_active : "transparent"
  84. Image {
  85. id: infillIcon
  86. anchors.fill: parent;
  87. anchors.margins: UM.Theme.sizes.default_margin.width / 2
  88. sourceSize.width: width
  89. sourceSize.height: width
  90. source: UM.Theme.icons[model.icon];
  91. }
  92. MouseArea {
  93. anchors.fill: parent
  94. onClicked: {
  95. infillListView.activeIndex = index
  96. UM.MachineManager.setSettingValue("infill_sparse_density", model.percentage)
  97. }
  98. }
  99. }
  100. Label{
  101. id: infillLabel
  102. anchors.top: infillIconLining.bottom
  103. anchors.horizontalCenter: infillIconLining.horizontalCenter
  104. color: infillListView.activeIndex == index ? UM.Theme.colors.setting_control_text : UM.Theme.colors.setting_control_border
  105. text: name
  106. }
  107. }
  108. }
  109. ListModel {
  110. id: infillModel
  111. Component.onCompleted:
  112. {
  113. infillModel.append({
  114. name: catalog.i18nc("@label", "Sparse"),
  115. percentage: 20,
  116. text: catalog.i18nc("@label", "Sparse (20%) infill will give your model an average strength"),
  117. icon: "sparse"
  118. })
  119. infillModel.append({
  120. name: catalog.i18nc("@label", "Dense"),
  121. percentage: 50,
  122. text: catalog.i18nc("@label", "Dense (50%) infill will give your model an above average strength"),
  123. icon: "dense"
  124. })
  125. infillModel.append({
  126. name: catalog.i18nc("@label", "Solid"),
  127. percentage: 100,
  128. text: catalog.i18nc("@label", "Solid (100%) infill will make your model completely solid"),
  129. icon: "solid"
  130. })
  131. }
  132. }
  133. }
  134. Rectangle {
  135. id: helpersCellLeft
  136. anchors.top: infillCellRight.bottom
  137. anchors.topMargin: UM.Theme.sizes.default_margin.height
  138. anchors.left: parent.left
  139. width: parent.width/100*45 - UM.Theme.sizes.default_margin.width
  140. height: childrenRect.height
  141. Label{
  142. anchors.left: parent.left
  143. anchors.leftMargin: UM.Theme.sizes.default_margin.width
  144. //: Helpers selection label
  145. text: catalog.i18nc("@label:listbox","Helpers:");
  146. font: UM.Theme.fonts.default;
  147. color: UM.Theme.colors.text_default;
  148. }
  149. }
  150. Rectangle {
  151. id: helpersCellRight
  152. anchors.top: helpersCellLeft.top
  153. anchors.left: helpersCellLeft.right
  154. width: parent.width/100*55 - UM.Theme.sizes.default_margin.width
  155. height: childrenRect.height
  156. CheckBox{
  157. id: skirtCheckBox
  158. anchors.top: parent.top
  159. anchors.left: parent.left
  160. //: Setting enable skirt adhesion checkbox
  161. text: catalog.i18nc("@option:check","Enable Skirt Adhesion");
  162. style: UM.Theme.styles.checkbox;
  163. checked: UM.ActiveProfile.valid ? UM.ActiveProfile.settingValues.adhesion_type == "brim" : false;
  164. onClicked:
  165. {
  166. UM.MachineManager.setSettingValue("adhesion_type", "brim")
  167. }
  168. }
  169. CheckBox{
  170. anchors.top: skirtCheckBox.bottom
  171. anchors.topMargin: UM.Theme.sizes.default_lining.height
  172. anchors.left: parent.left
  173. //: Setting enable support checkbox
  174. text: catalog.i18nc("@option:check","Enable Support");
  175. style: UM.Theme.styles.checkbox;
  176. checked: UM.ActiveProfile.valid ? UM.ActiveProfile.settingValues.support_enable : false;
  177. onClicked:
  178. {
  179. UM.MachineManager.setSettingValue("support_enable", checked)
  180. }
  181. }
  182. }
  183. /*
  184. Item
  185. {
  186. Layout.fillWidth: true;
  187. Layout.preferredHeight: UM.Theme.sizes.section.height;
  188. Label
  189. {
  190. anchors.left: parent.left;
  191. anchors.verticalCenter: parent.verticalCenter;
  192. text: base.minimumPrintTime.valid ? base.minimumPrintTime.getDisplayString(UM.DurationFormat.Short) : "??:??";
  193. font: UM.Theme.fonts.timeslider_time;
  194. color: UM.Theme.colors.primary;
  195. }
  196. Label
  197. {
  198. anchors.centerIn: parent;
  199. text: //: Sidebar configuration label
  200. {
  201. if (UM.Backend.progress < 0)
  202. {
  203. return catalog.i18nc("@label","No Model Loaded");
  204. }
  205. else if (!base.minimumPrintTime.valid || !base.maximumPrintTime.valid)
  206. {
  207. return catalog.i18nc("@label","Calculating...")
  208. }
  209. else
  210. {
  211. return catalog.i18nc("@label","Estimated Print Time");
  212. }
  213. }
  214. color: UM.Theme.colors.text;
  215. font: UM.Theme.fonts.default;
  216. }
  217. Label
  218. {
  219. anchors.right: parent.right;
  220. anchors.verticalCenter: parent.verticalCenter;
  221. text: base.maximumPrintTime.valid ? base.maximumPrintTime.getDisplayString(UM.DurationFormat.Short) : "??:??";
  222. font: UM.Theme.fonts.timeslider_time;
  223. color: UM.Theme.colors.primary;
  224. }
  225. }
  226. Slider
  227. {
  228. Layout.fillWidth: true;
  229. Layout.preferredHeight: UM.Theme.sizes.section.height;
  230. minimumValue: 0;
  231. maximumValue: 100;
  232. value: PrintInformation.timeQualityValue;
  233. onValueChanged: PrintInformation.setTimeQualityValue(value);
  234. style: UM.Theme.styles.slider;
  235. }
  236. Item
  237. {
  238. Layout.fillWidth: true;
  239. Layout.preferredHeight: UM.Theme.sizes.section.height;
  240. Label
  241. {
  242. anchors.left: parent.left;
  243. anchors.verticalCenter: parent.verticalCenter;
  244. //: Quality slider label
  245. text: catalog.i18nc("@label","Minimum\nDraft");
  246. color: UM.Theme.colors.text;
  247. font: UM.Theme.fonts.default;
  248. }
  249. Label
  250. {
  251. anchors.right: parent.right;
  252. anchors.verticalCenter: parent.verticalCenter;
  253. //: Quality slider label
  254. text: catalog.i18nc("@label","Maximum\nQuality");
  255. horizontalAlignment: Text.AlignRight;
  256. color: UM.Theme.colors.text;
  257. font: UM.Theme.fonts.default;
  258. }
  259. }
  260. CheckBox
  261. {
  262. Layout.fillWidth: true;
  263. Layout.preferredHeight: UM.Theme.sizes.section.height;
  264. //: Setting checkbox
  265. text: catalog.i18nc("@action:checkbox","Enable Support");
  266. style: UM.Theme.styles.checkbox;
  267. checked: Printer.getSettingValue("support_enable");
  268. onCheckedChanged: Printer.setSettingValue("support_enable", checked);
  269. }
  270. Item { Layout.fillWidth: true; Layout.fillHeight: true; }
  271. }*/
  272. }