mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-15 02:37:49 -06:00
Added a pyQtProperty to validate user settings (Might be wrong approach)
CURA-4333
This commit is contained in:
parent
39891551e3
commit
16bd4430e4
3 changed files with 32 additions and 22 deletions
|
@ -402,7 +402,7 @@ class CuraApplication(QtApplication):
|
||||||
# ALWAYS ask whether to keep or discard the profile
|
# ALWAYS ask whether to keep or discard the profile
|
||||||
self.showDiscardOrKeepProfileChanges.emit()
|
self.showDiscardOrKeepProfileChanges.emit()
|
||||||
|
|
||||||
sidebarSimpleDiscardOrKeepProfileChanges = pyqtSignal()
|
#sidebarSimpleDiscardOrKeepProfileChanges = pyqtSignal()
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def discardOrKeepProfileChangesClosed(self, option):
|
def discardOrKeepProfileChangesClosed(self, option):
|
||||||
|
@ -414,8 +414,8 @@ class CuraApplication(QtApplication):
|
||||||
global_stack.getTop().clear()
|
global_stack.getTop().clear()
|
||||||
|
|
||||||
# event handler for SidebarSimple, which will update sliders view visibility (like:sliders..)
|
# event handler for SidebarSimple, which will update sliders view visibility (like:sliders..)
|
||||||
if Preferences.getInstance().getValue("cura/active_mode") == 0:
|
if str(Preferences.getInstance().getValue("cura/active_mode")) == '0':
|
||||||
self.sidebarSimpleDiscardOrKeepProfileChanges.emit()
|
self.getMachineManager().hasUserCustomSettings()
|
||||||
|
|
||||||
@pyqtSlot(int)
|
@pyqtSlot(int)
|
||||||
def messageBoxClosed(self, button):
|
def messageBoxClosed(self, button):
|
||||||
|
|
|
@ -414,10 +414,13 @@ class MachineManager(QObject):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
## Check whether user containers have adjusted settings or not
|
## Check whether user containers have adjusted settings or not
|
||||||
|
# The skipped settings are predefined, because they are used on SideBarSimple to escape them while validation
|
||||||
# \param skip_keys \type{list} List of setting keys which will be not taken into account ("support_enable" , "infill_sparse_density"...)
|
# \param skip_keys \type{list} List of setting keys which will be not taken into account ("support_enable" , "infill_sparse_density"...)
|
||||||
# \return \type{boole} Return true if user containers have any of adjusted settings
|
# \return \type{boole} Return true if user containers have any of adjusted settings
|
||||||
@pyqtSlot("QVariantList", result = bool)
|
def hasUserCustomSettings(self) -> bool:
|
||||||
def hasUserCustomSettings(self, skip_keys = None) -> bool:
|
|
||||||
|
skip_keys = ["support_enable", "infill_sparse_density", "gradual_infill_steps", "adhesion_type", "support_extruder_nr"]
|
||||||
|
|
||||||
if skip_keys is None:
|
if skip_keys is None:
|
||||||
skip_keys = []
|
skip_keys = []
|
||||||
|
|
||||||
|
@ -447,7 +450,25 @@ class MachineManager(QObject):
|
||||||
Logger.log("e", "While checking user custom settings occured error. skip_keys: %s", skip_keys )
|
Logger.log("e", "While checking user custom settings occured error. skip_keys: %s", skip_keys )
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return len(user_setting_keys) > 0
|
if len(user_setting_keys) > 0:
|
||||||
|
self.userSettingsUpdated = True
|
||||||
|
else:
|
||||||
|
self.userSettingsUpdated = False
|
||||||
|
|
||||||
|
self.userCustomSettingsChanged.emit()
|
||||||
|
|
||||||
|
|
||||||
|
userSettingsUpdated = False
|
||||||
|
userCustomSettingsChanged = pyqtSignal()
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
|
def checkWhetherUserContainersHaveSettings(self):
|
||||||
|
return self.hasUserCustomSettings()
|
||||||
|
|
||||||
|
#Property to show wheter user settings are updated or not
|
||||||
|
@pyqtProperty(bool, notify = userCustomSettingsChanged)
|
||||||
|
def userCustomSettingsProperty(self):
|
||||||
|
return self.userSettingsUpdated
|
||||||
|
|
||||||
@pyqtProperty(int, notify = activeStackValueChanged)
|
@pyqtProperty(int, notify = activeStackValueChanged)
|
||||||
def numUserSettings(self) -> int:
|
def numUserSettings(self) -> int:
|
||||||
|
|
|
@ -20,13 +20,10 @@ Item
|
||||||
property variant minimumPrintTime: PrintInformation.minimumPrintTime;
|
property variant minimumPrintTime: PrintInformation.minimumPrintTime;
|
||||||
property variant maximumPrintTime: PrintInformation.maximumPrintTime;
|
property variant maximumPrintTime: PrintInformation.maximumPrintTime;
|
||||||
property bool settingsEnabled: ExtruderManager.activeExtruderStackId || machineExtruderCount.properties.value == 1
|
property bool settingsEnabled: ExtruderManager.activeExtruderStackId || machineExtruderCount.properties.value == 1
|
||||||
property bool hasUserSettings;
|
|
||||||
|
|
||||||
property var profileChangedCheckSkipKeys: ["support_enable" ,
|
property bool hasUserSettings: Cura.MachineManager.userCustomSettingsProperty
|
||||||
"infill_sparse_density",
|
|
||||||
"gradual_infill_steps",
|
|
||||||
"adhesion_type",
|
|
||||||
"support_extruder_nr"]
|
|
||||||
property var tickClickedViaProfileSlider: undefined
|
property var tickClickedViaProfileSlider: undefined
|
||||||
|
|
||||||
Component.onCompleted: PrintInformation.enabled = true
|
Component.onCompleted: PrintInformation.enabled = true
|
||||||
|
@ -41,17 +38,9 @@ Item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections
|
|
||||||
{
|
|
||||||
target: CuraApplication
|
|
||||||
onSidebarSimpleDiscardOrKeepProfileChanges:
|
|
||||||
{
|
|
||||||
base.checkUserSettings();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkUserSettings() {
|
function checkUserSettings() {
|
||||||
hasUserSettings = Cura.MachineManager.hasUserCustomSettings(profileChangedCheckSkipKeys);
|
|
||||||
|
Cura.MachineManager.checkWhetherUserContainersHaveSettings()
|
||||||
if (!hasUserSettings && tickClickedViaProfileSlider != undefined)
|
if (!hasUserSettings && tickClickedViaProfileSlider != undefined)
|
||||||
{
|
{
|
||||||
Cura.MachineManager.setActiveQuality(Cura.ProfilesModel.getItem(tickClickedViaProfileSlider).id);
|
Cura.MachineManager.setActiveQuality(Cura.ProfilesModel.getItem(tickClickedViaProfileSlider).id);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue