mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-18 04:07:57 -06:00
Added isValidGlobalStack property to MachineManager
CURA-1585
This commit is contained in:
parent
171adde6be
commit
113da81db5
2 changed files with 18 additions and 2 deletions
|
@ -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:
|
||||
|
|
|
@ -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...");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue