SaveProjectMenu.qml 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 = {
  27. "filter_by_machine": false,
  28. "file_type": "workspace",
  29. "preferred_mimetypes": "application/vnd.ms-package.3dmanufacturing-3dmodel+xml",
  30. "limit_mimetypes": ["application/vnd.ms-package.3dmanufacturing-3dmodel+xml"],
  31. };
  32. if (UM.Preferences.getValue("cura/dialog_on_project_save"))
  33. {
  34. saveWorkspaceDialog.deviceId = model.id
  35. saveWorkspaceDialog.args = args
  36. saveWorkspaceDialog.open()
  37. }
  38. else
  39. {
  40. UM.OutputDeviceManager.requestWriteToDevice(model.id, PrintInformation.jobName, args)
  41. }
  42. }
  43. shortcut: model.shortcut
  44. enabled: saveProjectMenu.shouldBeVisible
  45. }
  46. onObjectAdded: function(index, object) { saveProjectMenu.insertItem(index, object)}
  47. onObjectRemoved: function(index, object) { saveProjectMenu.removeItem(object)}
  48. }
  49. WorkspaceSummaryDialog
  50. {
  51. id: saveWorkspaceDialog
  52. property var args
  53. property var deviceId
  54. onAccepted: UM.OutputDeviceManager.requestWriteToDevice(deviceId, PrintInformation.jobName, args)
  55. }
  56. }