ConfigurationSelection.qml 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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.visible ? 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 - The 'opened' property is in 5.10 but the behavior is now implemented with the visible property
  26. id: popup
  27. clip: true
  28. closePolicy: Popup.CloseOnPressOutsideParent
  29. y: configurationSelector.height - UM.Theme.getSize("default_lining").height
  30. x: configurationSelector.width - width
  31. width: panelWidth
  32. visible: false
  33. padding: UM.Theme.getSize("default_lining").width
  34. transformOrigin: Popup.Top
  35. contentItem: ConfigurationListView
  36. {
  37. id: configList
  38. width: panelWidth - 2 * popup.padding
  39. outputDevice: connectedDevice
  40. }
  41. background: Rectangle
  42. {
  43. color: UM.Theme.getColor("setting_control")
  44. border.color: UM.Theme.getColor("setting_control_border")
  45. }
  46. exit: Transition
  47. {
  48. // This applies a default NumberAnimation to any changes a state change makes to x or y properties
  49. NumberAnimation { property: "visible"; duration: 75; }
  50. }
  51. enter: Transition
  52. {
  53. // This applies a default NumberAnimation to any changes a state change makes to x or y properties
  54. NumberAnimation { property: "visible"; duration: 75; }
  55. }
  56. onClosed: visible = false
  57. onOpened: visible = true
  58. }
  59. }