PerObjectSettingsPanel.qml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. // Copyright (c) 2015 Ultimaker B.V.
  2. // Uranium is released under the terms of the AGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 1.2
  5. import QtQuick.Controls.Styles 1.2
  6. import QtQuick.Window 2.2
  7. import UM 1.1 as UM
  8. Item {
  9. id: base;
  10. property int currentIndex: UM.ActiveTool.properties.SelectedIndex;
  11. property string printSequence: UM.ActiveTool.properties.PrintSequence;
  12. width: childrenRect.width;
  13. height: childrenRect.height;
  14. Column {
  15. id: items
  16. anchors.top: parent.top;
  17. anchors.left: parent.left;
  18. spacing: UM.Theme.sizes.default_margin.height;
  19. Label {
  20. width: UM.Theme.sizes.setting.width;
  21. wrapMode: Text.Wrap;
  22. text: catalog.i18nc("@label", "Per Object Settings behavior may be unexpected when 'Print sequence' is set to 'All at Once'.")
  23. color: UM.Theme.colors.text;
  24. visible: base.printSequence == "all_at_once"
  25. }
  26. UM.SettingItem {
  27. id: profileSelection
  28. width: UM.Theme.sizes.setting.width;
  29. height: UM.Theme.sizes.setting.height;
  30. name: catalog.i18nc("@label", "Object profile")
  31. type: "enum"
  32. indent: false
  33. style: UM.Theme.styles.setting_item;
  34. options: UM.ProfilesModel { addUseGlobal: true }
  35. value: UM.ActiveTool.properties.Model.getItem(base.currentIndex).profile
  36. onItemValueChanged: {
  37. var item = UM.ActiveTool.properties.Model.getItem(base.currentIndex);
  38. UM.ActiveTool.properties.Model.setObjectProfile(item.id, value)
  39. }
  40. }
  41. Column {
  42. id: customisedSettings
  43. spacing: UM.Theme.sizes.default_lining.height;
  44. width: UM.Theme.sizes.setting.width + UM.Theme.sizes.setting.height/2;
  45. Repeater {
  46. id: settings;
  47. model: UM.ActiveTool.properties.Model.getItem(base.currentIndex).settings
  48. UM.SettingItem {
  49. width: UM.Theme.sizes.setting.width;
  50. height: UM.Theme.sizes.setting.height;
  51. name: model.label;
  52. type: model.type;
  53. value: model.value;
  54. description: model.description;
  55. unit: model.unit;
  56. valid: model.valid;
  57. options: model.options
  58. indent: false
  59. style: UM.Theme.styles.setting_item;
  60. onItemValueChanged: {
  61. settings.model.setSettingValue(model.key, value)
  62. }
  63. Button
  64. {
  65. anchors.left: parent.right;
  66. width: UM.Theme.sizes.setting.height;
  67. height: UM.Theme.sizes.setting.height;
  68. onClicked: UM.ActiveTool.properties.Model.removeSettingOverride(UM.ActiveTool.properties.Model.getItem(base.currentIndex).id, model.key)
  69. style: ButtonStyle
  70. {
  71. background: Rectangle
  72. {
  73. color: control.hovered ? control.parent.style.controlHighlightColor : control.parent.style.controlColor;
  74. UM.RecolorImage
  75. {
  76. anchors.verticalCenter: parent.verticalCenter
  77. anchors.horizontalCenter: parent.horizontalCenter
  78. width: parent.width/2
  79. height: parent.height/2
  80. sourceSize.width: width
  81. sourceSize.height: width
  82. color: UM.Theme.colors.setting_control_revert
  83. source: UM.Theme.icons.cross1
  84. }
  85. }
  86. }
  87. }
  88. }
  89. }
  90. }
  91. Button
  92. {
  93. id: customise_settings_button;
  94. anchors.right: profileSelection.right;
  95. height: UM.Theme.sizes.setting.height;
  96. visible: parseInt(UM.Preferences.getValue("cura/active_mode")) == 1
  97. text: catalog.i18nc("@action:button", "Add Setting");
  98. style: ButtonStyle
  99. {
  100. background: Rectangle
  101. {
  102. width: control.width;
  103. height: control.height;
  104. border.width: UM.Theme.sizes.default_lining.width;
  105. border.color: control.pressed ? UM.Theme.colors.action_button_active_border :
  106. control.hovered ? UM.Theme.colors.action_button_hovered_border : UM.Theme.colors.action_button_border
  107. color: control.pressed ? UM.Theme.colors.action_button_active :
  108. control.hovered ? UM.Theme.colors.action_button_hovered : UM.Theme.colors.action_button
  109. }
  110. label: Label
  111. {
  112. text: control.text;
  113. color: UM.Theme.colors.setting_control_text;
  114. anchors.centerIn: parent
  115. }
  116. }
  117. onClicked: settingPickDialog.visible = true;
  118. Connections
  119. {
  120. target: UM.Preferences;
  121. onPreferenceChanged:
  122. {
  123. customise_settings_button.visible = parseInt(UM.Preferences.getValue("cura/active_mode"))
  124. }
  125. }
  126. }
  127. }
  128. UM.I18nCatalog { id: catalog; name: "uranium"; }
  129. UM.Dialog {
  130. id: settingPickDialog
  131. title: catalog.i18nc("@title:window", "Pick a Setting to Customize")
  132. TextField {
  133. id: filter;
  134. anchors {
  135. top: parent.top;
  136. left: parent.left;
  137. right: parent.right;
  138. }
  139. placeholderText: catalog.i18nc("@label:textbox", "Filter...");
  140. onTextChanged: settingCategoriesModel.filter(text);
  141. }
  142. ScrollView {
  143. id: view;
  144. anchors {
  145. top: filter.bottom;
  146. left: parent.left;
  147. right: parent.right;
  148. bottom: parent.bottom;
  149. }
  150. Column {
  151. width: view.width - UM.Theme.sizes.default_margin.width * 2;
  152. height: childrenRect.height;
  153. Repeater {
  154. id: settingList;
  155. model: UM.SettingCategoriesModel { id: settingCategoriesModel; }
  156. delegate: Item {
  157. id: delegateItem;
  158. width: parent.width;
  159. height: childrenRect.height;
  160. ToolButton {
  161. id: categoryHeader;
  162. text: model.name;
  163. checkable: true;
  164. width: parent.width;
  165. onCheckedChanged: settingsColumn.state != "" ? settingsColumn.state = "" : settingsColumn.state = "collapsed";
  166. style: ButtonStyle {
  167. background: Rectangle
  168. {
  169. width: control.width;
  170. height: control.height;
  171. color: control.hovered ? palette.highlight : "transparent";
  172. }
  173. label: Row
  174. {
  175. spacing: UM.Theme.sizes.default_margin.width;
  176. Image
  177. {
  178. anchors.verticalCenter: parent.verticalCenter;
  179. source: control.checked ? UM.Theme.icons.arrow_right : UM.Theme.icons.arrow_bottom;
  180. }
  181. Label
  182. {
  183. text: control.text;
  184. font.bold: true;
  185. color: control.hovered ? palette.highlightedText : palette.text;
  186. }
  187. }
  188. }
  189. }
  190. property variant settingsModel: model.settings;
  191. visible: model.visible;
  192. Column {
  193. id: settingsColumn;
  194. anchors.top: categoryHeader.bottom;
  195. property real childrenHeight:
  196. {
  197. var h = 0.0;
  198. for(var i in children)
  199. {
  200. var item = children[i];
  201. h += children[i].height;
  202. if(item.settingVisible)
  203. {
  204. if(i > 0)
  205. {
  206. h += spacing;
  207. }
  208. }
  209. }
  210. return h;
  211. }
  212. width: childrenRect.width;
  213. height: childrenHeight;
  214. Repeater {
  215. model: delegateItem.settingsModel;
  216. delegate: ToolButton {
  217. id: button;
  218. x: model.depth * UM.Theme.sizes.default_margin.width;
  219. text: model.name;
  220. tooltip: model.description;
  221. onClicked: {
  222. var object_id = UM.ActiveTool.properties.Model.getItem(base.currentIndex).id;
  223. UM.ActiveTool.properties.Model.addSettingOverride(object_id, model.key);
  224. settingPickDialog.visible = false;
  225. }
  226. states: State {
  227. name: "filtered"
  228. when: model.filtered || !model.visible || !model.enabled
  229. PropertyChanges { target: button; height: 0; opacity: 0; }
  230. }
  231. }
  232. }
  233. states: State {
  234. name: "collapsed";
  235. PropertyChanges { target: settingsColumn; opacity: 0; height: 0; }
  236. }
  237. }
  238. }
  239. }
  240. }
  241. }
  242. rightButtons: [
  243. Button {
  244. text: catalog.i18nc("@action:button", "Cancel");
  245. onClicked: {
  246. settingPickDialog.visible = false;
  247. }
  248. }
  249. ]
  250. }
  251. SystemPalette { id: palette; }
  252. }