Topbar.qml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. // Copyright (c) 2017 Ultimaker B.V.
  2. // Cura is released under the terms of the AGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 1.1
  5. import QtQuick.Controls.Styles 1.1
  6. import QtQuick.Layouts 1.1
  7. import UM 1.2 as UM
  8. import Cura 1.0 as Cura
  9. import "Menus"
  10. Rectangle
  11. {
  12. id: base
  13. anchors.left: parent.left
  14. anchors.right: parent.right
  15. height: UM.Theme.getSize("sidebar_header").height
  16. color: UM.Theme.getColor("sidebar_header_bar")
  17. property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0
  18. property bool printerAcceptsCommands: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands
  19. property bool monitoringPrint: false
  20. signal startMonitoringPrint()
  21. signal stopMonitoringPrint()
  22. UM.I18nCatalog
  23. {
  24. id: catalog
  25. name:"cura"
  26. }
  27. Row
  28. {
  29. anchors.left: parent.left
  30. anchors.right: machineSelection.left
  31. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  32. spacing: UM.Theme.getSize("default_margin").width
  33. Button
  34. {
  35. id: showSettings
  36. height: UM.Theme.getSize("sidebar_header").height
  37. onClicked: base.stopMonitoringPrint()
  38. iconSource: UM.Theme.getIcon("tab_settings");
  39. property color overlayColor: "transparent"
  40. property string overlayIconSource: ""
  41. text: catalog.i18nc("@title:tab", "Prepare")
  42. checkable: true
  43. checked: !base.monitoringPrint
  44. exclusiveGroup: sidebarHeaderBarGroup
  45. style: UM.Theme.styles.topbar_header_tab
  46. }
  47. Button
  48. {
  49. id: showMonitor
  50. height: UM.Theme.getSize("sidebar_header").height
  51. onClicked: base.startMonitoringPrint()
  52. text: catalog.i18nc("@title:tab", "Print")
  53. iconSource: UM.Theme.getIcon("tab_monitor")
  54. property color overlayColor:
  55. {
  56. if(!printerAcceptsCommands)
  57. {
  58. return UM.Theme.getColor("status_unknown");
  59. }
  60. if(Cura.MachineManager.printerOutputDevices[0].printerState == "maintenance")
  61. {
  62. return UM.Theme.getColor("status_busy");
  63. }
  64. switch(Cura.MachineManager.printerOutputDevices[0].jobState)
  65. {
  66. case "printing":
  67. case "pre_print":
  68. case "wait_cleanup":
  69. case "pausing":
  70. case "resuming":
  71. return UM.Theme.getColor("status_busy");
  72. case "ready":
  73. case "":
  74. return UM.Theme.getColor("status_ready");
  75. case "paused":
  76. return UM.Theme.getColor("status_paused");
  77. case "error":
  78. return UM.Theme.getColor("status_stopped");
  79. case "offline":
  80. return UM.Theme.getColor("status_offline");
  81. default:
  82. return UM.Theme.getColor("text_emphasis");
  83. }
  84. }
  85. property string overlayIconSource:
  86. {
  87. if(!printerConnected)
  88. {
  89. return "";
  90. }
  91. else if(!printerAcceptsCommands)
  92. {
  93. return UM.Theme.getIcon("tab_status_unknown");
  94. }
  95. if(Cura.MachineManager.printerOutputDevices[0].printerState == "maintenance")
  96. {
  97. return UM.Theme.getIcon("tab_status_busy");
  98. }
  99. switch(Cura.MachineManager.printerOutputDevices[0].jobState)
  100. {
  101. case "printing":
  102. case "pre_print":
  103. case "wait_cleanup":
  104. case "pausing":
  105. case "resuming":
  106. return UM.Theme.getIcon("tab_status_busy");
  107. case "ready":
  108. case "":
  109. return UM.Theme.getIcon("tab_status_connected")
  110. case "paused":
  111. return UM.Theme.getIcon("tab_status_paused")
  112. case "error":
  113. return UM.Theme.getIcon("tab_status_stopped")
  114. case "offline":
  115. return UM.Theme.getIcon("tab_status_offline")
  116. default:
  117. return ""
  118. }
  119. }
  120. checkable: true
  121. checked: base.monitoringPrint
  122. exclusiveGroup: sidebarHeaderBarGroup
  123. style: UM.Theme.styles.topbar_header_tab
  124. }
  125. ExclusiveGroup { id: sidebarHeaderBarGroup }
  126. }
  127. ToolButton
  128. {
  129. id: machineSelection
  130. text: Cura.MachineManager.activeMachineName
  131. width: UM.Theme.getSize("sidebar").width;
  132. height: UM.Theme.getSize("sidebar_header").height
  133. tooltip: Cura.MachineManager.activeMachineName
  134. anchors.verticalCenter: parent.verticalCenter
  135. anchors.right: parent.right
  136. style: ButtonStyle
  137. {
  138. background: Rectangle
  139. {
  140. color:
  141. {
  142. if(control.pressed)
  143. {
  144. return UM.Theme.getColor("sidebar_header_active");
  145. } else if(control.hovered)
  146. {
  147. return UM.Theme.getColor("sidebar_header_hover");
  148. } else
  149. {
  150. return UM.Theme.getColor("sidebar_header_bar");
  151. }
  152. }
  153. Behavior on color { ColorAnimation { duration: 50; } }
  154. Rectangle
  155. {
  156. id: underline;
  157. anchors.left: parent.left
  158. anchors.right: parent.right
  159. anchors.bottom: parent.bottom
  160. height: UM.Theme.getSize("sidebar_header_highlight").height
  161. color: UM.Theme.getColor("sidebar_header_highlight_hover")
  162. visible: control.hovered || control.pressed
  163. }
  164. UM.RecolorImage
  165. {
  166. id: downArrow
  167. anchors.verticalCenter: parent.verticalCenter
  168. anchors.right: parent.right
  169. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  170. width: UM.Theme.getSize("standard_arrow").width
  171. height: UM.Theme.getSize("standard_arrow").height
  172. sourceSize.width: width
  173. sourceSize.height: width
  174. color: UM.Theme.getColor("text_emphasis")
  175. source: UM.Theme.getIcon("arrow_bottom")
  176. }
  177. Label
  178. {
  179. id: sidebarComboBoxLabel
  180. color: UM.Theme.getColor("sidebar_header_text_active")
  181. text: control.text;
  182. elide: Text.ElideRight;
  183. anchors.left: parent.left;
  184. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  185. anchors.right: downArrow.left;
  186. anchors.rightMargin: control.rightMargin;
  187. anchors.verticalCenter: parent.verticalCenter;
  188. font: UM.Theme.getFont("large")
  189. }
  190. }
  191. label: Label {}
  192. }
  193. menu: PrinterMenu { }
  194. }
  195. }