From a859c9883c404cef61583b1d1dd383bad90a2116 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 8 Nov 2016 15:33:31 +0100 Subject: [PATCH] Added loadWorkspace option to menu CURA-1263 --- resources/qml/Actions.qml | 7 +++++++ resources/qml/Cura.qml | 39 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/resources/qml/Actions.qml b/resources/qml/Actions.qml index e88b7e77ea..2719d09cbc 100644 --- a/resources/qml/Actions.qml +++ b/resources/qml/Actions.qml @@ -11,6 +11,7 @@ import Cura 1.0 as Cura Item { property alias open: openAction; + property alias loadWorkspace: loadWorkspaceAction; property alias quit: quitAction; property alias undo: undoAction; @@ -286,6 +287,12 @@ Item shortcut: StandardKey.Open; } + Action + { + id: loadWorkspaceAction + text: catalog.i18nc("@action:inmenu menubar:file","&Load Workspace..."); + } + Action { id: showEngineLogAction; diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 021178e6db..94e81190a6 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -67,9 +67,14 @@ UM.MainWindow id: fileMenu title: catalog.i18nc("@title:menu menubar:toplevel","&File"); - MenuItem { + MenuItem + { action: Cura.Actions.open; } + MenuItem + { + action: Cura.Actions.loadWorkspace + } RecentFilesMenu { } @@ -712,6 +717,38 @@ UM.MainWindow onTriggered: openDialog.open() } + FileDialog + { + id: openWorkspaceDialog; + + //: File open dialog title + title: catalog.i18nc("@title:window","Open workspace") + modality: UM.Application.platform == "linux" ? Qt.NonModal : Qt.WindowModal; + selectMultiple: false + nameFilters: UM.WorkspaceFileHandler.supportedReadFileTypes; + folder: CuraApplication.getDefaultPath("dialog_load_path") + onAccepted: + { + //Because several implementations of the file dialog only update the folder + //when it is explicitly set. + var f = folder; + folder = f; + + CuraApplication.setDefaultPath("dialog_load_path", folder); + + for(var i in fileUrls) + { + UM.WorkspaceFileHandler.readLocalFile(fileUrls[i]) + } + } + } + + Connections + { + target: Cura.Actions.loadWorkspace + onTriggered:openWorkspaceDialog.open() + } + EngineLog { id: engineLog;