diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 2515d22127..579be0d953 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -1620,8 +1620,12 @@ class CuraApplication(QtApplication): openProjectFile = pyqtSignal(QUrl, arguments = ["project_file"]) # Emitted when a project file is about to open. - @pyqtSlot(QUrl, bool) - def readLocalFile(self, file, skip_project_file_check = False): + @pyqtSlot(QUrl, str) + @pyqtSlot(QUrl) + ## Open a local file + # \param project_mode How to handle project files. Either None(default): Follow user preference, "open_as_model" or + # "open_as_project". This parameter is only considered if the file is a project file. + def readLocalFile(self, file: QUrl, project_mode: Optional[str] = None): if not file.isValid(): return @@ -1632,10 +1636,24 @@ class CuraApplication(QtApplication): self.deleteAll() break - if not skip_project_file_check and self.checkIsValidProjectFile(file): + is_project_file = self.checkIsValidProjectFile(file) + + if project_mode is None: + project_mode = self.getPreferences().getValue("cura/choice_on_open_project") + + if is_project_file and project_mode == "open_as_project": + # open as project immediately without presenting a dialog + workspace_handler = self.getWorkspaceFileHandler() + workspace_handler.readLocalFile(file) + return + + 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) return + # Either the file is a model file or we want to load only models from project. Continue to load models. + if self.getPreferences().getValue("cura/select_models_on_load"): Selection.clear() diff --git a/cura/SingleInstance.py b/cura/SingleInstance.py index cf07b143c6..6fcf0da6cf 100644 --- a/cura/SingleInstance.py +++ b/cura/SingleInstance.py @@ -87,7 +87,7 @@ class SingleInstance: if command == "clear-all": self._application.callLater(lambda: self._application.deleteAll()) - # Command: Load a model file + # Command: Load a model or project file elif command == "open": self._application.callLater(lambda f = payload["filePath"]: self._application._openFile(f)) diff --git a/resources/definitions/fdmprinter.def.json b/resources/definitions/fdmprinter.def.json index 05355f7e23..9959fcd492 100644 --- a/resources/definitions/fdmprinter.def.json +++ b/resources/definitions/fdmprinter.def.json @@ -5832,6 +5832,32 @@ "enabled": "not (support_enable or support_tree_enable)", "settable_per_mesh": false, "settable_per_extruder": false + }, + "meshfix_maximum_travel_resolution": + { + "label": "Maximum Travel Resolution", + "description": "The minimum size of a travel line segment after slicing. If you increase this, the travel moves will have less smooth corners. This may allow the printer to keep up with the speed it has to process g-code, but it may cause model avoidance to become less accurate.", + "type": "float", + "unit": "mm", + "default_value": 1.0, + "value": "min(meshfix_maximum_resolution * speed_travel / speed_print, 2 * line_width)", + "minimum_value": "0.001", + "minimum_value_warning": "0.05", + "maximum_value_warning": "10", + "settable_per_mesh": false, + "settable_per_extruder": true + }, + "meshfix_maximum_deviation": + { + "label": "Maximum Deviation", + "description": "The maximum deviation allowed when reducing the resolution for the Maximum Resolution setting. If you increase this, the print will be less accurate, but the g-code will be smaller. Maximum Deviation is a limit for Maximum Resolution, so if the two conflict the Maximum Deviation will always be held true.", + "type": "float", + "unit": "mm", + "default_value": 0.05, + "minimum_value": "0.001", + "minimum_value_warning": "0.01", + "maximum_value_warning": "0.3", + "settable_per_mesh": true } } }, @@ -6222,7 +6248,7 @@ "unit": "mm", "type": "float", "default_value": 1.0, - "minimum_value": "0.001", + "minimum_value": "0", "minimum_value_warning": "0.05", "maximum_value_warning": "1.0", "settable_per_mesh": true, @@ -6240,32 +6266,6 @@ "maximum_value_warning": "3", "settable_per_mesh": true }, - "meshfix_maximum_travel_resolution": - { - "label": "Maximum Travel Resolution", - "description": "The minimum size of a travel line segment after slicing. If you increase this, the travel moves will have less smooth corners. This may allow the printer to keep up with the speed it has to process g-code, but it may cause model avoidance to become less accurate.", - "type": "float", - "unit": "mm", - "default_value": 1.0, - "value": "min(meshfix_maximum_resolution * speed_travel / speed_print, 2 * line_width)", - "minimum_value": "0.001", - "minimum_value_warning": "0.05", - "maximum_value_warning": "10", - "settable_per_mesh": false, - "settable_per_extruder": true - }, - "meshfix_maximum_deviation": - { - "label": "Maximum Deviation", - "description": "The maximum deviation allowed when reducing the resolution for the Maximum Resolution setting. If you increase this, the print will be less accurate, but the g-code will be smaller. Maximum Deviation is a limit for Maximum Resolution, so if the two conflict the Maximum Deviation will always be held true.", - "type": "float", - "unit": "mm", - "default_value": 0.05, - "minimum_value": "0.001", - "minimum_value_warning": "0.01", - "maximum_value_warning": "0.3", - "settable_per_mesh": true - }, "support_skip_some_zags": { "label": "Break Up Support In Chunks", diff --git a/resources/qml/Dialogs/AskOpenAsProjectOrModelsDialog.qml b/resources/qml/Dialogs/AskOpenAsProjectOrModelsDialog.qml index f6436f62c5..2566a2d44c 100644 --- a/resources/qml/Dialogs/AskOpenAsProjectOrModelsDialog.qml +++ b/resources/qml/Dialogs/AskOpenAsProjectOrModelsDialog.qml @@ -53,7 +53,7 @@ UM.Dialog UM.Preferences.setValue("cura/choice_on_open_project", "open_as_model") } - CuraApplication.readLocalFile(base.fileUrl, true) + CuraApplication.readLocalFile(base.fileUrl, "open_as_model") var meshName = backgroundItem.getMeshName(base.fileUrl.toString()) backgroundItem.hasMesh(decodeURIComponent(meshName)) diff --git a/resources/qml/Dialogs/OpenFilesIncludingProjectsDialog.qml b/resources/qml/Dialogs/OpenFilesIncludingProjectsDialog.qml index 0df914805a..187578f12c 100644 --- a/resources/qml/Dialogs/OpenFilesIncludingProjectsDialog.qml +++ b/resources/qml/Dialogs/OpenFilesIncludingProjectsDialog.qml @@ -42,7 +42,7 @@ UM.Dialog { for (var i in fileUrls) { - CuraApplication.readLocalFile(fileUrls[i], true); + CuraApplication.readLocalFile(fileUrls[i], "open_as_model"); } var meshName = backgroundItem.getMeshName(fileUrls[0].toString()); diff --git a/resources/qml/MachineSettings/PrintHeadMinMaxTextField.qml b/resources/qml/MachineSettings/PrintHeadMinMaxTextField.qml index a08fa92c78..7bb5f5fc76 100644 --- a/resources/qml/MachineSettings/PrintHeadMinMaxTextField.qml +++ b/resources/qml/MachineSettings/PrintHeadMinMaxTextField.qml @@ -24,7 +24,7 @@ import Cura 1.1 as Cura // NumericTextFieldWithUnit { - id: machineXMaxField + id: printerHeadMinMaxField UM.I18nCatalog { id: catalog; name: "cura" } containerStackId: Cura.MachineManager.activeMachineId @@ -64,7 +64,7 @@ NumericTextFieldWithUnit // show the correct value. if (!textField.activeFocus && !textField.acceptableInput) { - valueText = axisValue + valueText = Qt.binding(function() { return printerHeadMinMaxField.axisValue }) } } } @@ -94,6 +94,6 @@ NumericTextFieldWithUnit } // Recreate the binding to show the correct value. - valueText = axisValue + valueText = Qt.binding(function() { return axisValue }) } } diff --git a/resources/qml/Menus/RecentFilesMenu.qml b/resources/qml/Menus/RecentFilesMenu.qml index 0f1f67b6fa..b788b5e72e 100644 --- a/resources/qml/Menus/RecentFilesMenu.qml +++ b/resources/qml/Menus/RecentFilesMenu.qml @@ -29,42 +29,8 @@ Menu } onTriggered: { - var toShowDialog = false; - var toOpenAsProject = false; - var toOpenAsModel = false; + CuraApplication.readLocalFile(modelData); - if (CuraApplication.checkIsValidProjectFile(modelData)) { - // check preference - var choice = UM.Preferences.getValue("cura/choice_on_open_project"); - - if (choice == "open_as_project") - { - toOpenAsProject = true; - }else if (choice == "open_as_model"){ - toOpenAsModel = true; - }else{ - toShowDialog = true; - } - } - else { - toOpenAsModel = true; - } - - if (toShowDialog) { - askOpenAsProjectOrModelsDialog.fileUrl = modelData; - askOpenAsProjectOrModelsDialog.show(); - return; - } - - // open file in the prefered way - if (toOpenAsProject) - { - UM.WorkspaceFileHandler.readLocalFile(modelData); - } - else if (toOpenAsModel) - { - CuraApplication.readLocalFile(modelData, true); - } var meshName = backgroundItem.getMeshName(modelData.toString()) backgroundItem.hasMesh(decodeURIComponent(meshName)) }