SaveProjectMenu.qml 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. var args = { "filter_by_machine": false, "file_type": "workspace", "preferred_mimetypes": "application/vnd.ms-package.3dmanufacturing-3dmodel+xml" };
  22. if (UM.Preferences.getValue("cura/dialog_on_project_save"))
  23. {
  24. saveWorkspaceDialog.deviceId = model.id
  25. saveWorkspaceDialog.args = args
  26. saveWorkspaceDialog.open()
  27. }
  28. else
  29. {
  30. UM.OutputDeviceManager.requestWriteToDevice(model.id, PrintInformation.jobName, args)
  31. }
  32. }
  33. // Unassign the shortcuts when the submenu is invisible (i.e. when there is only one project output device) to avoid ambiguous shortcuts.
  34. // When there is only the LocalFileOutputDevice, the Ctrl+S shortcut is assigned to the saveWorkspaceMenu MenuItem
  35. shortcut: saveProjectMenu.visible ? model.shortcut : ""
  36. }
  37. onObjectAdded: saveProjectMenu.insertItem(index, object)
  38. onObjectRemoved: saveProjectMenu.removeItem(object)
  39. }
  40. WorkspaceSummaryDialog
  41. {
  42. id: saveWorkspaceDialog
  43. property var args
  44. property var deviceId
  45. onYes: UM.OutputDeviceManager.requestWriteToDevice(deviceId, PrintInformation.jobName, args)
  46. }
  47. }