styles.qml 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.10
  4. import QtQuick.Controls 1.4
  5. import QtQuick.Controls.Styles 1.4
  6. import UM 1.1 as UM
  7. QtObject
  8. {
  9. property Component print_setup_header_button: Component
  10. {
  11. ButtonStyle
  12. {
  13. background: Rectangle
  14. {
  15. color:
  16. {
  17. if(control.enabled)
  18. {
  19. if(control.valueError)
  20. {
  21. return Theme.getColor("setting_validation_error_background");
  22. }
  23. else if(control.valueWarning)
  24. {
  25. return Theme.getColor("setting_validation_warning_background");
  26. }
  27. else
  28. {
  29. return Theme.getColor("setting_control");
  30. }
  31. }
  32. else
  33. {
  34. return Theme.getColor("setting_control_disabled");
  35. }
  36. }
  37. radius: UM.Theme.getSize("setting_control_radius").width
  38. border.width: Theme.getSize("default_lining").width
  39. border.color:
  40. {
  41. if (control.enabled)
  42. {
  43. if (control.valueError)
  44. {
  45. return Theme.getColor("setting_validation_error");
  46. }
  47. else if (control.valueWarning)
  48. {
  49. return Theme.getColor("setting_validation_warning");
  50. }
  51. else if (control.hovered)
  52. {
  53. return Theme.getColor("setting_control_border_highlight");
  54. }
  55. else
  56. {
  57. return Theme.getColor("setting_control_border");
  58. }
  59. }
  60. else
  61. {
  62. return Theme.getColor("setting_control_disabled_border");
  63. }
  64. }
  65. UM.RecolorImage
  66. {
  67. id: downArrow
  68. anchors.verticalCenter: parent.verticalCenter
  69. anchors.right: parent.right
  70. anchors.rightMargin: Theme.getSize("default_margin").width
  71. width: Theme.getSize("standard_arrow").width
  72. height: Theme.getSize("standard_arrow").height
  73. sourceSize.height: width
  74. color: control.enabled ? Theme.getColor("setting_control_button") : Theme.getColor("setting_category_disabled_text")
  75. source: Theme.getIcon("arrow_bottom")
  76. }
  77. Label
  78. {
  79. id: printSetupComboBoxLabel
  80. color: control.enabled ? Theme.getColor("setting_control_text") : Theme.getColor("setting_control_disabled_text")
  81. text: control.text;
  82. elide: Text.ElideRight;
  83. anchors.left: parent.left;
  84. anchors.leftMargin: Theme.getSize("setting_unit_margin").width
  85. anchors.right: downArrow.left;
  86. anchors.rightMargin: control.rightMargin;
  87. anchors.verticalCenter: parent.verticalCenter;
  88. font: Theme.getFont("default")
  89. }
  90. }
  91. label: Label{}
  92. }
  93. }
  94. property Component main_window_header_tab: Component
  95. {
  96. ButtonStyle
  97. {
  98. // This property will be back-propagated when the width of the label is calculated
  99. property var buttonWidth: 0
  100. background: Rectangle
  101. {
  102. id: backgroundRectangle
  103. implicitHeight: control.height
  104. implicitWidth: buttonWidth
  105. radius: UM.Theme.getSize("action_button_radius").width
  106. color:
  107. {
  108. if (control.checked)
  109. {
  110. return UM.Theme.getColor("main_window_header_button_background_active")
  111. }
  112. else
  113. {
  114. if (control.hovered)
  115. {
  116. return UM.Theme.getColor("main_window_header_button_background_hovered")
  117. }
  118. return UM.Theme.getColor("main_window_header_button_background_inactive")
  119. }
  120. }
  121. }
  122. label: Item
  123. {
  124. id: contents
  125. anchors.horizontalCenter: parent.horizontalCenter
  126. anchors.verticalCenter: parent.verticalCenter
  127. height: control.height
  128. width: buttonLabel.width + 4 * UM.Theme.getSize("default_margin").width
  129. Label
  130. {
  131. id: buttonLabel
  132. text: control.text
  133. anchors.verticalCenter: parent.verticalCenter
  134. anchors.horizontalCenter: parent.horizontalCenter
  135. font: UM.Theme.getFont("medium")
  136. color:
  137. {
  138. if (control.checked)
  139. {
  140. return UM.Theme.getColor("main_window_header_button_text_active")
  141. }
  142. else
  143. {
  144. if (control.hovered)
  145. {
  146. return UM.Theme.getColor("main_window_header_button_text_hovered")
  147. }
  148. return UM.Theme.getColor("main_window_header_button_text_inactive")
  149. }
  150. }
  151. }
  152. Component.onCompleted:
  153. {
  154. buttonWidth = width
  155. }
  156. }
  157. }
  158. }
  159. property Component tool_button: Component
  160. {
  161. ButtonStyle
  162. {
  163. background: Item
  164. {
  165. implicitWidth: Theme.getSize("button").width
  166. implicitHeight: Theme.getSize("button").height
  167. UM.PointingRectangle
  168. {
  169. id: button_tooltip
  170. anchors.left: parent.right
  171. anchors.leftMargin: Theme.getSize("button_tooltip_arrow").width * 2
  172. anchors.verticalCenter: parent.verticalCenter
  173. target: Qt.point(parent.x, y + Math.round(height/2))
  174. arrowSize: Theme.getSize("button_tooltip_arrow").width
  175. color: Theme.getColor("button_tooltip")
  176. opacity: control.hovered ? 1.0 : 0.0;
  177. visible: control.text != ""
  178. width: control.hovered ? button_tip.width + Theme.getSize("button_tooltip").width : 0
  179. height: Theme.getSize("button_tooltip").height
  180. Behavior on width { NumberAnimation { duration: 100; } }
  181. Behavior on opacity { NumberAnimation { duration: 100; } }
  182. Label
  183. {
  184. id: button_tip
  185. anchors.horizontalCenter: parent.horizontalCenter
  186. anchors.verticalCenter: parent.verticalCenter
  187. text: control.text
  188. font: Theme.getFont("default")
  189. color: Theme.getColor("tooltip_text")
  190. }
  191. }
  192. Rectangle
  193. {
  194. id: buttonFace
  195. anchors.fill: parent
  196. property bool down: control.pressed || (control.checkable && control.checked)
  197. color:
  198. {
  199. if(control.customColor !== undefined && control.customColor !== null)
  200. {
  201. return control.customColor
  202. }
  203. else if(control.checkable && control.checked && control.hovered)
  204. {
  205. return Theme.getColor("toolbar_button_active_hover")
  206. }
  207. else if(control.pressed || (control.checkable && control.checked))
  208. {
  209. return Theme.getColor("toolbar_button_active")
  210. }
  211. else if(control.hovered)
  212. {
  213. return Theme.getColor("toolbar_button_hover")
  214. }
  215. return Theme.getColor("toolbar_background")
  216. }
  217. Behavior on color { ColorAnimation { duration: 50; } }
  218. border.width: (control.hasOwnProperty("needBorder") && control.needBorder) ? Theme.getSize("default_lining").width : 0
  219. border.color: Theme.getColor("lining")
  220. }
  221. }
  222. label: Item
  223. {
  224. UM.RecolorImage
  225. {
  226. anchors.centerIn: parent
  227. opacity: control.enabled ? 1.0 : 0.2
  228. source: control.iconSource
  229. width: Theme.getSize("button_icon").width
  230. height: Theme.getSize("button_icon").height
  231. color: Theme.getColor("icon")
  232. sourceSize: Theme.getSize("button_icon")
  233. }
  234. }
  235. }
  236. }
  237. property Component progressbar: Component
  238. {
  239. ProgressBarStyle
  240. {
  241. background: Rectangle
  242. {
  243. implicitWidth: Theme.getSize("message").width - (Theme.getSize("default_margin").width * 2)
  244. implicitHeight: Theme.getSize("progressbar").height
  245. color: control.hasOwnProperty("backgroundColor") ? control.backgroundColor : Theme.getColor("progressbar_background")
  246. radius: Theme.getSize("progressbar_radius").width
  247. }
  248. progress: Rectangle
  249. {
  250. color:
  251. {
  252. if(control.indeterminate)
  253. {
  254. return "transparent";
  255. }
  256. else if(control.hasOwnProperty("controlColor"))
  257. {
  258. return control.controlColor;
  259. }
  260. else
  261. {
  262. return Theme.getColor("progressbar_control");
  263. }
  264. }
  265. radius: Theme.getSize("progressbar_radius").width
  266. Rectangle
  267. {
  268. radius: Theme.getSize("progressbar_radius").width
  269. color: control.hasOwnProperty("controlColor") ? control.controlColor : Theme.getColor("progressbar_control")
  270. width: Theme.getSize("progressbar_control").width
  271. height: Theme.getSize("progressbar_control").height
  272. visible: control.indeterminate
  273. SequentialAnimation on x
  274. {
  275. id: xAnim
  276. property int animEndPoint: Theme.getSize("message").width - Math.round((Theme.getSize("default_margin").width * 2.5)) - Theme.getSize("progressbar_control").width
  277. running: control.indeterminate && control.visible
  278. loops: Animation.Infinite
  279. NumberAnimation { from: 0; to: xAnim.animEndPoint; duration: 2000;}
  280. NumberAnimation { from: xAnim.animEndPoint; to: 0; duration: 2000;}
  281. }
  282. }
  283. }
  284. }
  285. }
  286. property Component scrollview: Component
  287. {
  288. ScrollViewStyle
  289. {
  290. decrementControl: Item { }
  291. incrementControl: Item { }
  292. transientScrollBars: false
  293. scrollBarBackground: Rectangle
  294. {
  295. implicitWidth: Theme.getSize("scrollbar").width
  296. radius: Math.round(implicitWidth / 2)
  297. color: Theme.getColor("scrollbar_background")
  298. }
  299. handle: Rectangle
  300. {
  301. id: scrollViewHandle
  302. implicitWidth: Theme.getSize("scrollbar").width
  303. radius: Math.round(implicitWidth / 2)
  304. color: styleData.pressed ? Theme.getColor("scrollbar_handle_down") : styleData.hovered ? Theme.getColor("scrollbar_handle_hover") : Theme.getColor("scrollbar_handle")
  305. Behavior on color { ColorAnimation { duration: 50; } }
  306. }
  307. }
  308. }
  309. property Component combobox: Component
  310. {
  311. ComboBoxStyle
  312. {
  313. background: Rectangle
  314. {
  315. implicitHeight: Theme.getSize("setting_control").height;
  316. implicitWidth: Theme.getSize("setting_control").width;
  317. color: control.hovered ? UM.Theme.getColor("setting_control_highlight") : UM.Theme.getColor("setting_control")
  318. Behavior on color { ColorAnimation { duration: 50; } }
  319. border.width: Theme.getSize("default_lining").width;
  320. border.color: control.hovered ? Theme.getColor("setting_control_border_highlight") : Theme.getColor("setting_control_border");
  321. radius: UM.Theme.getSize("setting_control_radius").width
  322. }
  323. label: Item
  324. {
  325. Label
  326. {
  327. anchors.left: parent.left
  328. anchors.leftMargin: Theme.getSize("default_lining").width
  329. anchors.right: downArrow.left
  330. anchors.rightMargin: Theme.getSize("default_lining").width
  331. anchors.verticalCenter: parent.verticalCenter
  332. text: control.currentText
  333. font: Theme.getFont("default");
  334. color: !enabled ? Theme.getColor("setting_control_disabled_text") : Theme.getColor("setting_control_text")
  335. elide: Text.ElideRight
  336. verticalAlignment: Text.AlignVCenter
  337. }
  338. UM.RecolorImage
  339. {
  340. id: downArrow
  341. anchors.right: parent.right
  342. anchors.rightMargin: Theme.getSize("default_lining").width * 2
  343. anchors.verticalCenter: parent.verticalCenter
  344. source: Theme.getIcon("arrow_bottom")
  345. width: Theme.getSize("standard_arrow").width
  346. height: Theme.getSize("standard_arrow").height
  347. sourceSize.width: width + 5 * screenScaleFactor
  348. sourceSize.height: width + 5 * screenScaleFactor
  349. color: Theme.getColor("setting_control_button");
  350. }
  351. }
  352. }
  353. }
  354. // Combobox with items with colored rectangles
  355. property Component combobox_color: Component
  356. {
  357. ComboBoxStyle
  358. {
  359. background: Rectangle
  360. {
  361. color: !enabled ? UM.Theme.getColor("setting_control_disabled") : control._hovered ? UM.Theme.getColor("setting_control_highlight") : UM.Theme.getColor("setting_control")
  362. border.width: UM.Theme.getSize("default_lining").width
  363. 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")
  364. radius: UM.Theme.getSize("setting_control_radius").width
  365. }
  366. label: Item
  367. {
  368. Label
  369. {
  370. anchors.left: parent.left
  371. anchors.leftMargin: UM.Theme.getSize("default_lining").width
  372. anchors.right: swatch.left
  373. anchors.rightMargin: UM.Theme.getSize("default_lining").width
  374. anchors.verticalCenter: parent.verticalCenter
  375. text: control.currentText
  376. font: UM.Theme.getFont("default")
  377. color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text")
  378. elide: Text.ElideRight
  379. verticalAlignment: Text.AlignVCenter
  380. }
  381. UM.RecolorImage
  382. {
  383. id: swatch
  384. height: Math.round(control.height / 2)
  385. width: height
  386. anchors.right: downArrow.left
  387. anchors.verticalCenter: parent.verticalCenter
  388. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  389. sourceSize.width: width
  390. sourceSize.height: height
  391. source: UM.Theme.getIcon("extruder_button")
  392. color: (control.color_override !== "") ? control.color_override : control.color
  393. }
  394. UM.RecolorImage
  395. {
  396. id: downArrow
  397. anchors.right: parent.right
  398. anchors.rightMargin: UM.Theme.getSize("default_lining").width * 2
  399. anchors.verticalCenter: parent.verticalCenter
  400. source: UM.Theme.getIcon("arrow_bottom")
  401. width: UM.Theme.getSize("standard_arrow").width
  402. height: UM.Theme.getSize("standard_arrow").height
  403. sourceSize.width: width + 5 * screenScaleFactor
  404. sourceSize.height: width + 5 * screenScaleFactor
  405. color: UM.Theme.getColor("setting_control_button")
  406. }
  407. }
  408. }
  409. }
  410. property Component checkbox: Component
  411. {
  412. CheckBoxStyle
  413. {
  414. background: Item { }
  415. indicator: Rectangle
  416. {
  417. implicitWidth: Theme.getSize("checkbox").width
  418. implicitHeight: Theme.getSize("checkbox").height
  419. color: (control.hovered || control._hovered) ? Theme.getColor("checkbox_hover") : (control.enabled ? Theme.getColor("checkbox") : Theme.getColor("checkbox_disabled"))
  420. Behavior on color { ColorAnimation { duration: 50; } }
  421. radius: control.exclusiveGroup ? Math.round(Theme.getSize("checkbox").width / 2) : Theme.getSize("checkbox_radius").width
  422. border.width: Theme.getSize("default_lining").width
  423. border.color: (control.hovered || control._hovered) ? Theme.getColor("checkbox_border_hover") : Theme.getColor("checkbox_border")
  424. UM.RecolorImage
  425. {
  426. anchors.verticalCenter: parent.verticalCenter
  427. anchors.horizontalCenter: parent.horizontalCenter
  428. width: Math.round(parent.width / 2.5)
  429. height: Math.round(parent.height / 2.5)
  430. sourceSize.height: width
  431. color: Theme.getColor("checkbox_mark")
  432. source: control.exclusiveGroup ? Theme.getIcon("dot") : Theme.getIcon("check")
  433. opacity: control.checked
  434. Behavior on opacity { NumberAnimation { duration: 100; } }
  435. }
  436. }
  437. label: Label
  438. {
  439. text: control.text
  440. color: Theme.getColor("checkbox_text")
  441. font: Theme.getFont("default")
  442. elide: Text.ElideRight
  443. renderType: Text.NativeRendering
  444. }
  445. }
  446. }
  447. property Component partially_checkbox: Component
  448. {
  449. CheckBoxStyle
  450. {
  451. background: Item { }
  452. indicator: Rectangle
  453. {
  454. implicitWidth: Theme.getSize("checkbox").width
  455. implicitHeight: Theme.getSize("checkbox").height
  456. color: (control.hovered || control._hovered) ? Theme.getColor("checkbox_hover") : Theme.getColor("checkbox");
  457. Behavior on color { ColorAnimation { duration: 50; } }
  458. radius: control.exclusiveGroup ? Math.round(Theme.getSize("checkbox").width / 2) : UM.Theme.getSize("checkbox_radius").width
  459. border.width: Theme.getSize("default_lining").width;
  460. border.color: (control.hovered || control._hovered) ? Theme.getColor("checkbox_border_hover") : Theme.getColor("checkbox_border");
  461. UM.RecolorImage
  462. {
  463. anchors.verticalCenter: parent.verticalCenter
  464. anchors.horizontalCenter: parent.horizontalCenter
  465. width: Math.round(parent.width / 2.5)
  466. height: Math.round(parent.height / 2.5)
  467. sourceSize.height: width
  468. color: Theme.getColor("checkbox_mark")
  469. source:
  470. {
  471. if (control.checkbox_state == 2)
  472. {
  473. return Theme.getIcon("solid");
  474. }
  475. else
  476. {
  477. return control.exclusiveGroup ? Theme.getIcon("dot") : Theme.getIcon("check");
  478. }
  479. }
  480. opacity: control.checked
  481. Behavior on opacity { NumberAnimation { duration: 100; } }
  482. }
  483. }
  484. label: Label
  485. {
  486. text: control.text
  487. color: Theme.getColor("checkbox_text")
  488. font: Theme.getFont("default")
  489. }
  490. }
  491. }
  492. property Component text_field: Component
  493. {
  494. TextFieldStyle
  495. {
  496. textColor: Theme.getColor("setting_control_text")
  497. placeholderTextColor: Theme.getColor("setting_control_text")
  498. font: Theme.getFont("default")
  499. background: Rectangle
  500. {
  501. implicitHeight: control.height;
  502. implicitWidth: control.width;
  503. border.width: Theme.getSize("default_lining").width;
  504. border.color: control.hovered ? Theme.getColor("setting_control_border_highlight") : Theme.getColor("setting_control_border");
  505. radius: UM.Theme.getSize("setting_control_radius").width
  506. color: Theme.getColor("setting_validation_ok");
  507. Label
  508. {
  509. anchors.right: parent.right;
  510. anchors.rightMargin: Theme.getSize("setting_unit_margin").width;
  511. anchors.verticalCenter: parent.verticalCenter;
  512. text: control.unit ? control.unit : ""
  513. color: Theme.getColor("setting_unit");
  514. font: Theme.getFont("default");
  515. renderType: Text.NativeRendering
  516. }
  517. }
  518. }
  519. }
  520. property Component print_setup_action_button: Component
  521. {
  522. ButtonStyle
  523. {
  524. background: Rectangle
  525. {
  526. border.width: UM.Theme.getSize("default_lining").width
  527. border.color:
  528. {
  529. if(!control.enabled)
  530. {
  531. return UM.Theme.getColor("action_button_disabled_border");
  532. }
  533. else if(control.pressed)
  534. {
  535. return UM.Theme.getColor("action_button_active_border");
  536. }
  537. else if(control.hovered)
  538. {
  539. return UM.Theme.getColor("action_button_hovered_border");
  540. }
  541. else
  542. {
  543. return UM.Theme.getColor("action_button_border");
  544. }
  545. }
  546. color:
  547. {
  548. if(!control.enabled)
  549. {
  550. return UM.Theme.getColor("action_button_disabled");
  551. }
  552. else if(control.pressed)
  553. {
  554. return UM.Theme.getColor("action_button_active");
  555. }
  556. else if(control.hovered)
  557. {
  558. return UM.Theme.getColor("action_button_hovered");
  559. }
  560. else
  561. {
  562. return UM.Theme.getColor("action_button");
  563. }
  564. }
  565. Behavior on color { ColorAnimation { duration: 50 } }
  566. implicitWidth: actualLabel.contentWidth + (UM.Theme.getSize("thick_margin").width * 2)
  567. Label
  568. {
  569. id: actualLabel
  570. anchors.centerIn: parent
  571. color:
  572. {
  573. if(!control.enabled)
  574. {
  575. return UM.Theme.getColor("action_button_disabled_text");
  576. }
  577. else if(control.pressed)
  578. {
  579. return UM.Theme.getColor("action_button_active_text");
  580. }
  581. else if(control.hovered)
  582. {
  583. return UM.Theme.getColor("action_button_hovered_text");
  584. }
  585. else
  586. {
  587. return UM.Theme.getColor("action_button_text");
  588. }
  589. }
  590. font: UM.Theme.getFont("medium")
  591. text: control.text
  592. }
  593. }
  594. label: Item { }
  595. }
  596. }
  597. property Component toolbox_action_button: Component
  598. {
  599. ButtonStyle
  600. {
  601. background: Rectangle
  602. {
  603. implicitWidth: UM.Theme.getSize("toolbox_action_button").width
  604. implicitHeight: UM.Theme.getSize("toolbox_action_button").height
  605. color:
  606. {
  607. if (control.installed)
  608. {
  609. return UM.Theme.getColor("action_button_disabled");
  610. }
  611. else
  612. {
  613. if (control.hovered)
  614. {
  615. return UM.Theme.getColor("primary_hover");
  616. }
  617. else
  618. {
  619. return UM.Theme.getColor("primary");
  620. }
  621. }
  622. }
  623. }
  624. label: Label
  625. {
  626. text: control.text
  627. color:
  628. {
  629. if (control.installed)
  630. {
  631. return UM.Theme.getColor("action_button_disabled_text");
  632. }
  633. else
  634. {
  635. if (control.hovered)
  636. {
  637. return UM.Theme.getColor("button_text_hover");
  638. }
  639. else
  640. {
  641. return UM.Theme.getColor("button_text");
  642. }
  643. }
  644. }
  645. verticalAlignment: Text.AlignVCenter
  646. horizontalAlignment: Text.AlignHCenter
  647. font: UM.Theme.getFont("default_bold")
  648. }
  649. }
  650. }
  651. property Component monitor_button_style: Component
  652. {
  653. ButtonStyle
  654. {
  655. background: Rectangle
  656. {
  657. border.width: UM.Theme.getSize("default_lining").width
  658. border.color:
  659. {
  660. if(!control.enabled)
  661. {
  662. return UM.Theme.getColor("action_button_disabled_border");
  663. }
  664. else if(control.pressed)
  665. {
  666. return UM.Theme.getColor("action_button_active_border");
  667. }
  668. else if(control.hovered)
  669. {
  670. return UM.Theme.getColor("action_button_hovered_border");
  671. }
  672. return UM.Theme.getColor("action_button_border");
  673. }
  674. color:
  675. {
  676. if(!control.enabled)
  677. {
  678. return UM.Theme.getColor("action_button_disabled");
  679. }
  680. else if(control.pressed)
  681. {
  682. return UM.Theme.getColor("action_button_active");
  683. }
  684. else if(control.hovered)
  685. {
  686. return UM.Theme.getColor("action_button_hovered");
  687. }
  688. return UM.Theme.getColor("action_button");
  689. }
  690. Behavior on color
  691. {
  692. ColorAnimation
  693. {
  694. duration: 50
  695. }
  696. }
  697. }
  698. label: Item
  699. {
  700. UM.RecolorImage
  701. {
  702. anchors.verticalCenter: parent.verticalCenter
  703. anchors.horizontalCenter: parent.horizontalCenter
  704. width: Math.floor(control.width / 2)
  705. height: Math.floor(control.height / 2)
  706. sourceSize.height: width
  707. color:
  708. {
  709. if(!control.enabled)
  710. {
  711. return UM.Theme.getColor("action_button_disabled_text");
  712. }
  713. else if(control.pressed)
  714. {
  715. return UM.Theme.getColor("action_button_active_text");
  716. }
  717. else if(control.hovered)
  718. {
  719. return UM.Theme.getColor("action_button_hovered_text");
  720. }
  721. return UM.Theme.getColor("action_button_text");
  722. }
  723. source: control.iconSource
  724. }
  725. }
  726. }
  727. }
  728. property Component monitor_checkable_button_style: Component
  729. {
  730. ButtonStyle {
  731. background: Rectangle {
  732. border.width: control.checked ? UM.Theme.getSize("default_lining").width * 2 : UM.Theme.getSize("default_lining").width
  733. border.color:
  734. {
  735. if(!control.enabled)
  736. {
  737. return UM.Theme.getColor("action_button_disabled_border");
  738. }
  739. else if (control.checked || control.pressed)
  740. {
  741. return UM.Theme.getColor("action_button_active_border");
  742. }
  743. else if(control.hovered)
  744. {
  745. return UM.Theme.getColor("action_button_hovered_border");
  746. }
  747. return UM.Theme.getColor("action_button_border");
  748. }
  749. color:
  750. {
  751. if(!control.enabled)
  752. {
  753. return UM.Theme.getColor("action_button_disabled");
  754. }
  755. else if (control.checked || control.pressed)
  756. {
  757. return UM.Theme.getColor("action_button_active");
  758. }
  759. else if (control.hovered)
  760. {
  761. return UM.Theme.getColor("action_button_hovered");
  762. }
  763. return UM.Theme.getColor("action_button");
  764. }
  765. Behavior on color { ColorAnimation { duration: 50; } }
  766. Label {
  767. anchors.left: parent.left
  768. anchors.right: parent.right
  769. anchors.verticalCenter: parent.verticalCenter
  770. anchors.leftMargin: UM.Theme.getSize("default_lining").width * 2
  771. anchors.rightMargin: UM.Theme.getSize("default_lining").width * 2
  772. color:
  773. {
  774. if(!control.enabled)
  775. {
  776. return UM.Theme.getColor("action_button_disabled_text");
  777. }
  778. else if (control.checked || control.pressed)
  779. {
  780. return UM.Theme.getColor("action_button_active_text");
  781. }
  782. else if (control.hovered)
  783. {
  784. return UM.Theme.getColor("action_button_hovered_text");
  785. }
  786. return UM.Theme.getColor("action_button_text");
  787. }
  788. font: UM.Theme.getFont("default")
  789. text: control.text
  790. horizontalAlignment: Text.AlignHCenter
  791. elide: Text.ElideMiddle
  792. }
  793. }
  794. label: Item { }
  795. }
  796. }
  797. }