SaveProjectMenu.qml 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright (c) 2021 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 1.1
  5. import UM 1.6 as UM
  6. import Cura 1.1 as Cura
  7. import "../Dialogs"
  8. 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. 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. // Unassign the shortcuts when the submenu is invisible (i.e. when there is only one project output device) to avoid ambiguous shortcuts.
  39. // When there is only the LocalFileOutputDevice, the Ctrl+S shortcut is assigned to the saveWorkspaceMenu MenuItem
  40. shortcut: saveProjectMenu.visible ? model.shortcut : ""
  41. }
  42. onObjectAdded: saveProjectMenu.insertItem(index, object)
  43. onObjectRemoved: saveProjectMenu.removeItem(object)
  44. }
  45. WorkspaceSummaryDialog
  46. {
  47. id: saveWorkspaceDialog
  48. property var args
  49. property var deviceId
  50. onYes: UM.OutputDeviceManager.requestWriteToDevice(deviceId, PrintInformation.jobName, args)
  51. }
  52. }