styles.qml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. // Copyright (c) 2015 Ultimaker B.V.
  2. // Cura is released under the terms of the AGPLv3 or higher.
  3. import QtQuick 2.1
  4. import QtQuick.Controls 1.1
  5. import QtQuick.Controls.Styles 1.1
  6. import UM 1.1 as UM
  7. QtObject {
  8. property Component sidebar_header_button: Component {
  9. ButtonStyle {
  10. background: Rectangle {
  11. color: Theme.getColor("setting_control")
  12. border.width: Theme.getSize("default_lining").width
  13. border.color: control.hovered ? Theme.getColor("setting_control_border_highlight") : Theme.getColor("setting_control_border")
  14. UM.RecolorImage {
  15. id: downArrow
  16. anchors.verticalCenter: parent.verticalCenter
  17. anchors.right: parent.right
  18. anchors.rightMargin: Theme.getSize("default_margin").width
  19. width: Theme.getSize("standard_arrow").width
  20. height: Theme.getSize("standard_arrow").height
  21. sourceSize.width: width
  22. sourceSize.height: width
  23. color: Theme.getColor("setting_category_text")
  24. source: Theme.getIcon("arrow_bottom")
  25. }
  26. Label {
  27. id: sidebarComboBoxLabel
  28. color: Theme.getColor("setting_control_text")
  29. text: control.text;
  30. elide: Text.ElideRight;
  31. anchors.left: parent.left;
  32. anchors.leftMargin: Theme.getSize("setting_unit_margin").width
  33. anchors.right: downArrow.left;
  34. anchors.verticalCenter: parent.verticalCenter;
  35. font: Theme.getFont("default")
  36. }
  37. }
  38. label: Label{}
  39. }
  40. }
  41. property Component tool_button: Component {
  42. ButtonStyle {
  43. background: Item {
  44. implicitWidth: Theme.getSize("button").width;
  45. implicitHeight: Theme.getSize("button").height;
  46. UM.PointingRectangle {
  47. id: button_tooltip
  48. anchors.left: parent.right
  49. anchors.leftMargin: Theme.getSize("button_tooltip_arrow").width * 2
  50. anchors.verticalCenter: parent.verticalCenter
  51. target: Qt.point(parent.x, y + height/2)
  52. arrowSize: Theme.getSize("button_tooltip_arrow").width
  53. color: Theme.getColor("tooltip")
  54. opacity: control.hovered ? 1.0 : 0.0;
  55. width: control.hovered ? button_tip.width + Theme.getSize("button_tooltip").width : 0
  56. height: Theme.getSize("button_tooltip").height
  57. Behavior on width { NumberAnimation { duration: 100; } }
  58. Behavior on opacity { NumberAnimation { duration: 100; } }
  59. Label {
  60. id: button_tip
  61. anchors.horizontalCenter: parent.horizontalCenter
  62. anchors.verticalCenter: parent.verticalCenter;
  63. text: control.text;
  64. font: Theme.getFont("button_tooltip");
  65. color: Theme.getColor("tooltip_text");
  66. }
  67. }
  68. Rectangle {
  69. id: buttonFace;
  70. anchors.fill: parent;
  71. property bool down: control.pressed || (control.checkable && control.checked);
  72. color: {
  73. if(control.checkable && control.checked && control.hovered) {
  74. return Theme.getColor("button_active_hover");
  75. } else if(control.pressed || (control.checkable && control.checked)) {
  76. return Theme.getColor("button_active");
  77. } else if(control.hovered) {
  78. return Theme.getColor("button_hover");
  79. } else {
  80. return Theme.getColor("button");
  81. }
  82. }
  83. Behavior on color { ColorAnimation { duration: 50; } }
  84. UM.RecolorImage {
  85. id: tool_button_arrow
  86. opacity: !control.enabled ? 0.2 : 1.0
  87. anchors.right: parent.right;
  88. anchors.rightMargin: (Theme.getSize("button").width - Theme.getSize("button_icon").width) / 4
  89. anchors.bottom: parent.bottom;
  90. anchors.bottomMargin: (Theme.getSize("button").height - Theme.getSize("button_icon").height) / 4
  91. width: Theme.getSize("standard_arrow").width
  92. height: Theme.getSize("standard_arrow").height
  93. sourceSize.width: width
  94. sourceSize.height: width
  95. visible: control.menu != null;
  96. color: Theme.getColor("button_text")
  97. source: Theme.getIcon("arrow_bottom")
  98. }
  99. }
  100. }
  101. label: Item {
  102. Image {
  103. anchors.centerIn: parent;
  104. opacity: !control.enabled ? 0.2 : 1.0
  105. source: control.iconSource;
  106. width: Theme.getSize("button_icon").width;
  107. height: Theme.getSize("button_icon").height;
  108. sourceSize: Theme.getSize("button_icon")
  109. }
  110. }
  111. }
  112. }
  113. property Component progressbar: Component{
  114. ProgressBarStyle {
  115. background:Rectangle {
  116. implicitWidth: Theme.getSize("message").width - (Theme.getSize("default_margin").width * 2)
  117. implicitHeight: Theme.getSize("progressbar").height
  118. radius: Theme.getSize("progressbar_radius").width
  119. color: Theme.getColor("progressbar_background")
  120. }
  121. progress: Rectangle {
  122. color: control.indeterminate ? "transparent" : Theme.getColor("progressbar_control")
  123. radius: Theme.getSize("progressbar_radius").width
  124. Rectangle{
  125. radius: Theme.getSize("progressbar_radius").width
  126. color: Theme.getColor("progressbar_control")
  127. width: Theme.getSize("progressbar_control").width
  128. height: Theme.getSize("progressbar_control").height
  129. visible: control.indeterminate
  130. SequentialAnimation on x {
  131. id: xAnim
  132. property int animEndPoint: Theme.getSize("message").width - (Theme.getSize("default_margin").width * 2) - Theme.getSize("progressbar_control").width
  133. running: control.indeterminate
  134. loops: Animation.Infinite
  135. NumberAnimation { from: 0; to: xAnim.animEndPoint; duration: 2000;}
  136. NumberAnimation { from: xAnim.animEndPoint; to: 0; duration: 2000;}
  137. }
  138. }
  139. }
  140. }
  141. }
  142. property Component sidebar_category: Component {
  143. ButtonStyle {
  144. background: Rectangle {
  145. anchors.fill: parent;
  146. anchors.left: parent.left
  147. anchors.leftMargin: Theme.getSize("default_margin").width
  148. anchors.right: parent.right
  149. anchors.rightMargin: Theme.getSize("default_margin").width
  150. implicitHeight: Theme.getSize("section").height;
  151. color: {
  152. if(control.color) {
  153. return control.color;
  154. } else if(!control.enabled) {
  155. return Theme.getColor("setting_category_disabled");
  156. } else if(control.hovered && control.checkable && control.checked) {
  157. return Theme.getColor("setting_category_active_hover");
  158. } else if(control.pressed || (control.checkable && control.checked)) {
  159. return Theme.getColor("setting_category_active");
  160. } else if(control.hovered) {
  161. return Theme.getColor("setting_category_hover");
  162. } else {
  163. return Theme.getColor("setting_category");
  164. }
  165. }
  166. Behavior on color { ColorAnimation { duration: 50; } }
  167. Rectangle {
  168. height: Theme.getSize("default_lining").height
  169. width: parent.width
  170. anchors.bottom: parent.bottom
  171. color: {
  172. if(!control.enabled) {
  173. return Theme.getColor("setting_category_disabled_border");
  174. } else if(control.hovered && control.checkable && control.checked) {
  175. return Theme.getColor("setting_category_active_hover_border");
  176. } else if(control.pressed || (control.checkable && control.checked)) {
  177. return Theme.getColor("setting_category_active_border");
  178. } else if(control.hovered) {
  179. return Theme.getColor("setting_category_hover_border");
  180. } else {
  181. return Theme.getColor("setting_category_border");
  182. }
  183. }
  184. }
  185. }
  186. label: Item {
  187. anchors.fill: parent;
  188. anchors.left: parent.left
  189. Item{
  190. id: icon;
  191. anchors.left: parent.left
  192. height: parent.height
  193. width: Theme.getSize("section_icon_column").width
  194. UM.RecolorImage {
  195. anchors.verticalCenter: parent.verticalCenter
  196. anchors.left: parent.left
  197. anchors.leftMargin: Theme.getSize("default_margin").width
  198. color: Theme.getColor("setting_category_text")
  199. source: control.iconSource;
  200. width: Theme.getSize("section_icon").width;
  201. height: Theme.getSize("section_icon").height;
  202. sourceSize.width: width + 15
  203. sourceSize.height: width + 15
  204. }
  205. }
  206. Label {
  207. anchors {
  208. left: icon.right;
  209. leftMargin: Theme.getSize("default_lining").width;
  210. right: parent.right;
  211. verticalCenter: parent.verticalCenter;
  212. }
  213. text: control.text;
  214. font: Theme.getFont("setting_category");
  215. color: Theme.getColor("setting_category_text");
  216. fontSizeMode: Text.HorizontalFit;
  217. minimumPointSize: 8
  218. }
  219. UM.RecolorImage {
  220. id: category_arrow
  221. anchors.verticalCenter: parent.verticalCenter
  222. anchors.right: parent.right
  223. anchors.rightMargin: Theme.getSize("default_margin").width * 2 - width / 2
  224. width: Theme.getSize("standard_arrow").width
  225. height: Theme.getSize("standard_arrow").height
  226. sourceSize.width: width
  227. sourceSize.height: width
  228. color: Theme.getColor("setting_category_text")
  229. source: control.checked ? Theme.getIcon("arrow_bottom") : Theme.getIcon("arrow_left")
  230. }
  231. }
  232. }
  233. }
  234. property Component scrollview: Component {
  235. ScrollViewStyle {
  236. decrementControl: Item { }
  237. incrementControl: Item { }
  238. transientScrollBars: false
  239. scrollBarBackground: Rectangle {
  240. implicitWidth: Theme.getSize("scrollbar").width
  241. radius: implicitWidth / 2
  242. color: Theme.getColor("scrollbar_background");
  243. }
  244. handle: Rectangle {
  245. id: scrollViewHandle
  246. implicitWidth: Theme.getSize("scrollbar").width;
  247. radius: implicitWidth / 2
  248. color: styleData.pressed ? Theme.getColor("scrollbar_handle_down") : styleData.hovered ? Theme.getColor("scrollbar_handle_hover") : Theme.getColor("scrollbar_handle");
  249. Behavior on color { ColorAnimation { duration: 50; } }
  250. }
  251. }
  252. }
  253. property variant setting_item: UM.SettingItemStyle {
  254. labelFont: Theme.getFont("default");
  255. labelColor: Theme.getColor("setting_control_text");
  256. spacing: Theme.getSize("default_lining").height;
  257. fixedHeight: Theme.getSize("setting").height;
  258. controlWidth: Theme.getSize("setting_control").width;
  259. controlRightMargin: Theme.getSize("setting_control_margin").width;
  260. controlColor: Theme.getColor("setting_control");
  261. controlHighlightColor: Theme.getColor("setting_control_highlight");
  262. controlBorderColor: Theme.getColor("setting_control_border");
  263. controlBorderHighlightColor: Theme.getColor("setting_control_border_highlight");
  264. controlTextColor: Theme.getColor("setting_control_text");
  265. controlBorderWidth: Theme.getSize("default_lining").width;
  266. controlFont: Theme.getFont("default");
  267. validationErrorColor: Theme.getColor("setting_validation_error");
  268. validationWarningColor: Theme.getColor("setting_validation_warning");
  269. validationOkColor: Theme.getColor("setting_validation_ok");
  270. unitRightMargin: Theme.getSize("setting_unit_margin").width;
  271. unitColor: Theme.getColor("setting_unit");
  272. unitFont: Theme.getFont("default");
  273. }
  274. property Component checkbox: Component {
  275. CheckBoxStyle {
  276. background: Item { }
  277. indicator: Rectangle {
  278. implicitWidth: Theme.getSize("checkbox").width;
  279. implicitHeight: Theme.getSize("checkbox").height;
  280. color: (control.hovered || control.hovered_ex) ? Theme.getColor("checkbox_hover") : Theme.getColor("checkbox");
  281. Behavior on color { ColorAnimation { duration: 50; } }
  282. radius: control.exclusiveGroup ? Theme.getSize("checkbox").width / 2 : 0
  283. border.width: Theme.getSize("default_lining").width;
  284. border.color: (control.hovered || control.hovered_ex) ? Theme.getColor("checkbox_border_hover") : Theme.getColor("checkbox_border");
  285. UM.RecolorImage {
  286. anchors.verticalCenter: parent.verticalCenter
  287. anchors.horizontalCenter: parent.horizontalCenter
  288. width: parent.width/2.5
  289. height: parent.height/2.5
  290. sourceSize.width: width
  291. sourceSize.height: width
  292. color: Theme.getColor("checkbox_mark")
  293. source: control.exclusiveGroup ? Theme.getIcon("dot") : Theme.getIcon("check")
  294. opacity: control.checked
  295. Behavior on opacity { NumberAnimation { duration: 100; } }
  296. }
  297. }
  298. label: Label {
  299. text: control.text;
  300. color: Theme.getColor("checkbox_text");
  301. font: Theme.getFont("default");
  302. }
  303. }
  304. }
  305. property Component slider: Component {
  306. SliderStyle {
  307. groove: Rectangle {
  308. implicitWidth: control.width;
  309. implicitHeight: Theme.getSize("slider_groove").height;
  310. color: Theme.getColor("slider_groove");
  311. border.width: Theme.getSize("default_lining").width;
  312. border.color: Theme.getColor("slider_groove_border");
  313. radius: width / 2;
  314. Rectangle {
  315. anchors {
  316. left: parent.left;
  317. top: parent.top;
  318. bottom: parent.bottom;
  319. }
  320. color: Theme.getColor("slider_groove_fill");
  321. width: (control.value / (control.maximumValue - control.minimumValue)) * parent.width;
  322. radius: width / 2;
  323. }
  324. }
  325. handle: Rectangle {
  326. width: Theme.getSize("slider_handle").width;
  327. height: Theme.getSize("slider_handle").height;
  328. color: control.hovered ? Theme.getColor("slider_handle_hover") : Theme.getColor("slider_handle");
  329. radius: Theme.getSize("slider_handle").width/2;
  330. Behavior on color { ColorAnimation { duration: 50; } }
  331. }
  332. }
  333. }
  334. property Component text_field: Component {
  335. TextFieldStyle {
  336. textColor: Theme.getColor("setting_control_text");
  337. font: Theme.getFont("default");
  338. background: Rectangle
  339. {
  340. implicitHeight: control.height;
  341. implicitWidth: control.width;
  342. border.width: Theme.getSize("default_lining").width;
  343. border.color: control.hovered ? Theme.getColor("setting_control_border_highlight") : Theme.getColor("setting_control_border");
  344. color: Theme.getColor("setting_validation_ok");
  345. Label {
  346. anchors.right: parent.right;
  347. anchors.rightMargin: Theme.getSize("setting_unit_margin").width;
  348. anchors.verticalCenter: parent.verticalCenter;
  349. text: control.unit ? control.unit : ""
  350. color: Theme.getColor("setting_unit");
  351. font: Theme.getFont("default");
  352. }
  353. }
  354. }
  355. }
  356. }