diff --git a/UM/Qt/Bindings/OutputDeviceManagerProxy.py b/UM/Qt/Bindings/OutputDeviceManagerProxy.py index 076cac5c4..c484ffe0d 100644 --- a/UM/Qt/Bindings/OutputDeviceManagerProxy.py +++ b/UM/Qt/Bindings/OutputDeviceManagerProxy.py @@ -89,10 +89,11 @@ def requestWriteToDevice(self, device_id: str, file_name: str, kwargs: Mapping[s limit_mimetypes = kwargs.get("limit_mimetypes", None) file_type = kwargs.get("file_type", "mesh") preferred_mimetypes = kwargs.get("preferred_mimetypes", None) + silent_save = kwargs.get("silent_save", False) # On Windows, calling requestWrite() on LocalFileOutputDevice crashes when called from a signal # handler attached to a QML MenuItem. So instead, defer the call to the next run of the event # loop, since that does work. - Application.getInstance().callLater(self._writeToDevice, [Application.getInstance().getController().getScene().getRoot()], device_id, file_name, limit_mimetypes, file_type, preferred_mimetypes = preferred_mimetypes) + Application.getInstance().callLater(self._writeToDevice, [Application.getInstance().getController().getScene().getRoot()], device_id, file_name, limit_mimetypes, file_type, preferred_mimetypes = preferred_mimetypes, silent_save = silent_save) @pyqtSlot(str, str, "QVariantMap") def requestWriteSelectionToDevice(self, device_id: str, file_name: str, kwargs: Mapping[str, str]) -> None: diff --git a/plugins/LocalFileOutputDevice/LocalFileOutputDevice.py b/plugins/LocalFileOutputDevice/LocalFileOutputDevice.py index 4979dcbff..53419c907 100644 --- a/plugins/LocalFileOutputDevice/LocalFileOutputDevice.py +++ b/plugins/LocalFileOutputDevice/LocalFileOutputDevice.py @@ -136,9 +136,11 @@ def requestWrite(self, nodes, file_name = None, limit_mimetypes = None, file_han result = QMessageBox.question(None, catalog.i18nc("@title:window", "File Already Exists"), catalog.i18nc("@label Don't translate the XML tag !", "The file {0} already exists. Are you sure you want to overwrite it?").format(file_name)) if result == QMessageBox.StandardButton.No: raise OutputDeviceError.UserCanceledError() - self._performWrite(file_name, selected_type, file_handler, nodes) - def _performWrite(self, file_name, selected_type, file_handler, nodes): + silent_save = kwargs.get("silent_save", False) + self._performWrite(file_name, selected_type, file_handler, nodes, silent_save) + + def _performWrite(self, file_name, selected_type, file_handler, nodes, silent_save): """Writes the specified nodes to a file. This is split from requestWrite to allow interception in other plugins. See Ultimaker/Cura#10917. @@ -146,6 +148,7 @@ def _performWrite(self, file_name, selected_type, file_handler, nodes): :param selected_type: Selected file type to write. :param file_handler: File handler for writing to the file. :param nodes: A collection of scene nodes that should be written to the + :param silent_save: When true, ignore all side effects (set project name, add recent file, ...) file. """ @@ -155,7 +158,7 @@ def _performWrite(self, file_name, selected_type, file_handler, nodes): else: file_writer = Application.getInstance().getMeshFileHandler().getWriter(selected_type["id"]) - if isinstance(file_writer, WorkspaceWriter): + if isinstance(file_writer, WorkspaceWriter) and not silent_save: self.setLastOutputName(file_name) self.writeStarted.emit(self) @@ -173,7 +176,8 @@ def _performWrite(self, file_name, selected_type, file_handler, nodes): job = WriteFileJob(file_writer, stream, nodes, mode) job.setFileName(file_name) - job.setAddToRecentFiles(True) # The file will be added into the "recent files" list upon success + if not silent_save: + job.setAddToRecentFiles(True) # The file will be added into the "recent files" list upon success job.progress.connect(self._onJobProgress) job.finished.connect(self._onWriteJobFinished)