Topbar.qml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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", "Monitor")
  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_reversed");
  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 "pausing":
  104. case "resuming":
  105. return UM.Theme.getIcon("tab_status_busy");
  106. case "wait_cleanup":
  107. return UM.Theme.getIcon("tab_status_finished");
  108. case "ready":
  109. case "":
  110. return UM.Theme.getIcon("tab_status_connected")
  111. case "paused":
  112. return UM.Theme.getIcon("tab_status_paused")
  113. case "error":
  114. return UM.Theme.getIcon("tab_status_stopped")
  115. default:
  116. return ""
  117. }
  118. }
  119. checkable: true
  120. checked: base.monitoringPrint
  121. exclusiveGroup: sidebarHeaderBarGroup
  122. style: UM.Theme.styles.topbar_header_tab
  123. }
  124. ExclusiveGroup { id: sidebarHeaderBarGroup }
  125. }
  126. ToolButton
  127. {
  128. id: machineSelection
  129. text: Cura.MachineManager.activeMachineName
  130. width: UM.Theme.getSize("sidebar").width;
  131. height: UM.Theme.getSize("sidebar_header").height
  132. tooltip: Cura.MachineManager.activeMachineName
  133. anchors.verticalCenter: parent.verticalCenter
  134. anchors.right: parent.right
  135. style: ButtonStyle
  136. {
  137. background: Rectangle
  138. {
  139. color:
  140. {
  141. if(control.pressed)
  142. {
  143. return UM.Theme.getColor("sidebar_header_active");
  144. } else if(control.hovered)
  145. {
  146. return UM.Theme.getColor("sidebar_header_hover");
  147. } else
  148. {
  149. return UM.Theme.getColor("sidebar_header_bar");
  150. }
  151. }
  152. Behavior on color { ColorAnimation { duration: 50; } }
  153. Rectangle
  154. {
  155. id: underline;
  156. anchors.left: parent.left
  157. anchors.right: parent.right
  158. anchors.bottom: parent.bottom
  159. height: UM.Theme.getSize("sidebar_header_highlight").height
  160. color: UM.Theme.getColor("sidebar_header_highlight_hover")
  161. visible: control.hovered || control.pressed
  162. }
  163. UM.RecolorImage
  164. {
  165. id: downArrow
  166. anchors.verticalCenter: parent.verticalCenter
  167. anchors.right: parent.right
  168. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  169. width: UM.Theme.getSize("standard_arrow").width
  170. height: UM.Theme.getSize("standard_arrow").height
  171. sourceSize.width: width
  172. sourceSize.height: width
  173. color: UM.Theme.getColor("text_emphasis")
  174. source: UM.Theme.getIcon("arrow_bottom")
  175. }
  176. Label
  177. {
  178. id: sidebarComboBoxLabel
  179. color: UM.Theme.getColor("sidebar_header_text_active")
  180. text: control.text;
  181. elide: Text.ElideRight;
  182. anchors.left: parent.left;
  183. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  184. anchors.right: downArrow.left;
  185. anchors.rightMargin: control.rightMargin;
  186. anchors.verticalCenter: parent.verticalCenter;
  187. font: UM.Theme.getFont("large")
  188. }
  189. }
  190. label: Label {}
  191. }
  192. menu: PrinterMenu { }
  193. }
  194. }