Added a pyQtProperty to validate user settings (Might be wrong approach)

CURA-4333
This commit is contained in:
A.Sasin 2017-10-12 21:23:17 +02:00
parent 39891551e3
commit 16bd4430e4
3 changed files with 32 additions and 22 deletions

View file

@ -402,7 +402,7 @@ class CuraApplication(QtApplication):
# ALWAYS ask whether to keep or discard the profile
self.showDiscardOrKeepProfileChanges.emit()
sidebarSimpleDiscardOrKeepProfileChanges = pyqtSignal()
#sidebarSimpleDiscardOrKeepProfileChanges = pyqtSignal()
@pyqtSlot(str)
def discardOrKeepProfileChangesClosed(self, option):
@ -414,8 +414,8 @@ class CuraApplication(QtApplication):
global_stack.getTop().clear()
# event handler for SidebarSimple, which will update sliders view visibility (like:sliders..)
if Preferences.getInstance().getValue("cura/active_mode") == 0:
self.sidebarSimpleDiscardOrKeepProfileChanges.emit()
if str(Preferences.getInstance().getValue("cura/active_mode")) == '0':
self.getMachineManager().hasUserCustomSettings()
@pyqtSlot(int)
def messageBoxClosed(self, button):

View file

@ -414,10 +414,13 @@ class MachineManager(QObject):
return False
## 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"...)
# \return \type{boole} Return true if user containers have any of adjusted settings
@pyqtSlot("QVariantList", result = bool)
def hasUserCustomSettings(self, skip_keys = None) -> bool:
def hasUserCustomSettings(self) -> bool:
skip_keys = ["support_enable", "infill_sparse_density", "gradual_infill_steps", "adhesion_type", "support_extruder_nr"]
if skip_keys is None:
skip_keys = []
@ -447,7 +450,25 @@ class MachineManager(QObject):
Logger.log("e", "While checking user custom settings occured error. skip_keys: %s", skip_keys )
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)
def numUserSettings(self) -> int:

View file

@ -20,13 +20,10 @@ Item
property variant minimumPrintTime: PrintInformation.minimumPrintTime;
property variant maximumPrintTime: PrintInformation.maximumPrintTime;
property bool settingsEnabled: ExtruderManager.activeExtruderStackId || machineExtruderCount.properties.value == 1
property bool hasUserSettings;
property var profileChangedCheckSkipKeys: ["support_enable" ,
"infill_sparse_density",
"gradual_infill_steps",
"adhesion_type",
"support_extruder_nr"]
property bool hasUserSettings: Cura.MachineManager.userCustomSettingsProperty
property var tickClickedViaProfileSlider: undefined
Component.onCompleted: PrintInformation.enabled = true
@ -41,17 +38,9 @@ Item
}
}
Connections
{
target: CuraApplication
onSidebarSimpleDiscardOrKeepProfileChanges:
{
base.checkUserSettings();
}
}
function checkUserSettings() {
hasUserSettings = Cura.MachineManager.hasUserCustomSettings(profileChangedCheckSkipKeys);
Cura.MachineManager.checkWhetherUserContainersHaveSettings()
if (!hasUserSettings && tickClickedViaProfileSlider != undefined)
{
Cura.MachineManager.setActiveQuality(Cura.ProfilesModel.getItem(tickClickedViaProfileSlider).id);