SaveButton.qml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. property real progress: UM.Backend.progress;
  11. property bool activity: Printer.getPlatformActivity;
  12. Behavior on progress { NumberAnimation { duration: 250; } }
  13. property int totalHeight: childrenRect.height + UM.Theme.sizes.default_margin.height*1.5
  14. property string fileBaseName
  15. UM.I18nCatalog { id: catalog; name:"cura"}
  16. Rectangle{
  17. id: saveRow
  18. width: base.width
  19. height: saveToButton.height + (UM.Theme.sizes.default_margin.height / 2) // height + bottomMargin
  20. anchors.top: parent.top
  21. anchors.topMargin: UM.Theme.sizes.default_margin.height
  22. anchors.left: parent.left
  23. Button {
  24. id: saveToButton
  25. property int resizedWidth
  26. x: base.width - saveToButton.resizedWidth - UM.Theme.sizes.default_margin.width - UM.Theme.sizes.save_button_save_to_button.height + 2
  27. tooltip: UM.OutputDeviceManager.activeDeviceDescription;
  28. enabled: base.progress > 0.99 && base.activity == true
  29. height: UM.Theme.sizes.save_button_save_to_button.height
  30. width: 150
  31. anchors.top:parent.top
  32. text: UM.OutputDeviceManager.activeDeviceShortDescription
  33. onClicked:
  34. {
  35. UM.OutputDeviceManager.requestWriteToDevice(UM.OutputDeviceManager.activeDevice, Printer.jobName)
  36. }
  37. style: ButtonStyle {
  38. background: Rectangle {
  39. //opacity: control.enabled ? 1.0 : 0.5
  40. //Behavior on opacity { NumberAnimation { duration: 50; } }
  41. border.color: !control.enabled ? UM.Theme.colors.action_button_disabled_border :
  42. control.pressed ? UM.Theme.colors.action_button_active_border :
  43. control.hovered ? UM.Theme.colors.action_button_hovered_border : UM.Theme.colors.action_button_border
  44. color: !control.enabled ? UM.Theme.colors.action_button_disabled :
  45. control.pressed ? UM.Theme.colors.action_button_active :
  46. control.hovered ? UM.Theme.colors.action_button_hovered : UM.Theme.colors.action_button
  47. Behavior on color { ColorAnimation { duration: 50; } }
  48. width: {
  49. saveToButton.resizedWidth = actualLabel.width + (UM.Theme.sizes.default_margin.width * 2)
  50. return saveToButton.resizedWidth
  51. }
  52. Label {
  53. id: actualLabel
  54. //Behavior on opacity { NumberAnimation { duration: 50; } }
  55. anchors.centerIn: parent
  56. color: !control.enabled ? UM.Theme.colors.action_button_disabled_text :
  57. control.pressed ? UM.Theme.colors.action_button_active_text :
  58. control.hovered ? UM.Theme.colors.action_button_hovered_text : UM.Theme.colors.action_button_text
  59. font: UM.Theme.fonts.action_button
  60. text: control.text;
  61. }
  62. }
  63. label: Item { }
  64. }
  65. }
  66. Button {
  67. id: deviceSelectionMenu
  68. tooltip: catalog.i18nc("@info:tooltip","Select the active output device");
  69. anchors.top:parent.top
  70. anchors.right: parent.right
  71. anchors.rightMargin: UM.Theme.sizes.default_margin.width
  72. width: UM.Theme.sizes.save_button_save_to_button.height
  73. height: UM.Theme.sizes.save_button_save_to_button.height
  74. enabled: base.progress > 0.99 && base.activity == true
  75. //iconSource: UM.Theme.icons[UM.OutputDeviceManager.activeDeviceIconName];
  76. style: ButtonStyle {
  77. background: Rectangle {
  78. id: deviceSelectionIcon
  79. border.color: !control.enabled ? UM.Theme.colors.action_button_disabled_border :
  80. control.pressed ? UM.Theme.colors.action_button_active_border :
  81. control.hovered ? UM.Theme.colors.action_button_hovered_border : UM.Theme.colors.action_button_border
  82. color: !control.enabled ? UM.Theme.colors.action_button_disabled :
  83. control.pressed ? UM.Theme.colors.action_button_active :
  84. control.hovered ? UM.Theme.colors.action_button_hovered : UM.Theme.colors.action_button
  85. Behavior on color { ColorAnimation { duration: 50; } }
  86. anchors.left: parent.left
  87. anchors.leftMargin: UM.Theme.sizes.save_button_text_margin.width / 2;
  88. width: parent.height
  89. height: parent.height
  90. UM.RecolorImage {
  91. anchors.verticalCenter: parent.verticalCenter
  92. anchors.horizontalCenter: parent.horizontalCenter
  93. width: UM.Theme.sizes.standard_arrow.width
  94. height: UM.Theme.sizes.standard_arrow.height
  95. sourceSize.width: width
  96. sourceSize.height: height
  97. color: !control.enabled ? UM.Theme.colors.action_button_disabled_text :
  98. control.pressed ? UM.Theme.colors.action_button_active_text :
  99. control.hovered ? UM.Theme.colors.action_button_hovered_text : UM.Theme.colors.action_button_text;
  100. source: UM.Theme.icons.arrow_bottom;
  101. }
  102. }
  103. label: Label{ }
  104. }
  105. menu: Menu {
  106. id: devicesMenu;
  107. Instantiator {
  108. model: devicesModel;
  109. MenuItem {
  110. text: model.description
  111. checkable: true;
  112. checked: model.id == UM.OutputDeviceManager.activeDevice;
  113. exclusiveGroup: devicesMenuGroup;
  114. onTriggered: {
  115. UM.OutputDeviceManager.setActiveDevice(model.id);
  116. }
  117. }
  118. onObjectAdded: devicesMenu.insertItem(index, object)
  119. onObjectRemoved: devicesMenu.removeItem(object)
  120. }
  121. ExclusiveGroup { id: devicesMenuGroup; }
  122. }
  123. }
  124. UM.OutputDevicesModel { id: devicesModel; }
  125. }
  126. }