styles.qml 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091
  1. // Copyright (c) 2017 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 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:
  12. {
  13. if(control.enabled)
  14. {
  15. if(control.valueError)
  16. {
  17. return Theme.getColor("setting_validation_error_background");
  18. }
  19. else if(control.valueWarning)
  20. {
  21. return Theme.getColor("setting_validation_warning_background");
  22. }
  23. else
  24. {
  25. return Theme.getColor("setting_control");
  26. }
  27. }
  28. else
  29. {
  30. return Theme.getColor("setting_control_disabled");
  31. }
  32. }
  33. border.width: Theme.getSize("default_lining").width
  34. border.color:
  35. {
  36. if (control.enabled)
  37. {
  38. if (control.valueError)
  39. {
  40. return Theme.getColor("setting_validation_error");
  41. }
  42. else if (control.valueWarning)
  43. {
  44. return Theme.getColor("setting_validation_warning");
  45. }
  46. else if (control.hovered)
  47. {
  48. return Theme.getColor("setting_control_border_highlight");
  49. }
  50. else
  51. {
  52. return Theme.getColor("setting_control_border");
  53. }
  54. }
  55. else
  56. {
  57. return Theme.getColor("setting_control_disabled_border");
  58. }
  59. }
  60. UM.RecolorImage {
  61. id: downArrow
  62. anchors.verticalCenter: parent.verticalCenter
  63. anchors.right: parent.right
  64. anchors.rightMargin: Theme.getSize("default_margin").width
  65. width: Theme.getSize("standard_arrow").width
  66. height: Theme.getSize("standard_arrow").height
  67. sourceSize.width: width
  68. sourceSize.height: width
  69. color: control.enabled ? Theme.getColor("setting_category_text") : Theme.getColor("setting_category_disabled_text")
  70. source: Theme.getIcon("arrow_bottom")
  71. }
  72. Label {
  73. id: sidebarComboBoxLabel
  74. color: control.enabled ? Theme.getColor("setting_control_text") : Theme.getColor("setting_control_disabled_text")
  75. text: control.text;
  76. elide: Text.ElideRight;
  77. anchors.left: parent.left;
  78. anchors.leftMargin: Theme.getSize("setting_unit_margin").width
  79. anchors.right: downArrow.left;
  80. anchors.rightMargin: control.rightMargin;
  81. anchors.verticalCenter: parent.verticalCenter;
  82. font: Theme.getFont("default")
  83. }
  84. }
  85. label: Label{}
  86. }
  87. }
  88. property Component topbar_header_tab_no_overlay: Component {
  89. ButtonStyle {
  90. background: Rectangle {
  91. implicitHeight: Theme.getSize("topbar_button").height
  92. implicitWidth: Theme.getSize("topbar_button").width
  93. color: "transparent"
  94. anchors.fill: parent
  95. Rectangle
  96. {
  97. id: underline
  98. anchors.left: parent.left
  99. anchors.right: parent.right
  100. anchors.bottom: parent.bottom
  101. width: parent.width
  102. height: Theme.getSize("sidebar_header_highlight").height
  103. color: control.checked ? UM.Theme.getColor("sidebar_header_highlight") : UM.Theme.getColor("sidebar_header_highlight_hover")
  104. visible: control.hovered || control.checked
  105. }
  106. }
  107. label: Rectangle {
  108. implicitHeight: Theme.getSize("topbar_button_icon").height
  109. implicitWidth: Theme.getSize("topbar_button").width
  110. color: "transparent"
  111. anchors.fill: parent
  112. Item
  113. {
  114. anchors.centerIn: parent
  115. width: Math.round(textLabel.width + icon.width + Theme.getSize("default_margin").width / 2)
  116. Label
  117. {
  118. id: textLabel
  119. text: control.text
  120. anchors.right: icon.visible ? icon.left : parent.right
  121. anchors.rightMargin: icon.visible ? Math.round(Theme.getSize("default_margin").width / 2) : 0
  122. anchors.verticalCenter: parent.verticalCenter;
  123. font: control.checked ? UM.Theme.getFont("large") : UM.Theme.getFont("large_nonbold")
  124. color:
  125. {
  126. if(control.hovered)
  127. {
  128. return UM.Theme.getColor("topbar_button_text_hovered");
  129. }
  130. if(control.checked)
  131. {
  132. return UM.Theme.getColor("topbar_button_text_active");
  133. }
  134. else
  135. {
  136. return UM.Theme.getColor("topbar_button_text_inactive");
  137. }
  138. }
  139. }
  140. Image
  141. {
  142. id: icon
  143. visible: control.iconSource != ""
  144. anchors.right: parent.right
  145. anchors.verticalCenter: parent.verticalCenter
  146. opacity: !control.enabled ? 0.2 : 1.0
  147. source: control.iconSource
  148. width: visible ? Theme.getSize("topbar_button_icon").width : 0
  149. height: Theme.getSize("topbar_button_icon").height
  150. sourceSize: Theme.getSize("topbar_button_icon")
  151. }
  152. }
  153. }
  154. }
  155. }
  156. property Component topbar_header_tab: Component {
  157. ButtonStyle {
  158. background: Item {
  159. implicitHeight: Theme.getSize("topbar_button").height
  160. implicitWidth: Theme.getSize("topbar_button").width + Theme.getSize("topbar_button_icon").width
  161. Rectangle {
  162. id: buttonFace;
  163. anchors.fill: parent;
  164. color: "transparent"
  165. Behavior on color { ColorAnimation { duration: 50; } }
  166. Rectangle {
  167. id: underline;
  168. anchors.horizontalCenter: parent.horizontalCenter
  169. anchors.bottom: parent.bottom
  170. width: Theme.getSize("topbar_button").width + Theme.getSize("topbar_button_icon").width
  171. height: Theme.getSize("sidebar_header_highlight").height
  172. color: control.checked ? UM.Theme.getColor("sidebar_header_highlight") : UM.Theme.getColor("sidebar_header_highlight_hover")
  173. visible: control.hovered || control.checked
  174. }
  175. }
  176. }
  177. label: Item
  178. {
  179. implicitHeight: Theme.getSize("topbar_button_icon").height
  180. implicitWidth: Theme.getSize("topbar_button").width + Theme.getSize("topbar_button_icon").width
  181. Item
  182. {
  183. anchors.horizontalCenter: parent.horizontalCenter
  184. anchors.verticalCenter: parent.verticalCenter;
  185. width: childrenRect.width
  186. height: Theme.getSize("topbar_button_icon").height
  187. Label
  188. {
  189. id: button_label
  190. text: control.text;
  191. anchors.verticalCenter: parent.verticalCenter;
  192. font: control.checked ? UM.Theme.getFont("large") : UM.Theme.getFont("large_nonbold")
  193. color:
  194. {
  195. if(control.hovered)
  196. {
  197. return UM.Theme.getColor("topbar_button_text_hovered");
  198. }
  199. if(control.checked)
  200. {
  201. return UM.Theme.getColor("topbar_button_text_active");
  202. }
  203. else
  204. {
  205. return UM.Theme.getColor("topbar_button_text_inactive");
  206. }
  207. }
  208. }
  209. UM.RecolorImage
  210. {
  211. visible: control.iconSource != ""
  212. id: icon
  213. anchors.left: button_label.right
  214. anchors.leftMargin: (icon.visible || overlayIcon.visible) ? Theme.getSize("default_margin").width : 0
  215. color: UM.Theme.getColor("text_emphasis")
  216. opacity: !control.enabled ? 0.2 : 1.0
  217. source: control.iconSource
  218. width: visible ? Theme.getSize("topbar_button_icon").width : 0
  219. height: Theme.getSize("topbar_button_icon").height
  220. sourceSize: Theme.getSize("topbar_button_icon")
  221. }
  222. UM.RecolorImage
  223. {
  224. id: overlayIcon
  225. anchors.left: button_label.right
  226. anchors.leftMargin: (icon.visible || overlayIcon.visible) ? Theme.getSize("default_margin").width : 0
  227. visible: control.overlayIconSource != "" && control.iconSource != ""
  228. color: control.overlayColor
  229. opacity: !control.enabled ? 0.2 : 1.0
  230. source: control.overlayIconSource
  231. width: visible ? Theme.getSize("topbar_button_icon").width : 0
  232. height: Theme.getSize("topbar_button_icon").height
  233. sourceSize: Theme.getSize("topbar_button_icon")
  234. }
  235. }
  236. }
  237. }
  238. }
  239. property Component tool_button: Component {
  240. ButtonStyle {
  241. background: Item {
  242. implicitWidth: Theme.getSize("button").width;
  243. implicitHeight: Theme.getSize("button").height;
  244. UM.PointingRectangle {
  245. id: button_tooltip
  246. anchors.left: parent.right
  247. anchors.leftMargin: Theme.getSize("button_tooltip_arrow").width * 2
  248. anchors.verticalCenter: parent.verticalCenter
  249. target: Qt.point(parent.x, y + Math.round(height/2))
  250. arrowSize: Theme.getSize("button_tooltip_arrow").width
  251. color: Theme.getColor("button_tooltip")
  252. opacity: control.hovered ? 1.0 : 0.0;
  253. visible: control.text != ""
  254. width: control.hovered ? button_tip.width + Theme.getSize("button_tooltip").width : 0
  255. height: Theme.getSize("button_tooltip").height
  256. Behavior on width { NumberAnimation { duration: 100; } }
  257. Behavior on opacity { NumberAnimation { duration: 100; } }
  258. Label {
  259. id: button_tip
  260. anchors.horizontalCenter: parent.horizontalCenter
  261. anchors.verticalCenter: parent.verticalCenter;
  262. text: control.text;
  263. font: Theme.getFont("button_tooltip");
  264. color: Theme.getColor("tooltip_text");
  265. }
  266. }
  267. Rectangle {
  268. id: buttonFace;
  269. anchors.fill: parent;
  270. property bool down: control.pressed || (control.checkable && control.checked);
  271. color:
  272. {
  273. if(control.customColor !== undefined && control.customColor !== null)
  274. {
  275. return control.customColor
  276. }
  277. else if(control.checkable && control.checked && control.hovered)
  278. {
  279. return Theme.getColor("button_active_hover");
  280. }
  281. else if(control.pressed || (control.checkable && control.checked))
  282. {
  283. return Theme.getColor("button_active");
  284. }
  285. else if(control.hovered)
  286. {
  287. return Theme.getColor("button_hover");
  288. }
  289. else
  290. {
  291. return Theme.getColor("button");
  292. }
  293. }
  294. Behavior on color { ColorAnimation { duration: 50; } }
  295. border.width: (control.hasOwnProperty("needBorder") && control.needBorder) ? 2 * screenScaleFactor : 0
  296. border.color: Theme.getColor("tool_button_border")
  297. UM.RecolorImage {
  298. id: tool_button_arrow
  299. anchors.right: parent.right;
  300. anchors.rightMargin: Theme.getSize("button").width - Math.round(Theme.getSize("button_icon").width / 4)
  301. anchors.bottom: parent.bottom;
  302. anchors.bottomMargin: Theme.getSize("button").height - Math.round(Theme.getSize("button_icon").height / 4)
  303. width: Theme.getSize("standard_arrow").width
  304. height: Theme.getSize("standard_arrow").height
  305. sourceSize.width: width
  306. sourceSize.height: width
  307. visible: control.menu != null;
  308. color:
  309. {
  310. if(control.checkable && control.checked && control.hovered)
  311. {
  312. return Theme.getColor("button_text_active_hover");
  313. }
  314. else if(control.pressed || (control.checkable && control.checked))
  315. {
  316. return Theme.getColor("button_text_active");
  317. }
  318. else if(control.hovered)
  319. {
  320. return Theme.getColor("button_text_hover");
  321. }
  322. else
  323. {
  324. return Theme.getColor("button_text");
  325. }
  326. }
  327. source: Theme.getIcon("arrow_bottom")
  328. }
  329. }
  330. }
  331. label: Item {
  332. UM.RecolorImage {
  333. anchors.centerIn: parent;
  334. opacity: !control.enabled ? 0.2 : 1.0
  335. source: control.iconSource;
  336. width: Theme.getSize("button_icon").width;
  337. height: Theme.getSize("button_icon").height;
  338. color:
  339. {
  340. if(control.checkable && control.checked && control.hovered)
  341. {
  342. return Theme.getColor("button_text_active_hover");
  343. }
  344. else if(control.pressed || (control.checkable && control.checked))
  345. {
  346. return Theme.getColor("button_text_active");
  347. }
  348. else if(control.hovered)
  349. {
  350. return Theme.getColor("button_text_hover");
  351. }
  352. else
  353. {
  354. return Theme.getColor("button_text");
  355. }
  356. }
  357. sourceSize: Theme.getSize("button_icon")
  358. }
  359. }
  360. }
  361. }
  362. property Component small_tool_button: Component {
  363. ButtonStyle {
  364. background: Item {
  365. implicitWidth: Theme.getSize("small_button").width;
  366. implicitHeight: Theme.getSize("small_button").height;
  367. Rectangle {
  368. id: smallButtonFace;
  369. anchors.fill: parent;
  370. property bool down: control.pressed || (control.checkable && control.checked);
  371. color:
  372. {
  373. if(control.customColor !== undefined && control.customColor !== null)
  374. {
  375. return control.customColor
  376. }
  377. else if(control.checkable && control.checked && control.hovered)
  378. {
  379. return Theme.getColor("small_button_active_hover");
  380. }
  381. else if(control.pressed || (control.checkable && control.checked))
  382. {
  383. return Theme.getColor("small_button_active");
  384. }
  385. else if(control.hovered)
  386. {
  387. return Theme.getColor("small_button_hover");
  388. }
  389. else
  390. {
  391. return Theme.getColor("small_button");
  392. }
  393. }
  394. Behavior on color { ColorAnimation { duration: 50; } }
  395. border.width: (control.hasOwnProperty("needBorder") && control.needBorder) ? 2 * screenScaleFactor : 0
  396. border.color: Theme.getColor("tool_button_border")
  397. UM.RecolorImage {
  398. id: smallToolButtonArrow
  399. width: 5
  400. height: 5
  401. sourceSize.width: 5
  402. sourceSize.height: 5
  403. visible: control.menu != null;
  404. color:
  405. {
  406. if(control.checkable && control.checked && control.hovered)
  407. {
  408. return Theme.getColor("small_button_text_active_hover");
  409. }
  410. else if(control.pressed || (control.checkable && control.checked))
  411. {
  412. return Theme.getColor("small_button_text_active");
  413. }
  414. else if(control.hovered)
  415. {
  416. return Theme.getColor("small_button_text_hover");
  417. }
  418. else
  419. {
  420. return Theme.getColor("small_button_text");
  421. }
  422. }
  423. source: Theme.getIcon("arrow_bottom")
  424. }
  425. }
  426. }
  427. label: Item {
  428. UM.RecolorImage {
  429. anchors.centerIn: parent;
  430. opacity: !control.enabled ? 0.2 : 1.0
  431. source: control.iconSource;
  432. width: Theme.getSize("small_button_icon").width;
  433. height: Theme.getSize("small_button_icon").height;
  434. color:
  435. {
  436. if(control.checkable && control.checked && control.hovered)
  437. {
  438. return Theme.getColor("small_button_text_active_hover");
  439. }
  440. else if(control.pressed || (control.checkable && control.checked))
  441. {
  442. return Theme.getColor("small_button_text_active");
  443. }
  444. else if(control.hovered)
  445. {
  446. return Theme.getColor("small_button_text_hover");
  447. }
  448. else
  449. {
  450. return Theme.getColor("small_button_text");
  451. }
  452. }
  453. sourceSize: Theme.getSize("small_button_icon")
  454. }
  455. }
  456. }
  457. }
  458. property Component progressbar: Component{
  459. ProgressBarStyle {
  460. background: Rectangle {
  461. implicitWidth: Theme.getSize("message").width - (Theme.getSize("default_margin").width * 2)
  462. implicitHeight: Theme.getSize("progressbar").height
  463. color: control.hasOwnProperty("backgroundColor") ? control.backgroundColor : Theme.getColor("progressbar_background")
  464. }
  465. progress: Rectangle {
  466. color:
  467. {
  468. if(control.indeterminate)
  469. {
  470. return "transparent";
  471. }
  472. else if(control.hasOwnProperty("controlColor"))
  473. {
  474. return control.controlColor;
  475. }
  476. else
  477. {
  478. return Theme.getColor("progressbar_control");
  479. }
  480. }
  481. radius: Theme.getSize("progressbar_radius").width
  482. Rectangle{
  483. radius: Theme.getSize("progressbar_radius").width
  484. color: control.hasOwnProperty("controlColor") ? control.controlColor : Theme.getColor("progressbar_control")
  485. width: Theme.getSize("progressbar_control").width
  486. height: Theme.getSize("progressbar_control").height
  487. visible: control.indeterminate
  488. SequentialAnimation on x {
  489. id: xAnim
  490. property int animEndPoint: Theme.getSize("message").width - Math.round((Theme.getSize("default_margin").width * 2.5)) - Theme.getSize("progressbar_control").width
  491. running: control.indeterminate && control.visible
  492. loops: Animation.Infinite
  493. NumberAnimation { from: 0; to: xAnim.animEndPoint; duration: 2000;}
  494. NumberAnimation { from: xAnim.animEndPoint; to: 0; duration: 2000;}
  495. }
  496. }
  497. }
  498. }
  499. }
  500. property Component sidebar_category: Component {
  501. ButtonStyle {
  502. background: Rectangle {
  503. anchors.fill: parent;
  504. anchors.left: parent.left
  505. anchors.leftMargin: Theme.getSize("sidebar_margin").width
  506. anchors.right: parent.right
  507. anchors.rightMargin: Theme.getSize("sidebar_margin").width
  508. implicitHeight: Theme.getSize("section").height;
  509. color: {
  510. if(control.color) {
  511. return control.color;
  512. } else if(!control.enabled) {
  513. return Theme.getColor("setting_category_disabled");
  514. } else if(control.hovered && control.checkable && control.checked) {
  515. return Theme.getColor("setting_category_active_hover");
  516. } else if(control.pressed || (control.checkable && control.checked)) {
  517. return Theme.getColor("setting_category_active");
  518. } else if(control.hovered) {
  519. return Theme.getColor("setting_category_hover");
  520. } else {
  521. return Theme.getColor("setting_category");
  522. }
  523. }
  524. Behavior on color { ColorAnimation { duration: 50; } }
  525. Rectangle {
  526. height: Theme.getSize("default_lining").height
  527. width: parent.width
  528. anchors.bottom: parent.bottom
  529. color: {
  530. if(!control.enabled) {
  531. return Theme.getColor("setting_category_disabled_border");
  532. } else if((control.hovered || control.activeFocus) && control.checkable && control.checked) {
  533. return Theme.getColor("setting_category_active_hover_border");
  534. } else if(control.pressed || (control.checkable && control.checked)) {
  535. return Theme.getColor("setting_category_active_border");
  536. } else if(control.hovered || control.activeFocus) {
  537. return Theme.getColor("setting_category_hover_border");
  538. } else {
  539. return Theme.getColor("setting_category_border");
  540. }
  541. }
  542. }
  543. }
  544. label: Item {
  545. anchors.fill: parent;
  546. anchors.left: parent.left
  547. Item{
  548. id: icon;
  549. anchors.left: parent.left
  550. height: parent.height
  551. width: Theme.getSize("section_icon_column").width
  552. UM.RecolorImage {
  553. anchors.verticalCenter: parent.verticalCenter
  554. anchors.left: parent.left
  555. anchors.leftMargin: Theme.getSize("sidebar_margin").width
  556. color:
  557. {
  558. if(!control.enabled)
  559. {
  560. return Theme.getColor("setting_category_disabled_text");
  561. }
  562. else if((control.hovered || control.activeFocus) && control.checkable && control.checked)
  563. {
  564. return Theme.getColor("setting_category_active_hover_text");
  565. }
  566. else if(control.pressed || (control.checkable && control.checked))
  567. {
  568. return Theme.getColor("setting_category_active_text");
  569. }
  570. else if(control.hovered || control.activeFocus)
  571. {
  572. return Theme.getColor("setting_category_hover_text");
  573. }
  574. else
  575. {
  576. return Theme.getColor("setting_category_text");
  577. }
  578. }
  579. source: control.iconSource;
  580. width: Theme.getSize("section_icon").width;
  581. height: Theme.getSize("section_icon").height;
  582. sourceSize.width: width + 15 * screenScaleFactor
  583. sourceSize.height: width + 15 * screenScaleFactor
  584. }
  585. }
  586. Label {
  587. anchors {
  588. left: icon.right;
  589. leftMargin: Theme.getSize("default_margin").width;
  590. right: parent.right;
  591. verticalCenter: parent.verticalCenter;
  592. }
  593. text: control.text;
  594. font: Theme.getFont("setting_category");
  595. color:
  596. {
  597. if(!control.enabled)
  598. {
  599. return Theme.getColor("setting_category_disabled_text");
  600. }
  601. else if((control.hovered || control.activeFocus) && control.checkable && control.checked)
  602. {
  603. return Theme.getColor("setting_category_active_hover_text");
  604. }
  605. else if(control.pressed || (control.checkable && control.checked))
  606. {
  607. return Theme.getColor("setting_category_active_text");
  608. }
  609. else if(control.hovered || control.activeFocus)
  610. {
  611. return Theme.getColor("setting_category_hover_text");
  612. }
  613. else
  614. {
  615. return Theme.getColor("setting_category_text");
  616. }
  617. }
  618. fontSizeMode: Text.HorizontalFit;
  619. minimumPointSize: 8
  620. }
  621. UM.RecolorImage {
  622. id: category_arrow
  623. anchors.verticalCenter: parent.verticalCenter
  624. anchors.right: parent.right
  625. anchors.rightMargin: Theme.getSize("default_margin").width * 3 - Math.round(width / 2)
  626. width: Theme.getSize("standard_arrow").width
  627. height: Theme.getSize("standard_arrow").height
  628. sourceSize.width: width
  629. sourceSize.height: width
  630. color:
  631. {
  632. if(!control.enabled)
  633. {
  634. return Theme.getColor("setting_category_disabled_text");
  635. }
  636. else if((control.hovered || control.activeFocus) && control.checkable && control.checked)
  637. {
  638. return Theme.getColor("setting_category_active_hover_text");
  639. }
  640. else if(control.pressed || (control.checkable && control.checked))
  641. {
  642. return Theme.getColor("setting_category_active_text");
  643. }
  644. else if(control.hovered || control.activeFocus)
  645. {
  646. return Theme.getColor("setting_category_hover_text");
  647. }
  648. else
  649. {
  650. return Theme.getColor("setting_category_text");
  651. }
  652. }
  653. source: control.checked ? Theme.getIcon("arrow_bottom") : Theme.getIcon("arrow_left")
  654. }
  655. }
  656. }
  657. }
  658. property Component scrollview: Component {
  659. ScrollViewStyle {
  660. decrementControl: Item { }
  661. incrementControl: Item { }
  662. transientScrollBars: false
  663. scrollBarBackground: Rectangle {
  664. implicitWidth: Theme.getSize("scrollbar").width
  665. radius: Math.round(implicitWidth / 2)
  666. color: Theme.getColor("scrollbar_background");
  667. }
  668. handle: Rectangle {
  669. id: scrollViewHandle
  670. implicitWidth: Theme.getSize("scrollbar").width;
  671. radius: Math.round(implicitWidth / 2)
  672. color: styleData.pressed ? Theme.getColor("scrollbar_handle_down") : styleData.hovered ? Theme.getColor("scrollbar_handle_hover") : Theme.getColor("scrollbar_handle");
  673. Behavior on color { ColorAnimation { duration: 50; } }
  674. }
  675. }
  676. }
  677. property Component combobox: Component {
  678. ComboBoxStyle {
  679. background: Rectangle {
  680. implicitHeight: Theme.getSize("setting_control").height;
  681. implicitWidth: Theme.getSize("setting_control").width;
  682. color: control.hovered ? UM.Theme.getColor("setting_control_highlight") : UM.Theme.getColor("setting_control")
  683. Behavior on color { ColorAnimation { duration: 50; } }
  684. border.width: Theme.getSize("default_lining").width;
  685. border.color: control.hovered ? Theme.getColor("setting_control_border_highlight") : Theme.getColor("setting_control_border");
  686. }
  687. label: Item {
  688. Label {
  689. anchors.left: parent.left;
  690. anchors.leftMargin: Theme.getSize("default_lining").width
  691. anchors.right: downArrow.left;
  692. anchors.rightMargin: Theme.getSize("default_lining").width;
  693. anchors.verticalCenter: parent.verticalCenter;
  694. text: control.currentText;
  695. font: Theme.getFont("default");
  696. color: !enabled ? Theme.getColor("setting_control_disabled_text") : Theme.getColor("setting_control_text");
  697. elide: Text.ElideRight;
  698. verticalAlignment: Text.AlignVCenter;
  699. }
  700. UM.RecolorImage {
  701. id: downArrow
  702. anchors.right: parent.right;
  703. anchors.rightMargin: Theme.getSize("default_lining").width * 2;
  704. anchors.verticalCenter: parent.verticalCenter;
  705. source: Theme.getIcon("arrow_bottom")
  706. width: Theme.getSize("standard_arrow").width
  707. height: Theme.getSize("standard_arrow").height
  708. sourceSize.width: width + 5 * screenScaleFactor
  709. sourceSize.height: width + 5 * screenScaleFactor
  710. color: Theme.getColor("setting_control_text");
  711. }
  712. }
  713. }
  714. }
  715. // Combobox with items with colored rectangles
  716. property Component combobox_color: Component {
  717. ComboBoxStyle {
  718. background: Rectangle {
  719. color: !enabled ? UM.Theme.getColor("setting_control_disabled") : control._hovered ? UM.Theme.getColor("setting_control_highlight") : UM.Theme.getColor("setting_control")
  720. border.width: UM.Theme.getSize("default_lining").width
  721. border.color: !enabled ? UM.Theme.getColor("setting_control_disabled_border") : control._hovered ? UM.Theme.getColor("setting_control_border_highlight") : UM.Theme.getColor("setting_control_border")
  722. }
  723. label: Item {
  724. Label {
  725. anchors.left: parent.left
  726. anchors.leftMargin: UM.Theme.getSize("default_lining").width
  727. anchors.right: swatch.left
  728. anchors.rightMargin: UM.Theme.getSize("default_lining").width
  729. anchors.verticalCenter: parent.verticalCenter
  730. text: control.currentText
  731. font: UM.Theme.getFont("default")
  732. color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text")
  733. elide: Text.ElideRight
  734. verticalAlignment: Text.AlignVCenter
  735. }
  736. Rectangle {
  737. id: swatch
  738. height: Math.round(UM.Theme.getSize("setting_control").height / 2)
  739. width: height
  740. anchors.right: downArrow.left
  741. anchors.verticalCenter: parent.verticalCenter
  742. anchors.margins: Math.round(UM.Theme.getSize("default_margin").width / 4)
  743. radius: Math.round(width / 2)
  744. border.width: UM.Theme.getSize("default_lining").width
  745. border.color: UM.Theme.getColor("lining")
  746. color: (control.color_override !== "") ? control.color_override : control.color
  747. }
  748. UM.RecolorImage {
  749. id: downArrow
  750. anchors.right: parent.right
  751. anchors.rightMargin: UM.Theme.getSize("default_lining").width * 2
  752. anchors.verticalCenter: parent.verticalCenter
  753. source: UM.Theme.getIcon("arrow_bottom")
  754. width: UM.Theme.getSize("standard_arrow").width
  755. height: UM.Theme.getSize("standard_arrow").height
  756. sourceSize.width: width + 5 * screenScaleFactor
  757. sourceSize.height: width + 5 * screenScaleFactor
  758. color: UM.Theme.getColor("setting_control_text")
  759. }
  760. }
  761. }
  762. }
  763. property Component checkbox: Component {
  764. CheckBoxStyle {
  765. background: Item { }
  766. indicator: Rectangle {
  767. implicitWidth: Theme.getSize("checkbox").width;
  768. implicitHeight: Theme.getSize("checkbox").height;
  769. color: (control.hovered || control._hovered) ? Theme.getColor("checkbox_hover") : Theme.getColor("checkbox");
  770. Behavior on color { ColorAnimation { duration: 50; } }
  771. radius: control.exclusiveGroup ? Math.round(Theme.getSize("checkbox").width / 2) : 0
  772. border.width: Theme.getSize("default_lining").width;
  773. border.color: (control.hovered || control._hovered) ? Theme.getColor("checkbox_border_hover") : Theme.getColor("checkbox_border");
  774. UM.RecolorImage {
  775. anchors.verticalCenter: parent.verticalCenter
  776. anchors.horizontalCenter: parent.horizontalCenter
  777. width: Math.round(parent.width / 2.5)
  778. height: Math.round(parent.height / 2.5)
  779. sourceSize.width: width
  780. sourceSize.height: width
  781. color: Theme.getColor("checkbox_mark")
  782. source: control.exclusiveGroup ? Theme.getIcon("dot") : Theme.getIcon("check")
  783. opacity: control.checked
  784. Behavior on opacity { NumberAnimation { duration: 100; } }
  785. }
  786. }
  787. label: Label {
  788. text: control.text
  789. color: Theme.getColor("checkbox_text")
  790. font: Theme.getFont("default")
  791. elide: Text.ElideRight
  792. }
  793. }
  794. }
  795. property Component partially_checkbox: Component {
  796. CheckBoxStyle {
  797. background: Item { }
  798. indicator: Rectangle {
  799. implicitWidth: Theme.getSize("checkbox").width;
  800. implicitHeight: Theme.getSize("checkbox").height;
  801. color: (control.hovered || control._hovered) ? Theme.getColor("checkbox_hover") : Theme.getColor("checkbox");
  802. Behavior on color { ColorAnimation { duration: 50; } }
  803. radius: control.exclusiveGroup ? Math.round(Theme.getSize("checkbox").width / 2) : 0
  804. border.width: Theme.getSize("default_lining").width;
  805. border.color: (control.hovered || control._hovered) ? Theme.getColor("checkbox_border_hover") : Theme.getColor("checkbox_border");
  806. UM.RecolorImage {
  807. anchors.verticalCenter: parent.verticalCenter
  808. anchors.horizontalCenter: parent.horizontalCenter
  809. width: Math.round(parent.width / 2.5)
  810. height: Math.round(parent.height / 2.5)
  811. sourceSize.width: width
  812. sourceSize.height: width
  813. color: Theme.getColor("checkbox_mark")
  814. source: {
  815. if (control.checkbox_state == 2){
  816. return Theme.getIcon("solid")
  817. }
  818. else{
  819. return control.exclusiveGroup ? Theme.getIcon("dot") : Theme.getIcon("check")
  820. }
  821. }
  822. opacity: control.checked
  823. Behavior on opacity { NumberAnimation { duration: 100; } }
  824. }
  825. }
  826. label: Label {
  827. text: control.text;
  828. color: Theme.getColor("checkbox_text");
  829. font: Theme.getFont("default");
  830. }
  831. }
  832. }
  833. property Component slider: Component {
  834. SliderStyle {
  835. groove: Rectangle {
  836. implicitWidth: control.width;
  837. implicitHeight: Theme.getSize("slider_groove").height;
  838. color: Theme.getColor("slider_groove");
  839. border.width: Theme.getSize("default_lining").width;
  840. border.color: Theme.getColor("slider_groove_border");
  841. radius: Math.round(width / 2);
  842. Rectangle {
  843. anchors {
  844. left: parent.left;
  845. top: parent.top;
  846. bottom: parent.bottom;
  847. }
  848. color: Theme.getColor("slider_groove_fill");
  849. width: Math.round((control.value / (control.maximumValue - control.minimumValue)) * parent.width);
  850. radius: Math.round(width / 2);
  851. }
  852. }
  853. handle: Rectangle {
  854. width: Theme.getSize("slider_handle").width;
  855. height: Theme.getSize("slider_handle").height;
  856. color: control.hovered ? Theme.getColor("slider_handle_hover") : Theme.getColor("slider_handle");
  857. border.width: Theme.getSize("default_lining").width
  858. border.color: control.hovered ? Theme.getColor("slider_handle_hover_border") : Theme.getColor("slider_handle_border")
  859. radius: Math.round(Theme.getSize("slider_handle").width / 2); //Round.
  860. Behavior on color { ColorAnimation { duration: 50; } }
  861. }
  862. }
  863. }
  864. property Component text_field: Component {
  865. TextFieldStyle {
  866. textColor: Theme.getColor("setting_control_text");
  867. placeholderTextColor: Theme.getColor("setting_control_text")
  868. font: Theme.getFont("default");
  869. background: Rectangle
  870. {
  871. implicitHeight: control.height;
  872. implicitWidth: control.width;
  873. border.width: Theme.getSize("default_lining").width;
  874. border.color: control.hovered ? Theme.getColor("setting_control_border_highlight") : Theme.getColor("setting_control_border");
  875. color: Theme.getColor("setting_validation_ok");
  876. Label {
  877. anchors.right: parent.right;
  878. anchors.rightMargin: Theme.getSize("setting_unit_margin").width;
  879. anchors.verticalCenter: parent.verticalCenter;
  880. text: control.unit ? control.unit : ""
  881. color: Theme.getColor("setting_unit");
  882. font: Theme.getFont("default");
  883. }
  884. }
  885. }
  886. }
  887. property Component sidebar_action_button: Component {
  888. ButtonStyle
  889. {
  890. background: Rectangle
  891. {
  892. border.width: UM.Theme.getSize("default_lining").width
  893. border.color:
  894. {
  895. if(!control.enabled)
  896. return UM.Theme.getColor("action_button_disabled_border");
  897. else if(control.pressed)
  898. return UM.Theme.getColor("action_button_active_border");
  899. else if(control.hovered)
  900. return UM.Theme.getColor("action_button_hovered_border");
  901. else
  902. return UM.Theme.getColor("action_button_border");
  903. }
  904. color:
  905. {
  906. if(!control.enabled)
  907. return UM.Theme.getColor("action_button_disabled");
  908. else if(control.pressed)
  909. return UM.Theme.getColor("action_button_active");
  910. else if(control.hovered)
  911. return UM.Theme.getColor("action_button_hovered");
  912. else
  913. return UM.Theme.getColor("action_button");
  914. }
  915. Behavior on color { ColorAnimation { duration: 50; } }
  916. implicitWidth: actualLabel.contentWidth + (UM.Theme.getSize("sidebar_margin").width * 2)
  917. Label
  918. {
  919. id: actualLabel
  920. anchors.centerIn: parent
  921. color:
  922. {
  923. if(!control.enabled)
  924. return UM.Theme.getColor("action_button_disabled_text");
  925. else if(control.pressed)
  926. return UM.Theme.getColor("action_button_active_text");
  927. else if(control.hovered)
  928. return UM.Theme.getColor("action_button_hovered_text");
  929. else
  930. return UM.Theme.getColor("action_button_text");
  931. }
  932. font: UM.Theme.getFont("action_button")
  933. text: control.text
  934. }
  935. }
  936. label: Item { }
  937. }
  938. }
  939. property Component toolbox_action_button: Component {
  940. ButtonStyle
  941. {
  942. background: Rectangle
  943. {
  944. implicitWidth: UM.Theme.getSize("toolbox_action_button").width
  945. implicitHeight: UM.Theme.getSize("toolbox_action_button").height
  946. color:
  947. {
  948. if (control.installed)
  949. {
  950. return UM.Theme.getColor("action_button_disabled")
  951. }
  952. else
  953. {
  954. if (control.hovered)
  955. {
  956. return UM.Theme.getColor("primary_hover")
  957. }
  958. else
  959. {
  960. return UM.Theme.getColor("primary")
  961. }
  962. }
  963. }
  964. }
  965. label: Label
  966. {
  967. text: control.text
  968. color:
  969. {
  970. if (control.installed)
  971. {
  972. return UM.Theme.getColor("action_button_disabled_text")
  973. }
  974. else
  975. {
  976. if (control.hovered)
  977. {
  978. return UM.Theme.getColor("button_text_hover")
  979. }
  980. else
  981. {
  982. return UM.Theme.getColor("button_text")
  983. }
  984. }
  985. }
  986. verticalAlignment: Text.AlignVCenter
  987. horizontalAlignment: Text.AlignHCenter
  988. font: UM.Theme.getFont("default_bold")
  989. }
  990. }
  991. }
  992. }