styles.qml 28 KB

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