diff --git a/cura/MachineManagerModel.py b/cura/MachineManagerModel.py index d34e392720..e9b8ba7d55 100644 --- a/cura/MachineManagerModel.py +++ b/cura/MachineManagerModel.py @@ -7,6 +7,7 @@ from UM.Preferences import Preferences from UM.Logger import Logger import UM.Settings +from UM.Settings.Validator import ValidatorState class MachineManagerModel(QObject): @@ -167,6 +168,17 @@ class MachineManagerModel(QObject): return unique_name + ## Convenience function to check if a stack has errors. + def _checkStackForErrors(self, stack): + if stack is None: + return False + + for key in stack.getAllKeys(): + validation_state = stack.getProperty(key, "validationState") + if validation_state in (ValidatorState.Exception, ValidatorState.MaximumError, ValidatorState.MinimumError): + return True + return False + @pyqtSlot() def clearUserSettings(self): if not self._global_container_stack: @@ -182,6 +194,10 @@ class MachineManagerModel(QObject): user_settings = self._global_container_stack.getTop().findInstances(**{}) return len(user_settings) != 0 + @pyqtProperty(bool, notify = globalPropertyChanged) + def isGlobalStackValid(self): + return not self._checkStackForErrors(self._global_container_stack) + @pyqtProperty(str, notify = globalContainerChanged) def activeMachineName(self): if self._global_container_stack: diff --git a/resources/qml/Actions.qml b/resources/qml/Actions.qml index 6dd851c3d5..4769b53b05 100644 --- a/resources/qml/Actions.qml +++ b/resources/qml/Actions.qml @@ -110,7 +110,7 @@ Item Action { id: updateProfileAction; - enabled: UM.ActiveProfile.valid && !UM.ActiveProfile.readOnly && UM.ActiveProfile.hasCustomisedValues + enabled: Cura.MachineManager.isGlobalStackValid && !UM.ActiveProfile.readOnly && Cura.MachineManager.hasUserSettings text: catalog.i18nc("@action:inmenu menubar:profile","&Update Current Profile"); onTriggered: UM.ActiveProfile.updateProfile(); } @@ -126,7 +126,7 @@ Item Action { id: addProfileAction; - enabled: UM.ActiveProfile.valid + enabled: Cura.MachineManager.isGlobalStackValid text: catalog.i18nc("@action:inmenu menubar:profile","&Create New Profile..."); }