mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-14 02:07:51 -06:00
Fix custom profile handling for quality slider
CURA-4333
This commit is contained in:
parent
0383cea816
commit
39891551e3
3 changed files with 33 additions and 30 deletions
|
@ -413,7 +413,7 @@ class CuraApplication(QtApplication):
|
|||
|
||||
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:
|
||||
self.sidebarSimpleDiscardOrKeepProfileChanges.emit()
|
||||
|
||||
|
|
|
@ -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"...)
|
||||
# \return \type{boole} Return true if user containers have any of adjusted settings
|
||||
@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 = []
|
||||
try:
|
||||
if not self._global_container_stack:
|
||||
return False
|
||||
|
||||
allContainers = self._global_container_stack.getContainers()
|
||||
|
||||
for container in allContainers:
|
||||
for container in self._global_container_stack.getContainers():
|
||||
meta = container.getMetaData()
|
||||
if meta and meta["type"] and meta["type"] == "user":
|
||||
user_setting_keys.extend(container.getAllKeys())
|
||||
|
|
|
@ -22,6 +22,13 @@ Item
|
|||
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 var tickClickedViaProfileSlider: undefined
|
||||
|
||||
Component.onCompleted: PrintInformation.enabled = true
|
||||
Component.onDestruction: PrintInformation.enabled = false
|
||||
UM.I18nCatalog { id: catalog; name: "cura" }
|
||||
|
@ -39,17 +46,17 @@ Item
|
|||
target: CuraApplication
|
||||
onSidebarSimpleDiscardOrKeepProfileChanges:
|
||||
{
|
||||
base.hasUserSettings = false
|
||||
base.checkUserSettings();
|
||||
}
|
||||
}
|
||||
|
||||
function checkUserSettings(){
|
||||
var skip_keys = ["support_enable" ,
|
||||
"infill_sparse_density",
|
||||
"gradual_infill_steps",
|
||||
"adhesion_type",
|
||||
"support_extruder_nr"]
|
||||
base.hasUserSettings = Cura.MachineManager.hasUserCustomSettings(skip_keys)
|
||||
function checkUserSettings() {
|
||||
hasUserSettings = Cura.MachineManager.hasUserCustomSettings(profileChangedCheckSkipKeys);
|
||||
if (!hasUserSettings && tickClickedViaProfileSlider != undefined)
|
||||
{
|
||||
Cura.MachineManager.setActiveQuality(Cura.ProfilesModel.getItem(tickClickedViaProfileSlider).id);
|
||||
}
|
||||
tickClickedViaProfileSlider = undefined;
|
||||
}
|
||||
|
||||
ScrollView
|
||||
|
@ -289,7 +296,7 @@ Item
|
|||
anchors.bottom: speedSlider.bottom
|
||||
enabled: qualityModel.availableTotalTicks > 0
|
||||
visible: qualityModel.totalTicks > 0
|
||||
updateValueWhileDragging : false
|
||||
updateValueWhileDragging: false
|
||||
|
||||
minimumValue: qualityModel.qualitySliderAvailableMin >= 0 ? qualityModel.qualitySliderAvailableMin : 0
|
||||
maximumValue: qualityModel.qualitySliderAvailableMax >= 0 ? qualityModel.qualitySliderAvailableMax : 0
|
||||
|
@ -340,25 +347,21 @@ Item
|
|||
|
||||
//If any of settings were changed in custom mode then the Rectangle will
|
||||
//overlap quality slider area. It is used to catch mouse click
|
||||
Rectangle {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.right: extrudersModelCheckBox.right
|
||||
anchors.rightMargin: UM.Theme.getSize("default_margin").width
|
||||
width: qualitySlider.width
|
||||
height: qualitySlider.height * 1.5
|
||||
|
||||
color: "transparent"
|
||||
MouseArea {
|
||||
anchors.fill: qualitySlider
|
||||
|
||||
visible: hasUserSettings
|
||||
enabled: hasUserSettings
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue