diff options
author | Kostas Karmas <konskarm@gmail.com> | 2020-12-15 20:31:15 +0300 |
---|---|---|
committer | Kostas Karmas <konskarm@gmail.com> | 2020-12-15 20:31:15 +0300 |
commit | 430550452f80310435ba9859993f82456a24b7b8 (patch) | |
tree | a19414b8a22e16acc5235ea4bf6f0fab79fa6f1b | |
parent | b49d5ab9e91279ccc89dd14a0f5bf6a4887b51d6 (diff) |
Add a new file menu option when there are multiple file providers
CURA-7868
-rw-r--r-- | resources/qml/Menus/FileMenu.qml | 5 | ||||
-rw-r--r-- | resources/qml/Menus/OpenFilesMenu.qml | 45 |
2 files changed, 50 insertions, 0 deletions
diff --git a/resources/qml/Menus/FileMenu.qml b/resources/qml/Menus/FileMenu.qml index b9845678d6..24c081502a 100644 --- a/resources/qml/Menus/FileMenu.qml +++ b/resources/qml/Menus/FileMenu.qml @@ -22,6 +22,11 @@ Menu { id: openMenu action: Cura.Actions.open + visible: CuraApplication.fileProviders.length > 0 // DEBUG: It's > 0 so that both options are visible for debugging purposes + } + + OpenFilesMenu { + visible: CuraApplication.fileProviders.length > 0 // DEBUG: It's > 0 so that both options are visible for debugging purposes } RecentFilesMenu { } diff --git a/resources/qml/Menus/OpenFilesMenu.qml b/resources/qml/Menus/OpenFilesMenu.qml new file mode 100644 index 0000000000..a3afa9a598 --- /dev/null +++ b/resources/qml/Menus/OpenFilesMenu.qml @@ -0,0 +1,45 @@ +// Copyright (c) 2016 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.0 as Cura + +import "../Dialogs" + +Menu +{ + id: menu + title: catalog.i18nc("@title:menu menubar:file", "Open File(s)...") + iconName: "document-open-recent"; + + + Instantiator + { + id: fileProviders + model: UM.FileProviderModel { } + MenuItem + { + text: + { + return model.displayText; + } + onTriggered: + { + if (model.index == 0) // The 0th element is the "From Disk" option, which should activate the open local file dialog + { + Cura.Actions.open.trigger() + } + else + { + fileProviders.model.trigger(model.name); + } + } + shortcut: model.shortcut + } + onObjectAdded: menu.insertItem(index, object) + onObjectRemoved: menu.removeItem(object) + } +} |