From f8a9e7f2d27a96b8a657cf7772773f43d65ecebc Mon Sep 17 00:00:00 2001 From: Kostas Karmas Date: Mon, 8 Feb 2021 11:55:28 +0100 Subject: [PATCH] Pass the "add to recent" as an input var to dialogs that open projects This way it is clear before to the dialog whether it should add the file to the recent files list, before the dialog opens. CURA-7996 --- cura/CuraApplication.py | 4 ++-- resources/qml/Cura.qml | 5 +++++ resources/qml/Dialogs/AskOpenAsProjectOrModelsDialog.qml | 7 +++---- resources/qml/Dialogs/OpenFilesIncludingProjectsDialog.qml | 6 +++--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index f669e24b34..de29e56130 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -1733,7 +1733,7 @@ class CuraApplication(QtApplication): def log(self, msg): Logger.log("d", msg) - openProjectFile = pyqtSignal(QUrl, arguments = ["project_file"]) # Emitted when a project file is about to open. + openProjectFile = pyqtSignal(QUrl, bool, arguments = ["project_file", "add_to_recent_files"]) # Emitted when a project file is about to open. @pyqtSlot(QUrl, str, bool) @pyqtSlot(QUrl, str) @@ -1773,7 +1773,7 @@ class CuraApplication(QtApplication): if is_project_file and project_mode == "always_ask": # present a dialog asking to open as project or import models - self.callLater(self.openProjectFile.emit, file) + self.callLater(self.openProjectFile.emit, file, add_to_recent_files) return # Either the file is a model file or we want to load only models from project. Continue to load models. diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index bb7b5ac19c..a00dc627a9 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -691,6 +691,9 @@ UM.MainWindow function handleOpenFiles(selectedMultipleFiles, hasProjectFile, fileUrlList, projectFileUrlList) { + // Make sure the files opened through the openFilesIncludingProjectDialog are added to the recent files list + openFilesIncludingProjectsDialog.addtoRecent = true; + // we only allow opening one project file if (selectedMultipleFiles && hasProjectFile) { @@ -717,6 +720,7 @@ UM.MainWindow { // ask whether to open as project or as models askOpenAsProjectOrModelsDialog.fileUrl = projectFile; + askOpenAsProjectOrModelsDialog.addToRecent = true; askOpenAsProjectOrModelsDialog.show(); } } @@ -776,6 +780,7 @@ UM.MainWindow onOpenProjectFile: { askOpenAsProjectOrModelsDialog.fileUrl = project_file; + askOpenAsProjectOrModelsDialog.addToRecent = add_to_recent_files; askOpenAsProjectOrModelsDialog.show(); } } diff --git a/resources/qml/Dialogs/AskOpenAsProjectOrModelsDialog.qml b/resources/qml/Dialogs/AskOpenAsProjectOrModelsDialog.qml index eee8ab45db..acd44f330e 100644 --- a/resources/qml/Dialogs/AskOpenAsProjectOrModelsDialog.qml +++ b/resources/qml/Dialogs/AskOpenAsProjectOrModelsDialog.qml @@ -29,6 +29,7 @@ UM.Dialog modality: Qt.WindowModal property var fileUrl + property var addToRecent: true // load the entire project function loadProjectFile() { @@ -37,8 +38,7 @@ UM.Dialog UM.Preferences.setValue("cura/choice_on_open_project", "open_as_project") } - var addToRecent = UM.WorkspaceFileHandler.getAddToRecentFilesHint(base.fileUrl); - UM.WorkspaceFileHandler.readLocalFile(base.fileUrl, addToRecent); + UM.WorkspaceFileHandler.readLocalFile(base.fileUrl, base.addToRecent); base.hide() } @@ -50,8 +50,7 @@ UM.Dialog UM.Preferences.setValue("cura/choice_on_open_project", "open_as_model") } - var addToRecent = UM.WorkspaceFileHandler.getAddToRecentFilesHint(base.fileUrl); - CuraApplication.readLocalFile(base.fileUrl, "open_as_model", addToRecent) + CuraApplication.readLocalFile(base.fileUrl, "open_as_model", base.addToRecent) base.hide() } diff --git a/resources/qml/Dialogs/OpenFilesIncludingProjectsDialog.qml b/resources/qml/Dialogs/OpenFilesIncludingProjectsDialog.qml index 2ba8a409ef..3f1900c66b 100644 --- a/resources/qml/Dialogs/OpenFilesIncludingProjectsDialog.qml +++ b/resources/qml/Dialogs/OpenFilesIncludingProjectsDialog.qml @@ -28,19 +28,19 @@ UM.Dialog modality: Qt.WindowModal property var fileUrls: [] + property var addToRecent: true property int spacerHeight: 10 * screenScaleFactor function loadProjectFile(projectFile) { - var addToRecent = UM.WorkspaceFileHandler.getAddToRecentFilesHint(projectFile); - UM.WorkspaceFileHandler.readLocalFile(projectFile, addToRecent); + UM.WorkspaceFileHandler.readLocalFile(projectFile, base.addToRecent); } function loadModelFiles(fileUrls) { for (var i in fileUrls) { - CuraApplication.readLocalFile(fileUrls[i], "open_as_model"); + CuraApplication.readLocalFile(fileUrls[i], "open_as_model", base.addToRecent); } }