styles.qml 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128
  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. Behavior on color { ColorAnimation { duration: 50 } }
  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 small_tool_button: Component
  298. {
  299. ButtonStyle
  300. {
  301. background: Item
  302. {
  303. implicitWidth: Theme.getSize("small_button").width;
  304. implicitHeight: Theme.getSize("small_button").height;
  305. Rectangle
  306. {
  307. id: smallButtonFace;
  308. anchors.fill: parent;
  309. property bool down: control.pressed || (control.checkable && control.checked);
  310. color:
  311. {
  312. if(control.customColor !== undefined && control.customColor !== null)
  313. {
  314. return control.customColor
  315. }
  316. else if(control.checkable && control.checked && control.hovered)
  317. {
  318. return Theme.getColor("small_button_active_hover");
  319. }
  320. else if(control.pressed || (control.checkable && control.checked))
  321. {
  322. return Theme.getColor("small_button_active");
  323. }
  324. else if(control.hovered)
  325. {
  326. return Theme.getColor("small_button_hover");
  327. }
  328. else
  329. {
  330. return Theme.getColor("small_button");
  331. }
  332. }
  333. Behavior on color { ColorAnimation { duration: 50; } }
  334. border.width: (control.hasOwnProperty("needBorder") && control.needBorder) ? 2 * screenScaleFactor : 0
  335. border.color: Theme.getColor("tool_button_border")
  336. UM.RecolorImage
  337. {
  338. id: smallToolButtonArrow
  339. width: 5
  340. height: 5
  341. sourceSize.width: 5
  342. sourceSize.height: 5
  343. visible: control.menu != null;
  344. color:
  345. {
  346. if(control.checkable && control.checked && control.hovered)
  347. {
  348. return Theme.getColor("small_button_text_active_hover");
  349. }
  350. else if(control.pressed || (control.checkable && control.checked))
  351. {
  352. return Theme.getColor("small_button_text_active");
  353. }
  354. else if(control.hovered)
  355. {
  356. return Theme.getColor("small_button_text_hover");
  357. }
  358. else
  359. {
  360. return Theme.getColor("small_button_text");
  361. }
  362. }
  363. source: Theme.getIcon("arrow_bottom")
  364. }
  365. }
  366. }
  367. label: Item
  368. {
  369. UM.RecolorImage
  370. {
  371. anchors.centerIn: parent
  372. opacity: !control.enabled ? 0.2 : 1.0
  373. source: control.iconSource;
  374. width: Theme.getSize("small_button_icon").width
  375. height: Theme.getSize("small_button_icon").height
  376. color:
  377. {
  378. if(control.checkable && control.checked && control.hovered)
  379. {
  380. return Theme.getColor("small_button_text_active_hover");
  381. }
  382. else if(control.pressed || (control.checkable && control.checked))
  383. {
  384. return Theme.getColor("small_button_text_active");
  385. }
  386. else if(control.hovered)
  387. {
  388. return Theme.getColor("small_button_text_hover");
  389. }
  390. else
  391. {
  392. return Theme.getColor("small_button_text");
  393. }
  394. }
  395. sourceSize: Theme.getSize("small_button_icon")
  396. }
  397. }
  398. }
  399. }
  400. property Component progressbar: Component
  401. {
  402. ProgressBarStyle
  403. {
  404. background: Rectangle
  405. {
  406. implicitWidth: Theme.getSize("message").width - (Theme.getSize("default_margin").width * 2)
  407. implicitHeight: Theme.getSize("progressbar").height
  408. color: control.hasOwnProperty("backgroundColor") ? control.backgroundColor : Theme.getColor("progressbar_background")
  409. }
  410. progress: Rectangle
  411. {
  412. color:
  413. {
  414. if(control.indeterminate)
  415. {
  416. return "transparent";
  417. }
  418. else if(control.hasOwnProperty("controlColor"))
  419. {
  420. return control.controlColor;
  421. }
  422. else
  423. {
  424. return Theme.getColor("progressbar_control");
  425. }
  426. }
  427. radius: Theme.getSize("progressbar_radius").width
  428. Rectangle
  429. {
  430. radius: Theme.getSize("progressbar_radius").width
  431. color: control.hasOwnProperty("controlColor") ? control.controlColor : Theme.getColor("progressbar_control")
  432. width: Theme.getSize("progressbar_control").width
  433. height: Theme.getSize("progressbar_control").height
  434. visible: control.indeterminate
  435. SequentialAnimation on x
  436. {
  437. id: xAnim
  438. property int animEndPoint: Theme.getSize("message").width - Math.round((Theme.getSize("default_margin").width * 2.5)) - Theme.getSize("progressbar_control").width
  439. running: control.indeterminate && control.visible
  440. loops: Animation.Infinite
  441. NumberAnimation { from: 0; to: xAnim.animEndPoint; duration: 2000;}
  442. NumberAnimation { from: xAnim.animEndPoint; to: 0; duration: 2000;}
  443. }
  444. }
  445. }
  446. }
  447. }
  448. property Component sidebar_category: Component
  449. {
  450. ButtonStyle
  451. {
  452. background: Rectangle
  453. {
  454. anchors.fill: parent
  455. anchors.left: parent.left
  456. anchors.leftMargin: Theme.getSize("thick_margin").width
  457. anchors.right: parent.right
  458. anchors.rightMargin: Theme.getSize("thick_margin").width
  459. implicitHeight: Theme.getSize("section").height
  460. color:
  461. {
  462. if(control.color)
  463. {
  464. return control.color;
  465. }
  466. else if(!control.enabled)
  467. {
  468. return Theme.getColor("setting_category_disabled");
  469. }
  470. else if(control.hovered && control.checkable && control.checked)
  471. {
  472. return Theme.getColor("setting_category_active_hover");
  473. }
  474. else if(control.pressed || (control.checkable && control.checked))
  475. {
  476. return Theme.getColor("setting_category_active");
  477. }
  478. else if(control.hovered)
  479. {
  480. return Theme.getColor("setting_category_hover");
  481. }
  482. else
  483. {
  484. return Theme.getColor("setting_category");
  485. }
  486. }
  487. Behavior on color { ColorAnimation { duration: 50; } }
  488. Rectangle
  489. {
  490. height: Theme.getSize("default_lining").height
  491. width: parent.width
  492. anchors.bottom: parent.bottom
  493. color:
  494. {
  495. if(!control.enabled)
  496. {
  497. return Theme.getColor("setting_category_disabled_border");
  498. }
  499. else if((control.hovered || control.activeFocus) && control.checkable && control.checked)
  500. {
  501. return Theme.getColor("setting_category_active_hover_border");
  502. }
  503. else if(control.pressed || (control.checkable && control.checked))
  504. {
  505. return Theme.getColor("setting_category_active_border");
  506. }
  507. else if(control.hovered || control.activeFocus)
  508. {
  509. return Theme.getColor("setting_category_hover_border");
  510. }
  511. else
  512. {
  513. return Theme.getColor("setting_category_border");
  514. }
  515. }
  516. }
  517. }
  518. label: Item
  519. {
  520. anchors.fill: parent
  521. anchors.left: parent.left
  522. Item
  523. {
  524. id: icon
  525. anchors.left: parent.left
  526. height: parent.height
  527. width: Theme.getSize("section_icon_column").width
  528. UM.RecolorImage
  529. {
  530. anchors.verticalCenter: parent.verticalCenter
  531. anchors.left: parent.left
  532. anchors.leftMargin: Theme.getSize("thick_margin").width
  533. color:
  534. {
  535. if(!control.enabled)
  536. {
  537. return Theme.getColor("setting_category_disabled_text");
  538. }
  539. else if((control.hovered || control.activeFocus) && control.checkable && control.checked)
  540. {
  541. return Theme.getColor("setting_category_active_hover_text");
  542. }
  543. else if(control.pressed || (control.checkable && control.checked))
  544. {
  545. return Theme.getColor("setting_category_active_text");
  546. }
  547. else if(control.hovered || control.activeFocus)
  548. {
  549. return Theme.getColor("setting_category_hover_text");
  550. }
  551. else
  552. {
  553. return Theme.getColor("setting_category_text");
  554. }
  555. }
  556. source: control.iconSource;
  557. width: Theme.getSize("section_icon").width;
  558. height: Theme.getSize("section_icon").height;
  559. sourceSize.width: width + 15 * screenScaleFactor
  560. sourceSize.height: width + 15 * screenScaleFactor
  561. }
  562. }
  563. Label
  564. {
  565. anchors
  566. {
  567. left: icon.right
  568. leftMargin: Theme.getSize("default_margin").width
  569. right: parent.right
  570. verticalCenter: parent.verticalCenter
  571. }
  572. text: control.text
  573. font: Theme.getFont("setting_category")
  574. color:
  575. {
  576. if(!control.enabled)
  577. {
  578. return Theme.getColor("setting_category_disabled_text");
  579. }
  580. else if((control.hovered || control.activeFocus) && control.checkable && control.checked)
  581. {
  582. return Theme.getColor("setting_category_active_hover_text");
  583. }
  584. else if(control.pressed || (control.checkable && control.checked))
  585. {
  586. return Theme.getColor("setting_category_active_text");
  587. }
  588. else if(control.hovered || control.activeFocus)
  589. {
  590. return Theme.getColor("setting_category_hover_text");
  591. }
  592. else
  593. {
  594. return Theme.getColor("setting_category_text");
  595. }
  596. }
  597. fontSizeMode: Text.HorizontalFit
  598. minimumPointSize: 8
  599. }
  600. UM.RecolorImage
  601. {
  602. id: category_arrow
  603. anchors.verticalCenter: parent.verticalCenter
  604. anchors.right: parent.right
  605. anchors.rightMargin: Theme.getSize("default_margin").width * 3 - Math.round(width / 2)
  606. width: Theme.getSize("standard_arrow").width
  607. height: Theme.getSize("standard_arrow").height
  608. sourceSize.width: width
  609. sourceSize.height: width
  610. color:
  611. {
  612. if(!control.enabled)
  613. {
  614. return Theme.getColor("setting_category_disabled_text");
  615. }
  616. else if((control.hovered || control.activeFocus) && control.checkable && control.checked)
  617. {
  618. return Theme.getColor("setting_category_active_hover_text");
  619. }
  620. else if(control.pressed || (control.checkable && control.checked))
  621. {
  622. return Theme.getColor("setting_category_active_text");
  623. }
  624. else if(control.hovered || control.activeFocus)
  625. {
  626. return Theme.getColor("setting_category_hover_text");
  627. }
  628. else
  629. {
  630. return Theme.getColor("setting_category_text");
  631. }
  632. }
  633. source: control.checked ? Theme.getIcon("arrow_bottom") : Theme.getIcon("arrow_left")
  634. }
  635. }
  636. }
  637. }
  638. property Component scrollview: Component
  639. {
  640. ScrollViewStyle
  641. {
  642. decrementControl: Item { }
  643. incrementControl: Item { }
  644. transientScrollBars: false
  645. scrollBarBackground: Rectangle
  646. {
  647. implicitWidth: Theme.getSize("scrollbar").width
  648. radius: Math.round(implicitWidth / 2)
  649. color: Theme.getColor("scrollbar_background");
  650. }
  651. handle: Rectangle
  652. {
  653. id: scrollViewHandle
  654. implicitWidth: Theme.getSize("scrollbar").width;
  655. radius: Math.round(implicitWidth / 2)
  656. color: styleData.pressed ? Theme.getColor("scrollbar_handle_down") : styleData.hovered ? Theme.getColor("scrollbar_handle_hover") : Theme.getColor("scrollbar_handle");
  657. Behavior on color { ColorAnimation { duration: 50; } }
  658. }
  659. }
  660. }
  661. property Component combobox: Component
  662. {
  663. ComboBoxStyle
  664. {
  665. background: Rectangle
  666. {
  667. implicitHeight: Theme.getSize("setting_control").height;
  668. implicitWidth: Theme.getSize("setting_control").width;
  669. color: control.hovered ? UM.Theme.getColor("setting_control_highlight") : UM.Theme.getColor("setting_control")
  670. Behavior on color { ColorAnimation { duration: 50; } }
  671. border.width: Theme.getSize("default_lining").width;
  672. border.color: control.hovered ? Theme.getColor("setting_control_border_highlight") : Theme.getColor("setting_control_border");
  673. }
  674. label: Item
  675. {
  676. Label
  677. {
  678. anchors.left: parent.left
  679. anchors.leftMargin: Theme.getSize("default_lining").width
  680. anchors.right: downArrow.left
  681. anchors.rightMargin: Theme.getSize("default_lining").width
  682. anchors.verticalCenter: parent.verticalCenter
  683. text: control.currentText
  684. font: Theme.getFont("default");
  685. color: !enabled ? Theme.getColor("setting_control_disabled_text") : Theme.getColor("setting_control_text")
  686. elide: Text.ElideRight
  687. verticalAlignment: Text.AlignVCenter
  688. }
  689. UM.RecolorImage
  690. {
  691. id: downArrow
  692. anchors.right: parent.right
  693. anchors.rightMargin: Theme.getSize("default_lining").width * 2
  694. anchors.verticalCenter: parent.verticalCenter
  695. source: Theme.getIcon("arrow_bottom")
  696. width: Theme.getSize("standard_arrow").width
  697. height: Theme.getSize("standard_arrow").height
  698. sourceSize.width: width + 5 * screenScaleFactor
  699. sourceSize.height: width + 5 * screenScaleFactor
  700. color: Theme.getColor("setting_control_text");
  701. }
  702. }
  703. }
  704. }
  705. // Combobox with items with colored rectangles
  706. property Component combobox_color: Component
  707. {
  708. ComboBoxStyle
  709. {
  710. background: Rectangle
  711. {
  712. color: !enabled ? UM.Theme.getColor("setting_control_disabled") : control._hovered ? UM.Theme.getColor("setting_control_highlight") : UM.Theme.getColor("setting_control")
  713. border.width: UM.Theme.getSize("default_lining").width
  714. 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")
  715. }
  716. label: Item
  717. {
  718. Label
  719. {
  720. anchors.left: parent.left
  721. anchors.leftMargin: UM.Theme.getSize("default_lining").width
  722. anchors.right: swatch.left
  723. anchors.rightMargin: UM.Theme.getSize("default_lining").width
  724. anchors.verticalCenter: parent.verticalCenter
  725. text: control.currentText
  726. font: UM.Theme.getFont("default")
  727. color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text")
  728. elide: Text.ElideRight
  729. verticalAlignment: Text.AlignVCenter
  730. }
  731. Rectangle
  732. {
  733. id: swatch
  734. height: Math.round(UM.Theme.getSize("setting_control").height / 2)
  735. width: height
  736. anchors.right: downArrow.left
  737. anchors.verticalCenter: parent.verticalCenter
  738. anchors.margins: Math.round(UM.Theme.getSize("default_margin").width / 4)
  739. radius: Math.round(width / 2)
  740. border.width: UM.Theme.getSize("default_lining").width
  741. border.color: UM.Theme.getColor("lining")
  742. color: (control.color_override !== "") ? control.color_override : control.color
  743. }
  744. UM.RecolorImage
  745. {
  746. id: downArrow
  747. anchors.right: parent.right
  748. anchors.rightMargin: UM.Theme.getSize("default_lining").width * 2
  749. anchors.verticalCenter: parent.verticalCenter
  750. source: UM.Theme.getIcon("arrow_bottom")
  751. width: UM.Theme.getSize("standard_arrow").width
  752. height: UM.Theme.getSize("standard_arrow").height
  753. sourceSize.width: width + 5 * screenScaleFactor
  754. sourceSize.height: width + 5 * screenScaleFactor
  755. color: UM.Theme.getColor("setting_control_text")
  756. }
  757. }
  758. }
  759. }
  760. property Component checkbox: Component
  761. {
  762. CheckBoxStyle
  763. {
  764. background: Item { }
  765. indicator: Rectangle
  766. {
  767. implicitWidth: Theme.getSize("checkbox").width
  768. implicitHeight: Theme.getSize("checkbox").height
  769. color: (control.hovered || control._hovered) ? Theme.getColor("checkbox_hover") : Theme.getColor("checkbox")
  770. Behavior on color { ColorAnimation { duration: 50; } }
  771. radius: control.exclusiveGroup ? Math.round(Theme.getSize("checkbox").width / 2) : 0
  772. border.width: Theme.getSize("default_lining").width
  773. border.color: (control.hovered || control._hovered) ? Theme.getColor("checkbox_border_hover") : Theme.getColor("checkbox_border")
  774. UM.RecolorImage
  775. {
  776. anchors.verticalCenter: parent.verticalCenter
  777. anchors.horizontalCenter: parent.horizontalCenter
  778. width: Math.round(parent.width / 2.5)
  779. height: Math.round(parent.height / 2.5)
  780. sourceSize.width: width
  781. sourceSize.height: width
  782. color: Theme.getColor("checkbox_mark")
  783. source: control.exclusiveGroup ? Theme.getIcon("dot") : Theme.getIcon("check")
  784. opacity: control.checked
  785. Behavior on opacity { NumberAnimation { duration: 100; } }
  786. }
  787. }
  788. label: Label
  789. {
  790. text: control.text
  791. color: Theme.getColor("checkbox_text")
  792. font: Theme.getFont("default")
  793. elide: Text.ElideRight
  794. }
  795. }
  796. }
  797. property Component partially_checkbox: Component
  798. {
  799. CheckBoxStyle
  800. {
  801. background: Item { }
  802. indicator: Rectangle
  803. {
  804. implicitWidth: Theme.getSize("checkbox").width
  805. implicitHeight: Theme.getSize("checkbox").height
  806. color: (control.hovered || control._hovered) ? Theme.getColor("checkbox_hover") : Theme.getColor("checkbox");
  807. Behavior on color { ColorAnimation { duration: 50; } }
  808. radius: control.exclusiveGroup ? Math.round(Theme.getSize("checkbox").width / 2) : 0
  809. border.width: Theme.getSize("default_lining").width;
  810. border.color: (control.hovered || control._hovered) ? Theme.getColor("checkbox_border_hover") : Theme.getColor("checkbox_border");
  811. UM.RecolorImage
  812. {
  813. anchors.verticalCenter: parent.verticalCenter
  814. anchors.horizontalCenter: parent.horizontalCenter
  815. width: Math.round(parent.width / 2.5)
  816. height: Math.round(parent.height / 2.5)
  817. sourceSize.width: width
  818. sourceSize.height: width
  819. color: Theme.getColor("checkbox_mark")
  820. source:
  821. {
  822. if (control.checkbox_state == 2)
  823. {
  824. return Theme.getIcon("solid");
  825. }
  826. else
  827. {
  828. return control.exclusiveGroup ? Theme.getIcon("dot") : Theme.getIcon("check");
  829. }
  830. }
  831. opacity: control.checked
  832. Behavior on opacity { NumberAnimation { duration: 100; } }
  833. }
  834. }
  835. label: Label
  836. {
  837. text: control.text
  838. color: Theme.getColor("checkbox_text")
  839. font: Theme.getFont("default")
  840. }
  841. }
  842. }
  843. property Component slider: Component
  844. {
  845. SliderStyle
  846. {
  847. groove: Rectangle
  848. {
  849. implicitWidth: control.width
  850. implicitHeight: Theme.getSize("slider_groove").height
  851. color: Theme.getColor("slider_groove")
  852. border.width: Theme.getSize("default_lining").width
  853. border.color: Theme.getColor("slider_groove_border")
  854. radius: Math.round(width / 2)
  855. Rectangle
  856. {
  857. anchors
  858. {
  859. left: parent.left
  860. top: parent.top
  861. bottom: parent.bottom
  862. }
  863. color: Theme.getColor("slider_groove_fill");
  864. width: Math.round((control.value / (control.maximumValue - control.minimumValue)) * parent.width);
  865. radius: Math.round(width / 2);
  866. }
  867. }
  868. handle: Rectangle
  869. {
  870. width: Theme.getSize("slider_handle").width;
  871. height: Theme.getSize("slider_handle").height;
  872. color: control.hovered ? Theme.getColor("slider_handle_hover") : Theme.getColor("slider_handle");
  873. border.width: Theme.getSize("default_lining").width
  874. border.color: control.hovered ? Theme.getColor("slider_handle_hover_border") : Theme.getColor("slider_handle_border")
  875. radius: Math.round(Theme.getSize("slider_handle").width / 2); //Round.
  876. Behavior on color { ColorAnimation { duration: 50; } }
  877. }
  878. }
  879. }
  880. property Component text_field: Component
  881. {
  882. TextFieldStyle
  883. {
  884. textColor: Theme.getColor("setting_control_text")
  885. placeholderTextColor: Theme.getColor("setting_control_text")
  886. font: Theme.getFont("default")
  887. background: Rectangle
  888. {
  889. implicitHeight: control.height;
  890. implicitWidth: control.width;
  891. border.width: Theme.getSize("default_lining").width;
  892. border.color: control.hovered ? Theme.getColor("setting_control_border_highlight") : Theme.getColor("setting_control_border");
  893. color: Theme.getColor("setting_validation_ok");
  894. Label
  895. {
  896. anchors.right: parent.right;
  897. anchors.rightMargin: Theme.getSize("setting_unit_margin").width;
  898. anchors.verticalCenter: parent.verticalCenter;
  899. text: control.unit ? control.unit : ""
  900. color: Theme.getColor("setting_unit");
  901. font: Theme.getFont("default");
  902. }
  903. }
  904. }
  905. }
  906. property Component sidebar_action_button: Component
  907. {
  908. ButtonStyle
  909. {
  910. background: Rectangle
  911. {
  912. border.width: UM.Theme.getSize("default_lining").width
  913. border.color:
  914. {
  915. if(!control.enabled)
  916. {
  917. return UM.Theme.getColor("action_button_disabled_border");
  918. }
  919. else if(control.pressed)
  920. {
  921. return UM.Theme.getColor("action_button_active_border");
  922. }
  923. else if(control.hovered)
  924. {
  925. return UM.Theme.getColor("action_button_hovered_border");
  926. }
  927. else
  928. {
  929. return UM.Theme.getColor("action_button_border");
  930. }
  931. }
  932. color:
  933. {
  934. if(!control.enabled)
  935. {
  936. return UM.Theme.getColor("action_button_disabled");
  937. }
  938. else if(control.pressed)
  939. {
  940. return UM.Theme.getColor("action_button_active");
  941. }
  942. else if(control.hovered)
  943. {
  944. return UM.Theme.getColor("action_button_hovered");
  945. }
  946. else
  947. {
  948. return UM.Theme.getColor("action_button");
  949. }
  950. }
  951. Behavior on color { ColorAnimation { duration: 50 } }
  952. implicitWidth: actualLabel.contentWidth + (UM.Theme.getSize("thick_margin").width * 2)
  953. Label
  954. {
  955. id: actualLabel
  956. anchors.centerIn: parent
  957. color:
  958. {
  959. if(!control.enabled)
  960. {
  961. return UM.Theme.getColor("action_button_disabled_text");
  962. }
  963. else if(control.pressed)
  964. {
  965. return UM.Theme.getColor("action_button_active_text");
  966. }
  967. else if(control.hovered)
  968. {
  969. return UM.Theme.getColor("action_button_hovered_text");
  970. }
  971. else
  972. {
  973. return UM.Theme.getColor("action_button_text");
  974. }
  975. }
  976. font: UM.Theme.getFont("action_button")
  977. text: control.text
  978. }
  979. }
  980. label: Item { }
  981. }
  982. }
  983. property Component toolbox_action_button: Component
  984. {
  985. ButtonStyle
  986. {
  987. background: Rectangle
  988. {
  989. implicitWidth: UM.Theme.getSize("toolbox_action_button").width
  990. implicitHeight: UM.Theme.getSize("toolbox_action_button").height
  991. color:
  992. {
  993. if (control.installed)
  994. {
  995. return UM.Theme.getColor("action_button_disabled");
  996. }
  997. else
  998. {
  999. if (control.hovered)
  1000. {
  1001. return UM.Theme.getColor("primary_hover");
  1002. }
  1003. else
  1004. {
  1005. return UM.Theme.getColor("primary");
  1006. }
  1007. }
  1008. }
  1009. }
  1010. label: Label
  1011. {
  1012. text: control.text
  1013. color:
  1014. {
  1015. if (control.installed)
  1016. {
  1017. return UM.Theme.getColor("action_button_disabled_text");
  1018. }
  1019. else
  1020. {
  1021. if (control.hovered)
  1022. {
  1023. return UM.Theme.getColor("button_text_hover");
  1024. }
  1025. else
  1026. {
  1027. return UM.Theme.getColor("button_text");
  1028. }
  1029. }
  1030. }
  1031. verticalAlignment: Text.AlignVCenter
  1032. horizontalAlignment: Text.AlignHCenter
  1033. font: UM.Theme.getFont("default_bold")
  1034. }
  1035. }
  1036. }
  1037. }