SaveProjectMenu.qml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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.1
  5. import UM 1.5 as UM
  6. import Cura 1.1 as Cura
  7. import "../Dialogs"
  8. Cura.Menu
  9. {
  10. id: saveProjectMenu
  11. title: catalog.i18nc("@title:menu menubar:file", "Save Project...")
  12. property alias model: projectOutputDevices.model
  13. Instantiator
  14. {
  15. id: projectOutputDevices
  16. Cura.MenuItem
  17. {
  18. text: model.name
  19. onTriggered:
  20. {
  21. if(!UM.WorkspaceFileHandler.enabled)
  22. {
  23. // Prevent shortcut triggering if the item is disabled!
  24. return
  25. }
  26. var args = { "filter_by_machine": false, "file_type": "workspace", "preferred_mimetypes": "application/vnd.ms-package.3dmanufacturing-3dmodel+xml" };
  27. if (UM.Preferences.getValue("cura/dialog_on_project_save"))
  28. {
  29. saveWorkspaceDialog.deviceId = model.id
  30. saveWorkspaceDialog.args = args
  31. saveWorkspaceDialog.open()
  32. }
  33. else
  34. {
  35. UM.OutputDeviceManager.requestWriteToDevice(model.id, PrintInformation.jobName, args)
  36. }
  37. }
  38. shortcut: model.shortcut
  39. enabled: saveProjectMenu.shouldBeVisible
  40. }
  41. onObjectAdded: function(index, object) { saveProjectMenu.insertItem(index, object)}
  42. onObjectRemoved: function(index, object) { saveProjectMenu.removeItem(object)}
  43. }
  44. WorkspaceSummaryDialog
  45. {
  46. id: saveWorkspaceDialog
  47. property var args
  48. property var deviceId
  49. onAccepted: UM.OutputDeviceManager.requestWriteToDevice(deviceId, PrintInformation.jobName, args)
  50. }
  51. }