MonitorButton.qml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. // Copyright (c) 2016 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.1 as UM
  8. import Cura 1.0 as Cura
  9. Rectangle
  10. {
  11. id: base;
  12. UM.I18nCatalog { id: catalog; name:"cura"}
  13. property real progress: Cura.MachineManager.printerOutputDevices[0].progress;
  14. property int backendState: UM.Backend.state;
  15. property bool activity: Printer.getPlatformActivity;
  16. property int totalHeight: childrenRect.height + UM.Theme.getSize("default_margin").height
  17. property string fileBaseName
  18. property string statusText:
  19. {
  20. return "Printing..."
  21. }
  22. Label
  23. {
  24. id: statusLabel
  25. width: parent.width - 2 * UM.Theme.getSize("default_margin").width
  26. anchors.top: parent.top
  27. anchors.left: parent.left
  28. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  29. color: "green"
  30. font: UM.Theme.getFont("large")
  31. text: statusText;
  32. }
  33. Rectangle
  34. {
  35. id: progressBar
  36. width: parent.width - 2 * UM.Theme.getSize("default_margin").width
  37. height: UM.Theme.getSize("progressbar").height
  38. anchors.top: statusLabel.bottom
  39. anchors.topMargin: UM.Theme.getSize("default_margin").height / 4
  40. anchors.left: parent.left
  41. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  42. radius: UM.Theme.getSize("progressbar_radius").width
  43. color: UM.Theme.getColor("progressbar_background")
  44. Rectangle
  45. {
  46. width: Math.max(parent.width * base.progress)
  47. height: parent.height
  48. color: "green"
  49. radius: UM.Theme.getSize("progressbar_radius").width
  50. //visible: base.backendState == 2 ? true : false
  51. }
  52. }
  53. Button
  54. {
  55. id: abortButton
  56. enabled: true
  57. height: UM.Theme.getSize("save_button_save_to_button").height
  58. anchors.top: progressBar.bottom
  59. anchors.topMargin: UM.Theme.getSize("default_margin").height
  60. anchors.right: parent.right
  61. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  62. text: catalog.i18nc("@label:", "Abort Job")
  63. onClicked: {}
  64. style: ButtonStyle
  65. {
  66. background: Rectangle
  67. {
  68. border.width: UM.Theme.getSize("default_lining").width
  69. border.color: !control.enabled ? UM.Theme.getColor("action_button_disabled_border") :
  70. control.pressed ? UM.Theme.getColor("action_button_active_border") :
  71. control.hovered ? UM.Theme.getColor("action_button_hovered_border") : UM.Theme.getColor("action_button_border")
  72. color: !control.enabled ? UM.Theme.getColor("action_button_disabled") :
  73. control.pressed ? UM.Theme.getColor("action_button_active") :
  74. control.hovered ? UM.Theme.getColor("action_button_hovered") : UM.Theme.getColor("action_button")
  75. Behavior on color { ColorAnimation { duration: 50; } }
  76. implicitWidth: actualLabel.contentWidth + (UM.Theme.getSize("default_margin").width * 2)
  77. Label
  78. {
  79. id: actualLabel
  80. anchors.centerIn: parent
  81. color: !control.enabled ? UM.Theme.getColor("action_button_disabled_text") :
  82. control.pressed ? UM.Theme.getColor("action_button_active_text") :
  83. control.hovered ? UM.Theme.getColor("action_button_hovered_text") : UM.Theme.getColor("action_button_text")
  84. font: UM.Theme.getFont("action_button")
  85. text: control.text;
  86. }
  87. }
  88. label: Item { }
  89. }
  90. }
  91. Button
  92. {
  93. id: pauseButton
  94. height: UM.Theme.getSize("save_button_save_to_button").height
  95. anchors.top: progressBar.bottom
  96. anchors.topMargin: UM.Theme.getSize("default_margin").height
  97. anchors.right: abortButton.left
  98. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  99. text: Cura.MachineManager.printerOutputDevices[0].jobState == "paused" ? catalog.i18nc("@label:", "Resume") : catalog.i18nc("@label:", "Pause")
  100. onClicked: { Cura.MachineManager.printerOutputDevices[0].setJobState("printing")}
  101. style: ButtonStyle
  102. {
  103. background: Rectangle
  104. {
  105. border.width: UM.Theme.getSize("default_lining").width
  106. border.color: !control.enabled ? UM.Theme.getColor("action_button_disabled_border") :
  107. control.pressed ? UM.Theme.getColor("action_button_active_border") :
  108. control.hovered ? UM.Theme.getColor("action_button_hovered_border") : UM.Theme.getColor("action_button_border")
  109. color: !control.enabled ? UM.Theme.getColor("action_button_disabled") :
  110. control.pressed ? UM.Theme.getColor("action_button_active") :
  111. control.hovered ? UM.Theme.getColor("action_button_hovered") : UM.Theme.getColor("action_button")
  112. Behavior on color { ColorAnimation { duration: 50; } }
  113. implicitWidth: actualLabel.contentWidth + (UM.Theme.getSize("default_margin").width * 2)
  114. Label
  115. {
  116. id: actualLabel
  117. anchors.centerIn: parent
  118. color: !control.enabled ? UM.Theme.getColor("action_button_disabled_text") :
  119. control.pressed ? UM.Theme.getColor("action_button_active_text") :
  120. control.hovered ? UM.Theme.getColor("action_button_hovered_text") : UM.Theme.getColor("action_button_text")
  121. font: UM.Theme.getFont("action_button")
  122. text: control.text;
  123. }
  124. }
  125. label: Item { }
  126. }
  127. }
  128. Rectangle
  129. {
  130. id: saveRow
  131. width: base.width
  132. height: saveToButton.height
  133. anchors.top: progressBar.bottom
  134. anchors.topMargin: UM.Theme.getSize("default_margin").height
  135. anchors.left: parent.left
  136. }
  137. }