SaveButton.qml 8.6 KB

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