ConfigurationSelection.qml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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.0
  5. import QtQuick.Controls.Styles 1.4
  6. import UM 1.2 as UM
  7. import Cura 1.0 as Cura
  8. Item
  9. {
  10. id: configurationSelector
  11. property var connectedDevice: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null
  12. property var panelWidth: control.width
  13. function switchPopupState()
  14. {
  15. popup.opened ? popup.close() : popup.open()
  16. }
  17. SyncButton
  18. {
  19. id: syncButton
  20. onClicked: switchPopupState()
  21. outputDevice: connectedDevice
  22. }
  23. Popup
  24. {
  25. // TODO Change once updating to Qt5.10 - This property is already in 5.10 but is manually implemented until upgrade
  26. property bool opened: false
  27. id: popup
  28. clip: true
  29. closePolicy: Popup.CloseOnPressOutsideParent
  30. y: configurationSelector.height - UM.Theme.getSize("default_lining").height
  31. x: configurationSelector.width - width
  32. width: panelWidth
  33. visible: opened
  34. padding: UM.Theme.getSize("default_lining").width
  35. transformOrigin: Popup.Top
  36. contentItem: ConfigurationListView
  37. {
  38. id: configList
  39. width: panelWidth - 2 * popup.padding
  40. outputDevice: connectedDevice
  41. }
  42. background: Rectangle
  43. {
  44. color: UM.Theme.getColor("setting_control")
  45. border.color: UM.Theme.getColor("setting_control_border")
  46. }
  47. exit: Transition
  48. {
  49. // This applies a default NumberAnimation to any changes a state change makes to x or y properties
  50. NumberAnimation { property: "visible"; duration: 75; }
  51. }
  52. enter: Transition
  53. {
  54. // This applies a default NumberAnimation to any changes a state change makes to x or y properties
  55. NumberAnimation { property: "visible"; duration: 75; }
  56. }
  57. onClosed: opened = false
  58. onOpened: opened = true
  59. }
  60. }