SaveButton.qml 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. // Copyright (c) 2015 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. Rectangle {
  9. id: base;
  10. UM.I18nCatalog { id: catalog; name:"cura"}
  11. property real progress: UM.Backend.progress;
  12. property int backendState: UM.Backend.state;
  13. property bool activity: Printer.getPlatformActivity;
  14. //Behavior on progress { NumberAnimation { duration: 250; } }
  15. property int totalHeight: childrenRect.height + UM.Theme.getSize("default_margin").height
  16. property string fileBaseName
  17. property string statusText:
  18. {
  19. if(!activity)
  20. {
  21. return catalog.i18nc("@label:PrintjobStatus", "Please load a 3d model");
  22. }
  23. if(base.backendState == 1)
  24. {
  25. return catalog.i18nc("@label:PrintjobStatus", "Preparing to slice...");
  26. }
  27. else if(base.backendState == 2)
  28. {
  29. return catalog.i18nc("@label:PrintjobStatus", "Slicing...");
  30. }
  31. else if(base.backendState == 3)
  32. {
  33. return catalog.i18nc("@label:PrintjobStatus %1 is target operation","Ready to %1").arg(UM.OutputDeviceManager.activeDeviceShortDescription);
  34. }
  35. else if(base.backendState == 4)
  36. {
  37. return catalog.i18nc("@label:PrintjobStatus", "Unable to Slice")
  38. }
  39. }
  40. Label {
  41. id: statusLabel
  42. width: parent.width - 2 * UM.Theme.getSize("default_margin").width
  43. anchors.top: parent.top
  44. anchors.left: parent.left
  45. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  46. color: UM.Theme.getColor("text")
  47. font: UM.Theme.getFont("large")
  48. text: statusText;
  49. }
  50. Rectangle{
  51. id: progressBar
  52. width: parent.width - 2 * UM.Theme.getSize("default_margin").width
  53. height: UM.Theme.getSize("progressbar").height
  54. anchors.top: statusLabel.bottom
  55. anchors.topMargin: UM.Theme.getSize("default_margin").height/4
  56. anchors.left: parent.left
  57. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  58. radius: UM.Theme.getSize("progressbar_radius").width
  59. color: UM.Theme.getColor("progressbar_background")
  60. Rectangle{
  61. width: Math.max(parent.width * base.progress)
  62. height: parent.height
  63. color: UM.Theme.getColor("progressbar_control")
  64. radius: UM.Theme.getSize("progressbar_radius").width
  65. visible: base.backendState == 2 ? true : false
  66. }
  67. }
  68. Rectangle{
  69. id: saveRow
  70. width: base.width
  71. height: saveToButton.height
  72. anchors.top: progressBar.bottom
  73. anchors.topMargin: UM.Theme.getSize("default_margin").height
  74. anchors.left: parent.left
  75. Button {
  76. id: saveToButton
  77. tooltip: UM.OutputDeviceManager.activeDeviceDescription;
  78. enabled: base.backendState == 3 && base.activity == true
  79. height: UM.Theme.getSize("save_button_save_to_button").height
  80. anchors.top: parent.top
  81. anchors.right: deviceSelectionMenu.visible ? deviceSelectionMenu.left : parent.right
  82. anchors.rightMargin: deviceSelectionMenu.visible ? -3 * UM.Theme.getSize("default_lining").width : UM.Theme.getSize("default_margin").width
  83. text: UM.OutputDeviceManager.activeDeviceShortDescription
  84. onClicked:
  85. {
  86. UM.OutputDeviceManager.requestWriteToDevice(UM.OutputDeviceManager.activeDevice, PrintInformation.jobName, { "filter_by_machine": true })
  87. }
  88. style: ButtonStyle {
  89. background:
  90. Rectangle
  91. {
  92. border.width: UM.Theme.getSize("default_lining").width
  93. border.color: !control.enabled ? UM.Theme.getColor("action_button_disabled_border") :
  94. control.pressed ? UM.Theme.getColor("action_button_active_border") :
  95. control.hovered ? UM.Theme.getColor("action_button_hovered_border") : UM.Theme.getColor("action_button_border")
  96. color: !control.enabled ? UM.Theme.getColor("action_button_disabled") :
  97. control.pressed ? UM.Theme.getColor("action_button_active") :
  98. control.hovered ? UM.Theme.getColor("action_button_hovered") : UM.Theme.getColor("action_button")
  99. Behavior on color { ColorAnimation { duration: 50; } }
  100. implicitWidth: actualLabel.contentWidth + (UM.Theme.getSize("default_margin").width * 2)
  101. Label {
  102. id: actualLabel
  103. anchors.centerIn: parent
  104. color: !control.enabled ? UM.Theme.getColor("action_button_disabled_text") :
  105. control.pressed ? UM.Theme.getColor("action_button_active_text") :
  106. control.hovered ? UM.Theme.getColor("action_button_hovered_text") : UM.Theme.getColor("action_button_text")
  107. font: UM.Theme.getFont("action_button")
  108. text: control.text;
  109. }
  110. }
  111. label: Item { }
  112. }
  113. }
  114. Button {
  115. id: deviceSelectionMenu
  116. tooltip: catalog.i18nc("@info:tooltip","Select the active output device");
  117. anchors.top: parent.top
  118. anchors.right: parent.right
  119. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  120. width: UM.Theme.getSize("save_button_save_to_button").height
  121. height: UM.Theme.getSize("save_button_save_to_button").height
  122. enabled: base.backendState == 3 && base.activity == true
  123. visible: devicesModel.deviceCount > 1
  124. style: ButtonStyle {
  125. background: Rectangle {
  126. id: deviceSelectionIcon
  127. border.width: UM.Theme.getSize("default_lining").width
  128. border.color: !control.enabled ? UM.Theme.getColor("action_button_disabled_border") :
  129. control.pressed ? UM.Theme.getColor("action_button_active_border") :
  130. control.hovered ? UM.Theme.getColor("action_button_hovered_border") : UM.Theme.getColor("action_button_border")
  131. color: !control.enabled ? UM.Theme.getColor("action_button_disabled") :
  132. control.pressed ? UM.Theme.getColor("action_button_active") :
  133. control.hovered ? UM.Theme.getColor("action_button_hovered") : UM.Theme.getColor("action_button")
  134. Behavior on color { ColorAnimation { duration: 50; } }
  135. anchors.left: parent.left
  136. anchors.leftMargin: UM.Theme.getSize("save_button_text_margin").width / 2;
  137. width: parent.height
  138. height: parent.height
  139. UM.RecolorImage {
  140. anchors.verticalCenter: parent.verticalCenter
  141. anchors.horizontalCenter: parent.horizontalCenter
  142. width: UM.Theme.getSize("standard_arrow").width
  143. height: UM.Theme.getSize("standard_arrow").height
  144. sourceSize.width: width
  145. sourceSize.height: height
  146. color: !control.enabled ? UM.Theme.getColor("action_button_disabled_text") :
  147. control.pressed ? UM.Theme.getColor("action_button_active_text") :
  148. control.hovered ? UM.Theme.getColor("action_button_hovered_text") : UM.Theme.getColor("action_button_text");
  149. source: UM.Theme.getIcon("arrow_bottom");
  150. }
  151. }
  152. label: Label{ }
  153. }
  154. menu: Menu {
  155. id: devicesMenu;
  156. Instantiator {
  157. model: devicesModel;
  158. MenuItem {
  159. text: model.description
  160. checkable: true;
  161. checked: model.id == UM.OutputDeviceManager.activeDevice;
  162. exclusiveGroup: devicesMenuGroup;
  163. onTriggered: {
  164. UM.OutputDeviceManager.setActiveDevice(model.id);
  165. }
  166. }
  167. onObjectAdded: devicesMenu.insertItem(index, object)
  168. onObjectRemoved: devicesMenu.removeItem(object)
  169. }
  170. ExclusiveGroup { id: devicesMenuGroup; }
  171. }
  172. }
  173. UM.OutputDevicesModel { id: devicesModel; }
  174. }
  175. }