diff options
author | Kostas Karmas <konskarm@gmail.com> | 2021-01-15 11:50:23 +0300 |
---|---|---|
committer | Kostas Karmas <konskarm@gmail.com> | 2021-01-15 11:50:23 +0300 |
commit | a45af1da25a475c874aec843dda384bda5814af3 (patch) | |
tree | 2e3109340b08d225316056a4b32392f6a0486566 | |
parent | 0edd6278f856c47a5e13e7385dff04a7d4232708 (diff) |
Add save projects submenu
CURA-7866
-rw-r--r-- | resources/qml/Menus/FileMenu.qml | 14 | ||||
-rw-r--r-- | resources/qml/Menus/SaveProjectMenu.qml | 53 |
2 files changed, 65 insertions, 2 deletions
diff --git a/resources/qml/Menus/FileMenu.qml b/resources/qml/Menus/FileMenu.qml index 94fc2358e1..5ea1c9bc06 100644 --- a/resources/qml/Menus/FileMenu.qml +++ b/resources/qml/Menus/FileMenu.qml @@ -4,7 +4,7 @@ import QtQuick 2.2 import QtQuick.Controls 1.1 -import UM 1.2 as UM +import UM 1.6 as UM import Cura 1.0 as Cura Menu @@ -37,8 +37,9 @@ Menu MenuItem { id: saveWorkspaceMenu - shortcut: StandardKey.Save + shortcut: visible ? StandardKey.Save : "" text: catalog.i18nc("@title:menu menubar:file", "&Save Project...") + visible: saveProjectMenu.model.count == 1 onTriggered: { var args = { "filter_by_machine": false, "file_type": "workspace", "preferred_mimetypes": "application/vnd.ms-package.3dmanufacturing-3dmodel+xml" }; @@ -54,6 +55,15 @@ Menu } } + UM.ProjectOutputDevicesModel { id: projectOutputDevicesModel } + + SaveProjectMenu + { + id: saveProjectMenu + model: projectOutputDevicesModel + visible: model.count > 1 + } + MenuSeparator { } MenuItem diff --git a/resources/qml/Menus/SaveProjectMenu.qml b/resources/qml/Menus/SaveProjectMenu.qml new file mode 100644 index 0000000000..51894674f0 --- /dev/null +++ b/resources/qml/Menus/SaveProjectMenu.qml @@ -0,0 +1,53 @@ +// Copyright (c) 2021 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.2 +import QtQuick.Controls 1.1 + +import UM 1.6 as UM +import Cura 1.1 as Cura + +import "../Dialogs" + +Menu +{ + id: saveProjectMenu + title: catalog.i18nc("@title:menu menubar:file", "Save project...") + property alias model: projectOutputDevices.model + + Instantiator + { + id: projectOutputDevices + MenuItem + { + text: model.name + onTriggered: + { + var args = { "filter_by_machine": false, "file_type": "workspace", "preferred_mimetypes": "application/vnd.ms-package.3dmanufacturing-3dmodel+xml" }; + if (UM.Preferences.getValue("cura/dialog_on_project_save")) + { + saveWorkspaceDialog.deviceId = model.id + saveWorkspaceDialog.args = args + saveWorkspaceDialog.open() + } + else + { + UM.OutputDeviceManager.requestWriteToDevice(model.id, PrintInformation.jobName, args) + } + } + // Unassign the shortcuts when the submenu is invisible (i.e. when there is only one file provider) to avoid ambiguous shortcuts. + // When there is a signle file provider, the openAction is assigned with the Ctrl+O shortcut instead. + shortcut: saveProjectMenu.visible ? model.shortcut : "" + } + onObjectAdded: saveProjectMenu.insertItem(index, object) + onObjectRemoved: saveProjectMenu.removeItem(object) + } + + WorkspaceSummaryDialog + { + id: saveWorkspaceDialog + property var args + property var deviceId + onYes: UM.OutputDeviceManager.requestWriteToDevice(deviceId, PrintInformation.jobName, args) + } +} |