Fix custom profile handling for quality slider

CURA-4333
This commit is contained in:
Lipu Fei 2017-10-12 12:42:18 +02:00
parent 0383cea816
commit 39891551e3
3 changed files with 33 additions and 30 deletions

View file

@ -417,16 +417,16 @@ class MachineManager(QObject):
# \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) @pyqtSlot("QVariantList", result = bool)
def hasUserCustomSettings(self, skip_keys = []) -> bool: def hasUserCustomSettings(self, skip_keys = None) -> bool:
if skip_keys is None:
skip_keys = []
user_setting_keys = [] user_setting_keys = []
try: try:
if not self._global_container_stack: if not self._global_container_stack:
return False return False
allContainers = self._global_container_stack.getContainers() for container in self._global_container_stack.getContainers():
for container in allContainers:
meta = container.getMetaData() meta = container.getMetaData()
if meta and meta["type"] and meta["type"] == "user": if meta and meta["type"] and meta["type"] == "user":
user_setting_keys.extend(container.getAllKeys()) user_setting_keys.extend(container.getAllKeys())

View file

@ -22,6 +22,13 @@ Item
property bool settingsEnabled: ExtruderManager.activeExtruderStackId || machineExtruderCount.properties.value == 1 property bool settingsEnabled: ExtruderManager.activeExtruderStackId || machineExtruderCount.properties.value == 1
property bool hasUserSettings; property bool hasUserSettings;
property var profileChangedCheckSkipKeys: ["support_enable" ,
"infill_sparse_density",
"gradual_infill_steps",
"adhesion_type",
"support_extruder_nr"]
property var tickClickedViaProfileSlider: undefined
Component.onCompleted: PrintInformation.enabled = true Component.onCompleted: PrintInformation.enabled = true
Component.onDestruction: PrintInformation.enabled = false Component.onDestruction: PrintInformation.enabled = false
UM.I18nCatalog { id: catalog; name: "cura" } UM.I18nCatalog { id: catalog; name: "cura" }
@ -39,17 +46,17 @@ Item
target: CuraApplication target: CuraApplication
onSidebarSimpleDiscardOrKeepProfileChanges: onSidebarSimpleDiscardOrKeepProfileChanges:
{ {
base.hasUserSettings = false base.checkUserSettings();
} }
} }
function checkUserSettings() { function checkUserSettings() {
var skip_keys = ["support_enable" , hasUserSettings = Cura.MachineManager.hasUserCustomSettings(profileChangedCheckSkipKeys);
"infill_sparse_density", if (!hasUserSettings && tickClickedViaProfileSlider != undefined)
"gradual_infill_steps", {
"adhesion_type", Cura.MachineManager.setActiveQuality(Cura.ProfilesModel.getItem(tickClickedViaProfileSlider).id);
"support_extruder_nr"] }
base.hasUserSettings = Cura.MachineManager.hasUserCustomSettings(skip_keys) tickClickedViaProfileSlider = undefined;
} }
ScrollView ScrollView
@ -340,25 +347,21 @@ Item
//If any of settings were changed in custom mode then the Rectangle will //If any of settings were changed in custom mode then the Rectangle will
//overlap quality slider area. It is used to catch mouse click //overlap quality slider area. It is used to catch mouse click
Rectangle { MouseArea {
anchors.verticalCenter: parent.verticalCenter anchors.fill: qualitySlider
anchors.right: extrudersModelCheckBox.right
anchors.rightMargin: UM.Theme.getSize("default_margin").width
width: qualitySlider.width
height: qualitySlider.height * 1.5
color: "transparent"
visible: hasUserSettings visible: hasUserSettings
enabled: hasUserSettings enabled: hasUserSettings
MouseArea {
anchors.fill: parent
onClicked: { onClicked: {
discardOrKeepProfileChangesDialog.show() const offset = qualityModel.qualitySliderStepWidth / 2;
} const mousePosition = mouseX + offset;
}
// save where it was clicked
base.tickClickedViaProfileSlider = Math.floor(mousePosition / qualityModel.qualitySliderStepWidth);
discardOrKeepProfileChangesDialog.show();
}
} }
} }