PrinterMenu.qml 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // Copyright (c) 2022 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 2.4
  5. import UM 1.6 as UM
  6. import Cura 1.0 as Cura
  7. Cura.Menu
  8. {
  9. id: menu
  10. title: catalog.i18nc("@title:menu menubar:settings", "&Printer")
  11. Cura.MenuItem
  12. {
  13. id: networkEnabledPrinterItem
  14. text: catalog.i18nc("@label:category menu label", "Network enabled printers")
  15. enabled: false
  16. visible: networKPrinterInstantiator.count > 0
  17. }
  18. Instantiator
  19. {
  20. id: networKPrinterInstantiator
  21. model: Cura.GlobalStacksModel {filterOnlineOnly: true }
  22. Cura.MenuItem
  23. {
  24. property string connectGroupName:
  25. {
  26. if("group_name" in model.metadata)
  27. {
  28. return model.metadata["group_name"]
  29. }
  30. return ""
  31. }
  32. text: connectGroupName
  33. checkable: true
  34. checked: Cura.MachineManager.activeMachineNetworkGroupName == connectGroupName
  35. onTriggered: Cura.MachineManager.setActiveMachine(model.id)
  36. }
  37. onObjectAdded: function(index, object) { menu.insertItem(2, object)}
  38. onObjectRemoved: function(index, object) { menu.removeItem(object)}
  39. }
  40. Cura.MenuSeparator { visible: networKPrinterInstantiator.count > 0 }
  41. Cura.MenuItem
  42. {
  43. id: localPrinterMenu
  44. text: catalog.i18nc("@label:category menu label", "Local printers")
  45. enabled: false
  46. visible: localPrinterInstantiator.count > 0
  47. }
  48. Instantiator
  49. {
  50. id: localPrinterInstantiator
  51. model: Cura.GlobalStacksModel {}
  52. Cura.MenuItem
  53. {
  54. text: model.name
  55. checkable: true
  56. checked: Cura.MachineManager.activeMachine !== null ? Cura.MachineManager.activeMachine.id == model.id: false
  57. visible: !model.hasRemoteConnection
  58. onTriggered: Cura.MachineManager.setActiveMachine(model.id)
  59. }
  60. // A bit hackish, but we have 2 items at the end, put them before that
  61. onObjectAdded: function(index, object) { menu.insertItem(menu.count - 2, object) }
  62. onObjectRemoved: function(index, object) { menu.removeItem(object) }
  63. }
  64. Cura.MenuSeparator { visible: localPrinterInstantiator.count > 0 }
  65. Cura.MenuItem { action: Cura.Actions.addMachine }
  66. Cura.MenuItem { action: Cura.Actions.configureMachines }
  67. }