styles.qml 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  1. // Copyright (c) 2018 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. {
  9. property Component sidebar_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. border.width: Theme.getSize("default_lining").width
  38. border.color:
  39. {
  40. if (control.enabled)
  41. {
  42. if (control.valueError)
  43. {
  44. return Theme.getColor("setting_validation_error");
  45. }
  46. else if (control.valueWarning)
  47. {
  48. return Theme.getColor("setting_validation_warning");
  49. }
  50. else if (control.hovered)
  51. {
  52. return Theme.getColor("setting_control_border_highlight");
  53. }
  54. else
  55. {
  56. return Theme.getColor("setting_control_border");
  57. }
  58. }
  59. else
  60. {
  61. return Theme.getColor("setting_control_disabled_border");
  62. }
  63. }
  64. UM.RecolorImage
  65. {
  66. id: downArrow
  67. anchors.verticalCenter: parent.verticalCenter
  68. anchors.right: parent.right
  69. anchors.rightMargin: Theme.getSize("default_margin").width
  70. width: Theme.getSize("standard_arrow").width
  71. height: Theme.getSize("standard_arrow").height
  72. sourceSize.width: width
  73. sourceSize.height: width
  74. color: control.enabled ? Theme.getColor("setting_category_text") : Theme.getColor("setting_category_disabled_text")
  75. source: Theme.getIcon("arrow_bottom")
  76. }
  77. Label
  78. {
  79. id: sidebarComboBoxLabel
  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: Item
  101. {
  102. implicitHeight: control.height
  103. implicitWidth: buttonWidth
  104. Rectangle
  105. {
  106. id: buttonFace
  107. implicitHeight: parent.height
  108. implicitWidth: parent.width
  109. radius: UM.Theme.getSize("action_button_radius").width
  110. color:
  111. {
  112. if (control.checked)
  113. {
  114. return UM.Theme.getColor("main_window_header_button_background_active")
  115. }
  116. else
  117. {
  118. if (control.hovered)
  119. {
  120. return UM.Theme.getColor("main_window_header_button_background_hovered")
  121. }
  122. return UM.Theme.getColor("main_window_header_button_background_inactive")
  123. }
  124. }
  125. }
  126. }
  127. label: Item
  128. {
  129. id: contents
  130. anchors.horizontalCenter: parent.horizontalCenter
  131. anchors.verticalCenter: parent.verticalCenter
  132. height: control.height
  133. width: buttonLabel.width + 4 * UM.Theme.getSize("default_margin").width
  134. Label
  135. {
  136. id: buttonLabel
  137. text: control.text
  138. anchors.verticalCenter: parent.verticalCenter
  139. anchors.horizontalCenter: parent.horizontalCenter
  140. font: UM.Theme.getFont("medium_bold")
  141. color:
  142. {
  143. if (control.checked)
  144. {
  145. return UM.Theme.getColor("main_window_header_button_text_active")
  146. }
  147. else
  148. {
  149. if (control.hovered)
  150. {
  151. return UM.Theme.getColor("main_window_header_button_text_hovered")
  152. }
  153. return UM.Theme.getColor("main_window_header_button_text_inactive")
  154. }
  155. }
  156. }
  157. Component.onCompleted:
  158. {
  159. buttonWidth = width
  160. }
  161. }
  162. }
  163. }
  164. property Component tool_button: Component
  165. {
  166. ButtonStyle
  167. {
  168. background: Item
  169. {
  170. implicitWidth: Theme.getSize("button").width;
  171. implicitHeight: Theme.getSize("button").height;
  172. UM.PointingRectangle
  173. {
  174. id: button_tooltip
  175. anchors.left: parent.right
  176. anchors.leftMargin: Theme.getSize("button_tooltip_arrow").width * 2
  177. anchors.verticalCenter: parent.verticalCenter
  178. target: Qt.point(parent.x, y + Math.round(height/2))
  179. arrowSize: Theme.getSize("button_tooltip_arrow").width
  180. color: Theme.getColor("button_tooltip")
  181. opacity: control.hovered ? 1.0 : 0.0;
  182. visible: control.text != ""
  183. width: control.hovered ? button_tip.width + Theme.getSize("button_tooltip").width : 0
  184. height: Theme.getSize("button_tooltip").height
  185. Behavior on width { NumberAnimation { duration: 100; } }
  186. Behavior on opacity { NumberAnimation { duration: 100; } }
  187. Label
  188. {
  189. id: button_tip
  190. anchors.horizontalCenter: parent.horizontalCenter
  191. anchors.verticalCenter: parent.verticalCenter;
  192. text: control.text;
  193. font: Theme.getFont("button_tooltip");
  194. color: Theme.getColor("tooltip_text");
  195. }
  196. }
  197. Rectangle
  198. {
  199. id: buttonFace;
  200. anchors.fill: parent;
  201. property bool down: control.pressed || (control.checkable && control.checked);
  202. color:
  203. {
  204. if(control.customColor !== undefined && control.customColor !== null)
  205. {
  206. return control.customColor
  207. }
  208. else if(control.checkable && control.checked && control.hovered)
  209. {
  210. return Theme.getColor("button_active_hover");
  211. }
  212. else if(control.pressed || (control.checkable && control.checked))
  213. {
  214. return Theme.getColor("button_active");
  215. }
  216. else if(control.hovered)
  217. {
  218. return Theme.getColor("button_hover");
  219. }
  220. else
  221. {
  222. return Theme.getColor("button");
  223. }
  224. }
  225. Behavior on color { ColorAnimation { duration: 50; } }
  226. border.width: (control.hasOwnProperty("needBorder") && control.needBorder) ? 2 * screenScaleFactor : 0
  227. border.color: Theme.getColor("tool_button_border")
  228. UM.RecolorImage
  229. {
  230. id: tool_button_arrow
  231. anchors.right: parent.right;
  232. anchors.rightMargin: Theme.getSize("button").width - Math.round(Theme.getSize("button_icon").width / 4)
  233. anchors.bottom: parent.bottom;
  234. anchors.bottomMargin: Theme.getSize("button").height - Math.round(Theme.getSize("button_icon").height / 4)
  235. width: Theme.getSize("standard_arrow").width
  236. height: Theme.getSize("standard_arrow").height
  237. sourceSize.width: width
  238. sourceSize.height: width
  239. visible: control.menu != null;
  240. color:
  241. {
  242. if(control.checkable && control.checked && control.hovered)
  243. {
  244. return Theme.getColor("button_text_active_hover");
  245. }
  246. else if(control.pressed || (control.checkable && control.checked))
  247. {
  248. return Theme.getColor("button_text_active");
  249. }
  250. else if(control.hovered)
  251. {
  252. return Theme.getColor("button_text_hover");
  253. }
  254. else
  255. {
  256. return Theme.getColor("button_text");
  257. }
  258. }
  259. source: Theme.getIcon("arrow_bottom")
  260. }
  261. }
  262. }
  263. label: Item
  264. {
  265. UM.RecolorImage
  266. {
  267. anchors.centerIn: parent;
  268. opacity: !control.enabled ? 0.2 : 1.0
  269. source: control.iconSource;
  270. width: Theme.getSize("button_icon").width;
  271. height: Theme.getSize("button_icon").height;
  272. color:
  273. {
  274. if(control.checkable && control.checked && control.hovered)
  275. {
  276. return Theme.getColor("button_text_active_hover");
  277. }
  278. else if(control.pressed || (control.checkable && control.checked))
  279. {
  280. return Theme.getColor("button_text_active");
  281. }
  282. else if(control.hovered)
  283. {
  284. return Theme.getColor("button_text_hover");
  285. }
  286. else
  287. {
  288. return Theme.getColor("button_text");
  289. }
  290. }
  291. sourceSize: Theme.getSize("button_icon")
  292. }
  293. }
  294. }
  295. }
  296. property Component progressbar: Component
  297. {
  298. ProgressBarStyle
  299. {
  300. background: Rectangle
  301. {
  302. implicitWidth: Theme.getSize("message").width - (Theme.getSize("default_margin").width * 2)
  303. implicitHeight: Theme.getSize("progressbar").height
  304. color: control.hasOwnProperty("backgroundColor") ? control.backgroundColor : Theme.getColor("progressbar_background")
  305. radius: Theme.getSize("progressbar_radius").width
  306. }
  307. progress: Rectangle
  308. {
  309. color:
  310. {
  311. if(control.indeterminate)
  312. {
  313. return "transparent";
  314. }
  315. else if(control.hasOwnProperty("controlColor"))
  316. {
  317. return control.controlColor;
  318. }
  319. else
  320. {
  321. return Theme.getColor("progressbar_control");
  322. }
  323. }
  324. radius: Theme.getSize("progressbar_radius").width
  325. Rectangle
  326. {
  327. radius: Theme.getSize("progressbar_radius").width
  328. color: control.hasOwnProperty("controlColor") ? control.controlColor : Theme.getColor("progressbar_control")
  329. width: Theme.getSize("progressbar_control").width
  330. height: Theme.getSize("progressbar_control").height
  331. visible: control.indeterminate
  332. SequentialAnimation on x
  333. {
  334. id: xAnim
  335. property int animEndPoint: Theme.getSize("message").width - Math.round((Theme.getSize("default_margin").width * 2.5)) - Theme.getSize("progressbar_control").width
  336. running: control.indeterminate && control.visible
  337. loops: Animation.Infinite
  338. NumberAnimation { from: 0; to: xAnim.animEndPoint; duration: 2000;}
  339. NumberAnimation { from: xAnim.animEndPoint; to: 0; duration: 2000;}
  340. }
  341. }
  342. }
  343. }
  344. }
  345. property Component scrollview: Component
  346. {
  347. ScrollViewStyle
  348. {
  349. decrementControl: Item { }
  350. incrementControl: Item { }
  351. transientScrollBars: false
  352. scrollBarBackground: Rectangle
  353. {
  354. implicitWidth: Theme.getSize("scrollbar").width
  355. radius: Math.round(implicitWidth / 2)
  356. color: Theme.getColor("scrollbar_background");
  357. }
  358. handle: Rectangle
  359. {
  360. id: scrollViewHandle
  361. implicitWidth: Theme.getSize("scrollbar").width;
  362. radius: Math.round(implicitWidth / 2)
  363. color: styleData.pressed ? Theme.getColor("scrollbar_handle_down") : styleData.hovered ? Theme.getColor("scrollbar_handle_hover") : Theme.getColor("scrollbar_handle");
  364. Behavior on color { ColorAnimation { duration: 50; } }
  365. }
  366. }
  367. }
  368. property Component combobox: Component
  369. {
  370. ComboBoxStyle
  371. {
  372. background: Rectangle
  373. {
  374. implicitHeight: Theme.getSize("setting_control").height;
  375. implicitWidth: Theme.getSize("setting_control").width;
  376. color: control.hovered ? UM.Theme.getColor("setting_control_highlight") : UM.Theme.getColor("setting_control")
  377. Behavior on color { ColorAnimation { duration: 50; } }
  378. border.width: Theme.getSize("default_lining").width;
  379. border.color: control.hovered ? Theme.getColor("setting_control_border_highlight") : Theme.getColor("setting_control_border");
  380. }
  381. label: Item
  382. {
  383. Label
  384. {
  385. anchors.left: parent.left
  386. anchors.leftMargin: Theme.getSize("default_lining").width
  387. anchors.right: downArrow.left
  388. anchors.rightMargin: Theme.getSize("default_lining").width
  389. anchors.verticalCenter: parent.verticalCenter
  390. text: control.currentText
  391. font: Theme.getFont("default");
  392. color: !enabled ? Theme.getColor("setting_control_disabled_text") : Theme.getColor("setting_control_text")
  393. elide: Text.ElideRight
  394. verticalAlignment: Text.AlignVCenter
  395. }
  396. UM.RecolorImage
  397. {
  398. id: downArrow
  399. anchors.right: parent.right
  400. anchors.rightMargin: Theme.getSize("default_lining").width * 2
  401. anchors.verticalCenter: parent.verticalCenter
  402. source: Theme.getIcon("arrow_bottom")
  403. width: Theme.getSize("standard_arrow").width
  404. height: Theme.getSize("standard_arrow").height
  405. sourceSize.width: width + 5 * screenScaleFactor
  406. sourceSize.height: width + 5 * screenScaleFactor
  407. color: Theme.getColor("setting_control_text");
  408. }
  409. }
  410. }
  411. }
  412. // Combobox with items with colored rectangles
  413. property Component combobox_color: Component
  414. {
  415. ComboBoxStyle
  416. {
  417. background: Rectangle
  418. {
  419. color: !enabled ? UM.Theme.getColor("setting_control_disabled") : control._hovered ? UM.Theme.getColor("setting_control_highlight") : UM.Theme.getColor("setting_control")
  420. border.width: UM.Theme.getSize("default_lining").width
  421. 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")
  422. }
  423. label: Item
  424. {
  425. Label
  426. {
  427. anchors.left: parent.left
  428. anchors.leftMargin: UM.Theme.getSize("default_lining").width
  429. anchors.right: swatch.left
  430. anchors.rightMargin: UM.Theme.getSize("default_lining").width
  431. anchors.verticalCenter: parent.verticalCenter
  432. text: control.currentText
  433. font: UM.Theme.getFont("default")
  434. color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text")
  435. elide: Text.ElideRight
  436. verticalAlignment: Text.AlignVCenter
  437. }
  438. Rectangle
  439. {
  440. id: swatch
  441. height: Math.round(UM.Theme.getSize("setting_control").height / 2)
  442. width: height
  443. anchors.right: downArrow.left
  444. anchors.verticalCenter: parent.verticalCenter
  445. anchors.margins: Math.round(UM.Theme.getSize("default_margin").width / 4)
  446. radius: Math.round(width / 2)
  447. border.width: UM.Theme.getSize("default_lining").width
  448. border.color: UM.Theme.getColor("lining")
  449. color: (control.color_override !== "") ? control.color_override : control.color
  450. }
  451. UM.RecolorImage
  452. {
  453. id: downArrow
  454. anchors.right: parent.right
  455. anchors.rightMargin: UM.Theme.getSize("default_lining").width * 2
  456. anchors.verticalCenter: parent.verticalCenter
  457. source: UM.Theme.getIcon("arrow_bottom")
  458. width: UM.Theme.getSize("standard_arrow").width
  459. height: UM.Theme.getSize("standard_arrow").height
  460. sourceSize.width: width + 5 * screenScaleFactor
  461. sourceSize.height: width + 5 * screenScaleFactor
  462. color: UM.Theme.getColor("setting_control_text")
  463. }
  464. }
  465. }
  466. }
  467. property Component checkbox: Component
  468. {
  469. CheckBoxStyle
  470. {
  471. background: Item { }
  472. indicator: Rectangle
  473. {
  474. implicitWidth: Theme.getSize("checkbox").width
  475. implicitHeight: Theme.getSize("checkbox").height
  476. color: (control.hovered || control._hovered) ? Theme.getColor("checkbox_hover") : Theme.getColor("checkbox")
  477. Behavior on color { ColorAnimation { duration: 50; } }
  478. radius: control.exclusiveGroup ? Math.round(Theme.getSize("checkbox").width / 2) : UM.Theme.getSize("checkbox_radius").width
  479. border.width: Theme.getSize("default_lining").width
  480. border.color: (control.hovered || control._hovered) ? Theme.getColor("checkbox_border_hover") : Theme.getColor("checkbox_border")
  481. UM.RecolorImage
  482. {
  483. anchors.verticalCenter: parent.verticalCenter
  484. anchors.horizontalCenter: parent.horizontalCenter
  485. width: Math.round(parent.width / 2.5)
  486. height: Math.round(parent.height / 2.5)
  487. sourceSize.width: width
  488. sourceSize.height: width
  489. color: Theme.getColor("checkbox_mark")
  490. source: control.exclusiveGroup ? Theme.getIcon("dot") : Theme.getIcon("check")
  491. opacity: control.checked
  492. Behavior on opacity { NumberAnimation { duration: 100; } }
  493. }
  494. }
  495. label: Label
  496. {
  497. text: control.text
  498. color: Theme.getColor("checkbox_text")
  499. font: Theme.getFont("default")
  500. elide: Text.ElideRight
  501. renderType: Text.NativeRendering
  502. }
  503. }
  504. }
  505. property Component partially_checkbox: Component
  506. {
  507. CheckBoxStyle
  508. {
  509. background: Item { }
  510. indicator: Rectangle
  511. {
  512. implicitWidth: Theme.getSize("checkbox").width
  513. implicitHeight: Theme.getSize("checkbox").height
  514. color: (control.hovered || control._hovered) ? Theme.getColor("checkbox_hover") : Theme.getColor("checkbox");
  515. Behavior on color { ColorAnimation { duration: 50; } }
  516. radius: control.exclusiveGroup ? Math.round(Theme.getSize("checkbox").width / 2) : 0
  517. border.width: Theme.getSize("default_lining").width;
  518. border.color: (control.hovered || control._hovered) ? Theme.getColor("checkbox_border_hover") : Theme.getColor("checkbox_border");
  519. UM.RecolorImage
  520. {
  521. anchors.verticalCenter: parent.verticalCenter
  522. anchors.horizontalCenter: parent.horizontalCenter
  523. width: Math.round(parent.width / 2.5)
  524. height: Math.round(parent.height / 2.5)
  525. sourceSize.width: width
  526. sourceSize.height: width
  527. color: Theme.getColor("checkbox_mark")
  528. source:
  529. {
  530. if (control.checkbox_state == 2)
  531. {
  532. return Theme.getIcon("solid");
  533. }
  534. else
  535. {
  536. return control.exclusiveGroup ? Theme.getIcon("dot") : Theme.getIcon("check");
  537. }
  538. }
  539. opacity: control.checked
  540. Behavior on opacity { NumberAnimation { duration: 100; } }
  541. }
  542. }
  543. label: Label
  544. {
  545. text: control.text
  546. color: Theme.getColor("checkbox_text")
  547. font: Theme.getFont("default")
  548. }
  549. }
  550. }
  551. property Component text_field: Component
  552. {
  553. TextFieldStyle
  554. {
  555. textColor: Theme.getColor("setting_control_text")
  556. placeholderTextColor: Theme.getColor("setting_control_text")
  557. font: Theme.getFont("default")
  558. background: Rectangle
  559. {
  560. implicitHeight: control.height;
  561. implicitWidth: control.width;
  562. border.width: Theme.getSize("default_lining").width;
  563. border.color: control.hovered ? Theme.getColor("setting_control_border_highlight") : Theme.getColor("setting_control_border");
  564. color: Theme.getColor("setting_validation_ok");
  565. Label
  566. {
  567. anchors.right: parent.right;
  568. anchors.rightMargin: Theme.getSize("setting_unit_margin").width;
  569. anchors.verticalCenter: parent.verticalCenter;
  570. text: control.unit ? control.unit : ""
  571. color: Theme.getColor("setting_unit");
  572. font: Theme.getFont("default");
  573. }
  574. }
  575. }
  576. }
  577. property Component sidebar_action_button: Component
  578. {
  579. ButtonStyle
  580. {
  581. background: Rectangle
  582. {
  583. border.width: UM.Theme.getSize("default_lining").width
  584. border.color:
  585. {
  586. if(!control.enabled)
  587. {
  588. return UM.Theme.getColor("action_button_disabled_border");
  589. }
  590. else if(control.pressed)
  591. {
  592. return UM.Theme.getColor("action_button_active_border");
  593. }
  594. else if(control.hovered)
  595. {
  596. return UM.Theme.getColor("action_button_hovered_border");
  597. }
  598. else
  599. {
  600. return UM.Theme.getColor("action_button_border");
  601. }
  602. }
  603. color:
  604. {
  605. if(!control.enabled)
  606. {
  607. return UM.Theme.getColor("action_button_disabled");
  608. }
  609. else if(control.pressed)
  610. {
  611. return UM.Theme.getColor("action_button_active");
  612. }
  613. else if(control.hovered)
  614. {
  615. return UM.Theme.getColor("action_button_hovered");
  616. }
  617. else
  618. {
  619. return UM.Theme.getColor("action_button");
  620. }
  621. }
  622. Behavior on color { ColorAnimation { duration: 50 } }
  623. implicitWidth: actualLabel.contentWidth + (UM.Theme.getSize("thick_margin").width * 2)
  624. Label
  625. {
  626. id: actualLabel
  627. anchors.centerIn: parent
  628. color:
  629. {
  630. if(!control.enabled)
  631. {
  632. return UM.Theme.getColor("action_button_disabled_text");
  633. }
  634. else if(control.pressed)
  635. {
  636. return UM.Theme.getColor("action_button_active_text");
  637. }
  638. else if(control.hovered)
  639. {
  640. return UM.Theme.getColor("action_button_hovered_text");
  641. }
  642. else
  643. {
  644. return UM.Theme.getColor("action_button_text");
  645. }
  646. }
  647. font: UM.Theme.getFont("action_button")
  648. text: control.text
  649. }
  650. }
  651. label: Item { }
  652. }
  653. }
  654. }