OutputDevicesActionButton.qml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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.ActionButton
  12. {
  13. id: saveToButton
  14. height: parent.height
  15. fixedWidthMode: true
  16. anchors
  17. {
  18. top: parent.top
  19. left: parent.left
  20. right: deviceSelectionMenu.visible ? deviceSelectionMenu.left : parent.right
  21. }
  22. tooltip: UM.OutputDeviceManager.activeDeviceDescription
  23. text: UM.OutputDeviceManager.activeDeviceShortDescription
  24. onClicked:
  25. {
  26. forceActiveFocus();
  27. UM.OutputDeviceManager.requestWriteToDevice(UM.OutputDeviceManager.activeDevice, PrintInformation.jobName,
  28. { "filter_by_machine": true, "preferred_mimetypes": Cura.MachineManager.activeMachine.preferred_output_file_formats });
  29. }
  30. }
  31. Cura.ActionButton
  32. {
  33. id: deviceSelectionMenu
  34. height: parent.height
  35. anchors
  36. {
  37. top: parent.top
  38. right: parent.right
  39. }
  40. tooltip: catalog.i18nc("@info:tooltip", "Select the active output device")
  41. iconSource: popup.opened ? UM.Theme.getIcon("arrow_top") : UM.Theme.getIcon("arrow_bottom")
  42. color: UM.Theme.getColor("action_panel_secondary")
  43. visible: (devicesModel.deviceCount > 1)
  44. onClicked: popup.opened ? popup.close() : popup.open()
  45. Popup
  46. {
  47. id: popup
  48. padding: 0
  49. y: -height
  50. x: parent.width - width
  51. closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
  52. contentItem: Column
  53. {
  54. Repeater
  55. {
  56. model: devicesModel
  57. delegate: Cura.ActionButton
  58. {
  59. text: model.description
  60. color: "transparent"
  61. cornerRadius: 0
  62. hoverColor: UM.Theme.getColor("primary")
  63. onClicked:
  64. {
  65. UM.OutputDeviceManager.setActiveDevice(model.id)
  66. popup.close()
  67. }
  68. }
  69. }
  70. }
  71. background: Rectangle
  72. {
  73. opacity: visible ? 1 : 0
  74. Behavior on opacity { NumberAnimation { duration: 100 } }
  75. radius: UM.Theme.getSize("default_radius").width
  76. color: UM.Theme.getColor("action_panel_secondary")
  77. border.color: UM.Theme.getColor("lining")
  78. border.width: UM.Theme.getSize("default_lining").width
  79. }
  80. }
  81. }
  82. UM.OutputDevicesModel { id: devicesModel }
  83. }