OutputDevicesActionButton.qml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.7
  4. import QtQuick.Controls 2.1
  5. import QtQuick.Layouts 1.3
  6. import UM 1.1 as UM
  7. import Cura 1.0 as Cura
  8. Item
  9. {
  10. id: widget
  11. Cura.PrimaryButton
  12. {
  13. id: saveToButton
  14. height: parent.height
  15. fixedWidthMode: true
  16. cornerSide: deviceSelectionMenu.visible ? Cura.RoundedRectangle.Direction.Left : Cura.RoundedRectangle.Direction.All
  17. anchors
  18. {
  19. top: parent.top
  20. left: parent.left
  21. right: deviceSelectionMenu.visible ? deviceSelectionMenu.left : parent.right
  22. }
  23. tooltip: UM.OutputDeviceManager.activeDeviceDescription
  24. text: UM.OutputDeviceManager.activeDeviceShortDescription
  25. onClicked:
  26. {
  27. forceActiveFocus();
  28. UM.OutputDeviceManager.requestWriteToDevice(UM.OutputDeviceManager.activeDevice, PrintInformation.jobName,
  29. { "filter_by_machine": true, "preferred_mimetypes": Cura.MachineManager.activeMachine.preferred_output_file_formats });
  30. }
  31. }
  32. Cura.ActionButton
  33. {
  34. id: deviceSelectionMenu
  35. height: parent.height
  36. shadowEnabled: true
  37. shadowColor: UM.Theme.getColor("primary_shadow")
  38. cornerSide: Cura.RoundedRectangle.Direction.Right
  39. anchors
  40. {
  41. top: parent.top
  42. right: parent.right
  43. }
  44. leftPadding: UM.Theme.getSize("narrow_margin").width //Need more space than usual here for wide text.
  45. rightPadding: UM.Theme.getSize("narrow_margin").width
  46. iconSource: popup.opened ? UM.Theme.getIcon("arrow_top") : UM.Theme.getIcon("arrow_bottom")
  47. color: UM.Theme.getColor("action_panel_secondary")
  48. visible: (devicesModel.deviceCount > 1)
  49. onClicked: popup.opened ? popup.close() : popup.open()
  50. Popup
  51. {
  52. id: popup
  53. padding: 0
  54. y: -height
  55. x: parent.width - width
  56. closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
  57. contentItem: ColumnLayout
  58. {
  59. Repeater
  60. {
  61. model: devicesModel
  62. delegate: Cura.ActionButton
  63. {
  64. text: model.description
  65. color: "transparent"
  66. cornerRadius: 0
  67. hoverColor: UM.Theme.getColor("primary")
  68. Layout.fillWidth: true
  69. onClicked:
  70. {
  71. UM.OutputDeviceManager.setActiveDevice(model.id)
  72. popup.close()
  73. }
  74. }
  75. }
  76. }
  77. background: Rectangle
  78. {
  79. opacity: visible ? 1 : 0
  80. Behavior on opacity { NumberAnimation { duration: 100 } }
  81. color: UM.Theme.getColor("action_panel_secondary")
  82. }
  83. }
  84. }
  85. UM.OutputDevicesModel { id: devicesModel }
  86. }