FileMenu.qml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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.6 as UM
  6. import Cura 1.0 as Cura
  7. Cura.Menu
  8. {
  9. id: base
  10. title: catalog.i18nc("@title:menu menubar:toplevel", "&File")
  11. property var fileProviderModel: CuraApplication.getFileProviderModel()
  12. Cura.MenuItem
  13. {
  14. id: newProjectMenu
  15. action: Cura.Actions.newProject
  16. }
  17. Cura.MenuItem
  18. {
  19. id: openMenu
  20. action: Cura.Actions.open
  21. visible: base.fileProviderModel.count == 1
  22. enabled: base.fileProviderModel.count == 1
  23. }
  24. OpenFilesMenu
  25. {
  26. id: openFilesMenu
  27. shouldBeVisible: base.fileProviderModel.count > 1
  28. enabled: shouldBeVisible
  29. }
  30. RecentFilesMenu { }
  31. Cura.MenuItem
  32. {
  33. id: saveWorkspaceMenu
  34. shortcut: StandardKey.Save
  35. text: catalog.i18nc("@title:menu menubar:file", "&Save Project...")
  36. visible: saveProjectMenu.model.count == 1
  37. enabled: UM.WorkspaceFileHandler.enabled && saveProjectMenu.model.count == 1
  38. onTriggered:
  39. {
  40. const args = {
  41. "filter_by_machine": false,
  42. "file_type": "workspace",
  43. "preferred_mimetypes": "application/vnd.ms-package.3dmanufacturing-3dmodel+xml",
  44. "limit_mimetypes":["application/vnd.ms-package.3dmanufacturing-3dmodel+xml"],
  45. };
  46. if (UM.Preferences.getValue("cura/dialog_on_project_save"))
  47. {
  48. saveWorkspaceDialog.args = args
  49. saveWorkspaceDialog.open()
  50. }
  51. else
  52. {
  53. UM.OutputDeviceManager.requestWriteToDevice("local_file", PrintInformation.jobName, args)
  54. }
  55. }
  56. }
  57. UM.ProjectOutputDevicesModel { id: projectOutputDevicesModel }
  58. SaveProjectMenu
  59. {
  60. id: saveProjectMenu
  61. model: projectOutputDevicesModel
  62. shouldBeVisible: model.count > 1
  63. enabled: UM.WorkspaceFileHandler.enabled
  64. }
  65. Cura.MenuItem
  66. {
  67. id: saveUCPMenu
  68. text: catalog.i18nc("@title:menu menubar:file Don't translate 'Universal Cura Project'", "&Save Universal Cura Project...")
  69. enabled: UM.WorkspaceFileHandler.enabled && CuraApplication.getPackageManager().allEnabledPackages.includes("3MFWriter")
  70. onTriggered: CuraApplication.exportUcp()
  71. }
  72. Cura.MenuSeparator { }
  73. Cura.MenuItem
  74. {
  75. id: saveAsMenu
  76. text: catalog.i18nc("@title:menu menubar:file", "&Export...")
  77. onTriggered:
  78. {
  79. const args = {
  80. "filter_by_machine": false,
  81. "preferred_mimetypes": "application/vnd.ms-package.3dmanufacturing-3dmodel+xml",
  82. };
  83. UM.OutputDeviceManager.requestWriteToDevice("local_file", PrintInformation.jobName, args);
  84. }
  85. }
  86. Cura.MenuItem
  87. {
  88. id: exportSelectionMenu
  89. text: catalog.i18nc("@action:inmenu menubar:file", "Export Selection...")
  90. enabled: UM.Selection.hasSelection
  91. icon.name: "document-save-as"
  92. onTriggered: {
  93. const args = {
  94. "filter_by_machine": false,
  95. "preferred_mimetypes": "application/vnd.ms-package.3dmanufacturing-3dmodel+xml",
  96. };
  97. UM.OutputDeviceManager.requestWriteSelectionToDevice("local_file", PrintInformation.jobName, args);
  98. }
  99. }
  100. Cura.MenuSeparator { }
  101. Cura.MenuItem
  102. {
  103. id: reloadAllMenu
  104. action: Cura.Actions.reloadAll
  105. }
  106. Cura.MenuSeparator { }
  107. Cura.MenuItem { action: Cura.Actions.quit }
  108. }