styles.qml 45 KB

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