styles.qml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. // Copyright (c) 2021 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 UM.Theme.getColor("setting_validation_error_background");
  22. }
  23. else if(control.valueWarning)
  24. {
  25. return UM.Theme.getColor("setting_validation_warning_background");
  26. }
  27. else
  28. {
  29. return UM.Theme.getColor("setting_control");
  30. }
  31. }
  32. else
  33. {
  34. return UM.Theme.getColor("setting_control_disabled");
  35. }
  36. }
  37. radius: UM.Theme.getSize("setting_control_radius").width
  38. border.width: UM.Theme.getSize("default_lining").width
  39. border.color:
  40. {
  41. if (control.enabled)
  42. {
  43. if (control.valueError)
  44. {
  45. return UM.Theme.getColor("setting_validation_error");
  46. }
  47. else if (control.valueWarning)
  48. {
  49. return UM.Theme.getColor("setting_validation_warning");
  50. }
  51. else if (control.hovered)
  52. {
  53. return UM.Theme.getColor("setting_control_border_highlight");
  54. }
  55. else
  56. {
  57. return UM.Theme.getColor("setting_control_border");
  58. }
  59. }
  60. else
  61. {
  62. return UM.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: UM.Theme.getSize("default_margin").width
  71. width: UM.Theme.getSize("standard_arrow").width
  72. height: UM.Theme.getSize("standard_arrow").height
  73. sourceSize.height: width
  74. color: control.enabled ? UM.Theme.getColor("setting_control_button") : UM.Theme.getColor("setting_category_disabled_text")
  75. source: UM.Theme.getIcon("ChevronSingleDown")
  76. }
  77. Label
  78. {
  79. id: printSetupComboBoxLabel
  80. color: control.enabled ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text")
  81. text: control.text;
  82. elide: Text.ElideRight;
  83. anchors.left: parent.left;
  84. anchors.leftMargin: UM.Theme.getSize("setting_unit_margin").width
  85. anchors.right: downArrow.left;
  86. anchors.rightMargin: control.rightMargin;
  87. anchors.verticalCenter: parent.verticalCenter;
  88. font: UM.Theme.getFont("default")
  89. }
  90. }
  91. label: Label{}
  92. }
  93. }
  94. property Component tool_button: Component
  95. {
  96. ButtonStyle
  97. {
  98. background: Item
  99. {
  100. implicitWidth: UM.Theme.getSize("button").width
  101. implicitHeight: UM.Theme.getSize("button").height
  102. UM.PointingRectangle
  103. {
  104. id: button_tooltip
  105. anchors.left: parent.right
  106. anchors.leftMargin: UM.Theme.getSize("button_tooltip_arrow").width * 2
  107. anchors.verticalCenter: parent.verticalCenter
  108. target: Qt.point(parent.x, y + Math.round(height/2))
  109. arrowSize: UM.Theme.getSize("button_tooltip_arrow").width
  110. color: UM.Theme.getColor("button_tooltip")
  111. opacity: control.hovered ? 1.0 : 0.0;
  112. visible: control.text != ""
  113. width: control.hovered ? button_tip.width + UM.Theme.getSize("button_tooltip").width : 0
  114. height: UM.Theme.getSize("button_tooltip").height
  115. Behavior on width { NumberAnimation { duration: 100; } }
  116. Behavior on opacity { NumberAnimation { duration: 100; } }
  117. Label
  118. {
  119. id: button_tip
  120. anchors.horizontalCenter: parent.horizontalCenter
  121. anchors.verticalCenter: parent.verticalCenter
  122. text: control.text
  123. font: UM.Theme.getFont("default")
  124. color: UM.Theme.getColor("tooltip_text")
  125. }
  126. }
  127. Rectangle
  128. {
  129. id: buttonFace
  130. anchors.fill: parent
  131. property bool down: control.pressed || (control.checkable && control.checked)
  132. color:
  133. {
  134. if(control.customColor !== undefined && control.customColor !== null)
  135. {
  136. return control.customColor
  137. }
  138. else if(control.checkable && control.checked && control.hovered)
  139. {
  140. return UM.Theme.getColor("toolbar_button_active_hover")
  141. }
  142. else if(control.pressed || (control.checkable && control.checked))
  143. {
  144. return UM.Theme.getColor("toolbar_button_active")
  145. }
  146. else if(control.hovered)
  147. {
  148. return UM.Theme.getColor("toolbar_button_hover")
  149. }
  150. return UM.Theme.getColor("toolbar_background")
  151. }
  152. Behavior on color { ColorAnimation { duration: 50; } }
  153. border.width: (control.hasOwnProperty("needBorder") && control.needBorder) ? UM.Theme.getSize("default_lining").width : 0
  154. border.color: control.checked ? UM.Theme.getColor("icon") : UM.Theme.getColor("lining")
  155. }
  156. }
  157. label: Item
  158. {
  159. UM.RecolorImage
  160. {
  161. anchors.centerIn: parent
  162. opacity: control.enabled ? 1.0 : 0.2
  163. source: control.iconSource
  164. width: UM.Theme.getSize("medium_button_icon").width
  165. height: UM.Theme.getSize("medium_button_icon").height
  166. color: UM.Theme.getColor("icon")
  167. sourceSize: UM.Theme.getSize("medium_button_icon")
  168. }
  169. }
  170. }
  171. }
  172. property Component progressbar: Component
  173. {
  174. ProgressBarStyle
  175. {
  176. background: Rectangle
  177. {
  178. implicitWidth: UM.Theme.getSize("message").width - (UM.Theme.getSize("default_margin").width * 2)
  179. implicitHeight: UM.Theme.getSize("progressbar").height
  180. color: control.hasOwnProperty("backgroundColor") ? control.backgroundColor : UM.Theme.getColor("progressbar_background")
  181. radius: UM.Theme.getSize("progressbar_radius").width
  182. }
  183. progress: Rectangle
  184. {
  185. color:
  186. {
  187. if(control.indeterminate)
  188. {
  189. return "transparent";
  190. }
  191. else if(control.hasOwnProperty("controlColor"))
  192. {
  193. return control.controlColor;
  194. }
  195. else
  196. {
  197. return UM.Theme.getColor("progressbar_control");
  198. }
  199. }
  200. radius: UM.Theme.getSize("progressbar_radius").width
  201. Rectangle
  202. {
  203. radius: UM.Theme.getSize("progressbar_radius").width
  204. color: control.hasOwnProperty("controlColor") ? control.controlColor : UM.Theme.getColor("progressbar_control")
  205. width: UM.Theme.getSize("progressbar_control").width
  206. height: UM.Theme.getSize("progressbar_control").height
  207. visible: control.indeterminate
  208. SequentialAnimation on x
  209. {
  210. id: xAnim
  211. property int animEndPoint: UM.Theme.getSize("message").width - Math.round((UM.Theme.getSize("default_margin").width * 2.5)) - UM.Theme.getSize("progressbar_control").width
  212. running: control.indeterminate && control.visible
  213. loops: Animation.Infinite
  214. NumberAnimation { from: 0; to: xAnim.animEndPoint; duration: 2000;}
  215. NumberAnimation { from: xAnim.animEndPoint; to: 0; duration: 2000;}
  216. }
  217. }
  218. }
  219. }
  220. }
  221. property Component scrollview: Component
  222. {
  223. ScrollViewStyle
  224. {
  225. decrementControl: Item { }
  226. incrementControl: Item { }
  227. transientScrollBars: false
  228. scrollBarBackground: Rectangle
  229. {
  230. implicitWidth: UM.Theme.getSize("scrollbar").width
  231. radius: Math.round(implicitWidth / 2)
  232. color: UM.Theme.getColor("scrollbar_background")
  233. }
  234. handle: Rectangle
  235. {
  236. id: scrollViewHandle
  237. implicitWidth: UM.Theme.getSize("scrollbar").width
  238. radius: Math.round(implicitWidth / 2)
  239. color: styleData.pressed ? UM.Theme.getColor("scrollbar_handle_down") : styleData.hovered ? UM.Theme.getColor("scrollbar_handle_hover") : UM.Theme.getColor("scrollbar_handle")
  240. Behavior on color { ColorAnimation { duration: 50; } }
  241. }
  242. }
  243. }
  244. property Component combobox: Component
  245. {
  246. ComboBoxStyle
  247. {
  248. background: Rectangle
  249. {
  250. implicitHeight: UM.Theme.getSize("setting_control").height;
  251. implicitWidth: UM.Theme.getSize("setting_control").width;
  252. color: control.hovered ? UM.Theme.getColor("setting_control_highlight") : UM.Theme.getColor("setting_control")
  253. Behavior on color { ColorAnimation { duration: 50; } }
  254. border.width: UM.Theme.getSize("default_lining").width;
  255. border.color: control.hovered ? UM.Theme.getColor("setting_control_border_highlight") : UM.Theme.getColor("setting_control_border");
  256. radius: UM.Theme.getSize("setting_control_radius").width
  257. }
  258. label: Item
  259. {
  260. Label
  261. {
  262. anchors.left: parent.left
  263. anchors.leftMargin: UM.Theme.getSize("default_lining").width
  264. anchors.right: downArrow.left
  265. anchors.rightMargin: UM.Theme.getSize("default_lining").width
  266. anchors.verticalCenter: parent.verticalCenter
  267. text: control.currentText
  268. font: UM.Theme.getFont("default");
  269. color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text")
  270. elide: Text.ElideRight
  271. verticalAlignment: Text.AlignVCenter
  272. }
  273. UM.RecolorImage
  274. {
  275. id: downArrow
  276. anchors.right: parent.right
  277. anchors.rightMargin: UM.Theme.getSize("default_lining").width * 2
  278. anchors.verticalCenter: parent.verticalCenter
  279. source: UM.Theme.getIcon("ChevronSingleDown")
  280. width: UM.Theme.getSize("standard_arrow").width
  281. height: UM.Theme.getSize("standard_arrow").height
  282. sourceSize.width: width + 5 * screenScaleFactor
  283. sourceSize.height: width + 5 * screenScaleFactor
  284. color: UM.Theme.getColor("setting_control_button");
  285. }
  286. }
  287. }
  288. }
  289. property Component partially_checkbox: Component
  290. {
  291. CheckBoxStyle
  292. {
  293. background: Item { }
  294. indicator: Rectangle
  295. {
  296. implicitWidth: UM.Theme.getSize("checkbox").width
  297. implicitHeight: UM.Theme.getSize("checkbox").height
  298. color: (control.hovered || control._hovered) ? UM.Theme.getColor("checkbox_hover") : UM.Theme.getColor("checkbox");
  299. Behavior on color { ColorAnimation { duration: 50; } }
  300. radius: control.exclusiveGroup ? Math.round(UM.Theme.getSize("checkbox").width / 2) : UM.Theme.getSize("checkbox_radius").width
  301. border.width: UM.Theme.getSize("default_lining").width;
  302. border.color: (control.hovered || control._hovered) ? UM.Theme.getColor("checkbox_border_hover") : UM.Theme.getColor("checkbox_border");
  303. UM.RecolorImage
  304. {
  305. anchors.verticalCenter: parent.verticalCenter
  306. anchors.horizontalCenter: parent.horizontalCenter
  307. width: Math.round(parent.width / 2.5)
  308. height: Math.round(parent.height / 2.5)
  309. sourceSize.height: width
  310. color: UM.Theme.getColor("checkbox_mark")
  311. source:
  312. {
  313. if (control.checkbox_state == 2)
  314. {
  315. return UM.Theme.getIcon("Solid");
  316. }
  317. else
  318. {
  319. return control.exclusiveGroup ? UM.Theme.getIcon("Dot", "low") : UM.Theme.getIcon("Check");
  320. }
  321. }
  322. opacity: control.checked
  323. Behavior on opacity { NumberAnimation { duration: 100; } }
  324. }
  325. }
  326. label: Label
  327. {
  328. text: control.text
  329. color: UM.Theme.getColor("checkbox_text")
  330. font: UM.Theme.getFont("default")
  331. }
  332. }
  333. }
  334. property Component print_setup_action_button: Component
  335. {
  336. ButtonStyle
  337. {
  338. background: Rectangle
  339. {
  340. border.width: UM.Theme.getSize("default_lining").width
  341. border.color:
  342. {
  343. if(!control.enabled)
  344. {
  345. return UM.Theme.getColor("action_button_disabled_border");
  346. }
  347. else if(control.pressed)
  348. {
  349. return UM.Theme.getColor("action_button_active_border");
  350. }
  351. else if(control.hovered)
  352. {
  353. return UM.Theme.getColor("action_button_hovered_border");
  354. }
  355. else
  356. {
  357. return UM.Theme.getColor("action_button_border");
  358. }
  359. }
  360. color:
  361. {
  362. if(!control.enabled)
  363. {
  364. return UM.Theme.getColor("action_button_disabled");
  365. }
  366. else if(control.pressed)
  367. {
  368. return UM.Theme.getColor("action_button_active");
  369. }
  370. else if(control.hovered)
  371. {
  372. return UM.Theme.getColor("action_button_hovered");
  373. }
  374. else
  375. {
  376. return UM.Theme.getColor("action_button");
  377. }
  378. }
  379. Behavior on color { ColorAnimation { duration: 50 } }
  380. implicitWidth: actualLabel.contentWidth + (UM.Theme.getSize("thick_margin").width * 2)
  381. Label
  382. {
  383. id: actualLabel
  384. anchors.centerIn: parent
  385. color:
  386. {
  387. if(!control.enabled)
  388. {
  389. return UM.Theme.getColor("action_button_disabled_text");
  390. }
  391. else if(control.pressed)
  392. {
  393. return UM.Theme.getColor("action_button_active_text");
  394. }
  395. else if(control.hovered)
  396. {
  397. return UM.Theme.getColor("action_button_hovered_text");
  398. }
  399. else
  400. {
  401. return UM.Theme.getColor("action_button_text");
  402. }
  403. }
  404. font: UM.Theme.getFont("medium")
  405. text: control.text
  406. }
  407. }
  408. label: Item { }
  409. }
  410. }
  411. property Component monitor_button_style: Component
  412. {
  413. ButtonStyle
  414. {
  415. background: Rectangle
  416. {
  417. border.width: UM.Theme.getSize("default_lining").width
  418. border.color:
  419. {
  420. if(!control.enabled)
  421. {
  422. return UM.Theme.getColor("action_button_disabled_border");
  423. }
  424. else if(control.pressed)
  425. {
  426. return UM.Theme.getColor("action_button_active_border");
  427. }
  428. else if(control.hovered)
  429. {
  430. return UM.Theme.getColor("action_button_hovered_border");
  431. }
  432. return UM.Theme.getColor("action_button_border");
  433. }
  434. color:
  435. {
  436. if(!control.enabled)
  437. {
  438. return UM.Theme.getColor("action_button_disabled");
  439. }
  440. else if(control.pressed)
  441. {
  442. return UM.Theme.getColor("action_button_active");
  443. }
  444. else if(control.hovered)
  445. {
  446. return UM.Theme.getColor("action_button_hovered");
  447. }
  448. return UM.Theme.getColor("action_button");
  449. }
  450. Behavior on color
  451. {
  452. ColorAnimation
  453. {
  454. duration: 50
  455. }
  456. }
  457. }
  458. label: Item
  459. {
  460. UM.RecolorImage
  461. {
  462. anchors.verticalCenter: parent.verticalCenter
  463. anchors.horizontalCenter: parent.horizontalCenter
  464. width: Math.floor(control.width / 2)
  465. height: Math.floor(control.height / 2)
  466. sourceSize.height: width
  467. color:
  468. {
  469. if(!control.enabled)
  470. {
  471. return UM.Theme.getColor("action_button_disabled_text");
  472. }
  473. else if(control.pressed)
  474. {
  475. return UM.Theme.getColor("action_button_active_text");
  476. }
  477. else if(control.hovered)
  478. {
  479. return UM.Theme.getColor("action_button_hovered_text");
  480. }
  481. return UM.Theme.getColor("action_button_text");
  482. }
  483. source: control.iconSource
  484. }
  485. }
  486. }
  487. }
  488. property Component monitor_checkable_button_style: Component
  489. {
  490. ButtonStyle {
  491. background: Rectangle {
  492. border.width: control.checked ? UM.Theme.getSize("default_lining").width * 2 : UM.Theme.getSize("default_lining").width
  493. border.color:
  494. {
  495. if(!control.enabled)
  496. {
  497. return UM.Theme.getColor("action_button_disabled_border");
  498. }
  499. else if (control.checked || control.pressed)
  500. {
  501. return UM.Theme.getColor("action_button_active_border");
  502. }
  503. else if(control.hovered)
  504. {
  505. return UM.Theme.getColor("action_button_hovered_border");
  506. }
  507. return UM.Theme.getColor("action_button_border");
  508. }
  509. color:
  510. {
  511. if(!control.enabled)
  512. {
  513. return UM.Theme.getColor("action_button_disabled");
  514. }
  515. else if (control.checked || control.pressed)
  516. {
  517. return UM.Theme.getColor("action_button_active");
  518. }
  519. else if (control.hovered)
  520. {
  521. return UM.Theme.getColor("action_button_hovered");
  522. }
  523. return UM.Theme.getColor("action_button");
  524. }
  525. Behavior on color { ColorAnimation { duration: 50; } }
  526. Label {
  527. anchors.left: parent.left
  528. anchors.right: parent.right
  529. anchors.verticalCenter: parent.verticalCenter
  530. anchors.leftMargin: UM.Theme.getSize("default_lining").width * 2
  531. anchors.rightMargin: UM.Theme.getSize("default_lining").width * 2
  532. color:
  533. {
  534. if(!control.enabled)
  535. {
  536. return UM.Theme.getColor("action_button_disabled_text");
  537. }
  538. else if (control.checked || control.pressed)
  539. {
  540. return UM.Theme.getColor("action_button_active_text");
  541. }
  542. else if (control.hovered)
  543. {
  544. return UM.Theme.getColor("action_button_hovered_text");
  545. }
  546. return UM.Theme.getColor("action_button_text");
  547. }
  548. font: UM.Theme.getFont("default")
  549. text: control.text
  550. horizontalAlignment: Text.AlignHCenter
  551. elide: Text.ElideMiddle
  552. }
  553. }
  554. label: Item { }
  555. }
  556. }
  557. }