mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-14 02:07:51 -06:00
Sync currently selected preset between visibility-page and -menu
This commit is contained in:
parent
4c1002bf47
commit
74fe281e1d
7 changed files with 82 additions and 61 deletions
|
@ -362,13 +362,8 @@ class CuraApplication(QtApplication):
|
||||||
|
|
||||||
default_visibility_profile = SettingVisibilityPresetsModel.getInstance().getItem(0)
|
default_visibility_profile = SettingVisibilityPresetsModel.getInstance().getItem(0)
|
||||||
|
|
||||||
preferences.addPreference("general/preset_setting_visibility_choice", default_visibility_profile["id"])
|
|
||||||
preferences.setDefault("general/visible_settings", ";".join(default_visibility_profile["settings"]))
|
preferences.setDefault("general/visible_settings", ";".join(default_visibility_profile["settings"]))
|
||||||
|
|
||||||
preset_setting_visibility_choice = Preferences.getInstance().getValue("general/preset_setting_visibility_choice")
|
|
||||||
if not SettingVisibilityPresetsModel.getInstance().find("id", preset_setting_visibility_choice):
|
|
||||||
Preferences.getInstance().setValue("general/preset_setting_visibility_choice", default_visibility_profile["id"])
|
|
||||||
|
|
||||||
self.applicationShuttingDown.connect(self.saveSettings)
|
self.applicationShuttingDown.connect(self.saveSettings)
|
||||||
self.engineCreatedSignal.connect(self._onEngineCreated)
|
self.engineCreatedSignal.connect(self._onEngineCreated)
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ from PyQt5.QtCore import pyqtProperty, Qt, pyqtSignal, pyqtSlot, QUrl
|
||||||
|
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
from UM.Qt.ListModel import ListModel
|
from UM.Qt.ListModel import ListModel
|
||||||
|
from UM.Preferences import Preferences
|
||||||
from UM.Resources import Resources
|
from UM.Resources import Resources
|
||||||
from UM.MimeTypeDatabase import MimeTypeDatabase, MimeTypeNotFoundError
|
from UM.MimeTypeDatabase import MimeTypeDatabase, MimeTypeNotFoundError
|
||||||
|
|
||||||
|
@ -27,11 +27,18 @@ class SettingVisibilityPresetsModel(ListModel):
|
||||||
self.addRoleName(self.NameRole, "name")
|
self.addRoleName(self.NameRole, "name")
|
||||||
self.addRoleName(self.SettingsRole, "settings")
|
self.addRoleName(self.SettingsRole, "settings")
|
||||||
|
|
||||||
self._container_ids = []
|
|
||||||
self._containers = []
|
|
||||||
|
|
||||||
self._populate()
|
self._populate()
|
||||||
|
|
||||||
|
preferences = Preferences.getInstance()
|
||||||
|
preferences.addPreference("cura/active_setting_visibility_preset", "custom")
|
||||||
|
|
||||||
|
self._active_preset = Preferences.getInstance().getValue("cura/active_setting_visibility_preset")
|
||||||
|
if self.find("id", self._active_preset) < 0:
|
||||||
|
self._active_preset = "custom"
|
||||||
|
|
||||||
|
self.activePresetChanged.emit()
|
||||||
|
|
||||||
|
|
||||||
def _populate(self):
|
def _populate(self):
|
||||||
items = []
|
items = []
|
||||||
for item in Resources.getAllResourcesOfType(cura.CuraApplication.CuraApplication.ResourceTypes.SettingVisibilityPreset):
|
for item in Resources.getAllResourcesOfType(cura.CuraApplication.CuraApplication.ResourceTypes.SettingVisibilityPreset):
|
||||||
|
@ -77,6 +84,23 @@ class SettingVisibilityPresetsModel(ListModel):
|
||||||
items.sort(key = lambda k: (k["weight"], k["id"]))
|
items.sort(key = lambda k: (k["weight"], k["id"]))
|
||||||
self.setItems(items)
|
self.setItems(items)
|
||||||
|
|
||||||
|
@pyqtSlot(str)
|
||||||
|
def setActivePreset(self, preset_id):
|
||||||
|
if preset_id != "custom" and self.find("id", preset_id) == -1:
|
||||||
|
Logger.log("w", "Tried to set active preset to unknown id %s", preset_id)
|
||||||
|
return
|
||||||
|
|
||||||
|
Preferences.getInstance().setValue("cura/active_setting_visibility_preset", preset_id);
|
||||||
|
|
||||||
|
self._active_preset = preset_id
|
||||||
|
self.activePresetChanged.emit()
|
||||||
|
|
||||||
|
activePresetChanged = pyqtSignal()
|
||||||
|
|
||||||
|
@pyqtProperty(str, notify = activePresetChanged)
|
||||||
|
def activePreset(self):
|
||||||
|
return self._active_preset
|
||||||
|
|
||||||
# Factory function, used by QML
|
# Factory function, used by QML
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def createSettingVisibilityPresetsModel(engine, js_engine):
|
def createSettingVisibilityPresetsModel(engine, js_engine):
|
||||||
|
|
|
@ -453,7 +453,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
Logger.log("w", "Workspace did not contain visible settings. Leaving visibility unchanged")
|
Logger.log("w", "Workspace did not contain visible settings. Leaving visibility unchanged")
|
||||||
else:
|
else:
|
||||||
global_preferences.setValue("general/visible_settings", visible_settings)
|
global_preferences.setValue("general/visible_settings", visible_settings)
|
||||||
global_preferences.setValue("general/preset_setting_visibility_choice", "Custom")
|
global_preferences.setValue("cura/active_setting_visibility_preset", "custom")
|
||||||
|
|
||||||
categories_expanded = temp_preferences.getValue("cura/categories_expanded")
|
categories_expanded = temp_preferences.getValue("cura/categories_expanded")
|
||||||
if categories_expanded is None:
|
if categories_expanded is None:
|
||||||
|
|
|
@ -625,7 +625,10 @@ UM.MainWindow
|
||||||
{
|
{
|
||||||
preferences.visible = true;
|
preferences.visible = true;
|
||||||
preferences.setPage(1);
|
preferences.setPage(1);
|
||||||
preferences.getCurrentItem().scrollToSection(source.key);
|
if(source && source.key)
|
||||||
|
{
|
||||||
|
preferences.getCurrentItem().scrollToSection(source.key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,9 +32,13 @@ Menu
|
||||||
{
|
{
|
||||||
text: catalog.i18nc("@action:inmenu", "Custom selection")
|
text: catalog.i18nc("@action:inmenu", "Custom selection")
|
||||||
checkable: true
|
checkable: true
|
||||||
checked: !showingSearchResults && !showingAllSettings
|
checked: !showingSearchResults && !showingAllSettings && Cura.SettingVisibilityPresetsModel.activePreset == "custom"
|
||||||
exclusiveGroup: group
|
exclusiveGroup: group
|
||||||
onTriggered: showSettingVisibilityProfile("Custom")
|
onTriggered:
|
||||||
|
{
|
||||||
|
Cura.SettingVisibilityPresetsModel.setActivePreset("custom");
|
||||||
|
showSettingVisibilityProfile();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
MenuSeparator { }
|
MenuSeparator { }
|
||||||
|
|
||||||
|
@ -46,12 +50,13 @@ Menu
|
||||||
{
|
{
|
||||||
text: model.name
|
text: model.name
|
||||||
checkable: true
|
checkable: true
|
||||||
checked: false
|
checked: model.id == Cura.SettingVisibilityPresetsModel.activePreset
|
||||||
exclusiveGroup: group
|
exclusiveGroup: group
|
||||||
onTriggered:
|
onTriggered:
|
||||||
{
|
{
|
||||||
|
Cura.SettingVisibilityPresetsModel.setActivePreset(model.id);
|
||||||
|
|
||||||
UM.Preferences.setValue("general/visible_settings", model.settings.join(";"));
|
UM.Preferences.setValue("general/visible_settings", model.settings.join(";"));
|
||||||
UM.Preferences.setValue("general/preset_setting_visibility_choice", model.id);
|
|
||||||
|
|
||||||
showSettingVisibilityProfile();
|
showSettingVisibilityProfile();
|
||||||
}
|
}
|
||||||
|
@ -61,27 +66,6 @@ Menu
|
||||||
onObjectRemoved: menu.removeItem(object)
|
onObjectRemoved: menu.removeItem(object)
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuSeparator { visible: false }
|
|
||||||
MenuItem
|
|
||||||
{
|
|
||||||
text: catalog.i18nc("@action:inmenu", "Changed settings")
|
|
||||||
visible: false
|
|
||||||
enabled: true
|
|
||||||
checkable: true
|
|
||||||
checked: showingAllSettings
|
|
||||||
exclusiveGroup: group
|
|
||||||
onTriggered: showAllSettings()
|
|
||||||
}
|
|
||||||
MenuItem
|
|
||||||
{
|
|
||||||
text: catalog.i18nc("@action:inmenu", "Settings in profile")
|
|
||||||
visible: false
|
|
||||||
enabled: true
|
|
||||||
checkable: true
|
|
||||||
checked: showingAllSettings
|
|
||||||
exclusiveGroup: group
|
|
||||||
onTriggered: showAllSettings()
|
|
||||||
}
|
|
||||||
MenuSeparator {}
|
MenuSeparator {}
|
||||||
MenuItem
|
MenuItem
|
||||||
{
|
{
|
||||||
|
@ -89,7 +73,11 @@ Menu
|
||||||
checkable: true
|
checkable: true
|
||||||
checked: showingAllSettings
|
checked: showingAllSettings
|
||||||
exclusiveGroup: group
|
exclusiveGroup: group
|
||||||
onTriggered: showAllSettings()
|
onTriggered:
|
||||||
|
{
|
||||||
|
Cura.SettingVisibilityPresetsModel.setActivePreset("custom");
|
||||||
|
showAllSettings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
MenuSeparator {}
|
MenuSeparator {}
|
||||||
MenuItem
|
MenuItem
|
||||||
|
|
|
@ -37,6 +37,8 @@ UM.PreferencesPage
|
||||||
id: base;
|
id: base;
|
||||||
anchors.fill: parent;
|
anchors.fill: parent;
|
||||||
|
|
||||||
|
property bool inhibitSwitchToCustom: false
|
||||||
|
|
||||||
CheckBox
|
CheckBox
|
||||||
{
|
{
|
||||||
id: toggleVisibleSettings
|
id: toggleVisibleSettings
|
||||||
|
@ -84,7 +86,7 @@ UM.PreferencesPage
|
||||||
if (visibilityPreset.currentIndex != visibilityPreset.model.count - 1)
|
if (visibilityPreset.currentIndex != visibilityPreset.model.count - 1)
|
||||||
{
|
{
|
||||||
visibilityPreset.currentIndex = visibilityPreset.model.count - 1
|
visibilityPreset.currentIndex = visibilityPreset.model.count - 1
|
||||||
UM.Preferences.setValue("general/preset_setting_visibility_choice", visibilityPreset.model.getItem(visibilityPreset.currentIndex).id)
|
UM.Preferences.setValue("cura/active_setting_visibility_preset", visibilityPreset.model.getItem(visibilityPreset.currentIndex).id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,7 +131,7 @@ UM.PreferencesPage
|
||||||
currentIndex:
|
currentIndex:
|
||||||
{
|
{
|
||||||
// Load previously selected preset.
|
// Load previously selected preset.
|
||||||
var index = model.find("id", UM.Preferences.getValue("general/preset_setting_visibility_choice"));
|
var index = model.find("id", model.activePreset);
|
||||||
if(index == -1)
|
if(index == -1)
|
||||||
{
|
{
|
||||||
index = 0;
|
index = 0;
|
||||||
|
@ -140,14 +142,12 @@ UM.PreferencesPage
|
||||||
|
|
||||||
onActivated:
|
onActivated:
|
||||||
{
|
{
|
||||||
// TODO What to do if user is selected "Custom from Combobox" ?
|
base.inhibitSwitchToCustom = true;
|
||||||
if (model.getItem(index).id == "custom"){
|
model.setActivePreset(model.getItem(index).id);
|
||||||
UM.Preferences.setValue("general/preset_setting_visibility_choice", model.get(index).id)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
UM.Preferences.setValue("general/visible_settings", model.getItem(index).settings.join(";"))
|
UM.Preferences.setValue("general/visible_settings", model.getItem(index).settings.join(";"));
|
||||||
UM.Preferences.setValue("general/preset_setting_visibility_choice", model.getItem(index).id)
|
UM.Preferences.setValue("cura/active_setting_visibility_preset", model.getItem(index).id);
|
||||||
|
base.inhibitSwitchToCustom = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +177,16 @@ UM.PreferencesPage
|
||||||
exclude: ["machine_settings", "command_line_settings"]
|
exclude: ["machine_settings", "command_line_settings"]
|
||||||
showAncestors: true
|
showAncestors: true
|
||||||
expanded: ["*"]
|
expanded: ["*"]
|
||||||
visibilityHandler: UM.SettingPreferenceVisibilityHandler { }
|
visibilityHandler: UM.SettingPreferenceVisibilityHandler
|
||||||
|
{
|
||||||
|
onVisibilityChanged:
|
||||||
|
{
|
||||||
|
if(Cura.SettingVisibilityPresetsModel.activePreset != "" && !base.inhibitSwitchToCustom)
|
||||||
|
{
|
||||||
|
Cura.SettingVisibilityPresetsModel.setActivePreset("custom");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate: Loader
|
delegate: Loader
|
||||||
|
@ -220,19 +229,7 @@ UM.PreferencesPage
|
||||||
{
|
{
|
||||||
id: settingVisibilityItem;
|
id: settingVisibilityItem;
|
||||||
|
|
||||||
UM.SettingVisibilityItem {
|
UM.SettingVisibilityItem { }
|
||||||
|
|
||||||
// after changing any visibility of settings, set the preset to the "Custom" option
|
|
||||||
visibilityChangeCallback : function()
|
|
||||||
{
|
|
||||||
// If already "Custom" then don't do nothing
|
|
||||||
if (visibilityPreset.currentIndex != visibilityPreset.model.count - 1)
|
|
||||||
{
|
|
||||||
visibilityPreset.currentIndex = visibilityPreset.model.count - 1
|
|
||||||
UM.Preferences.setValue("general/preset_setting_visibility_choice", visibilityPreset.model.getItem(visibilityPreset.currentIndex).id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -18,6 +18,7 @@ Item
|
||||||
property Action configureSettings
|
property Action configureSettings
|
||||||
property bool findingSettings
|
property bool findingSettings
|
||||||
property bool showingAllSettings
|
property bool showingAllSettings
|
||||||
|
property bool inhibitSwitchToCustom: false
|
||||||
signal showTooltip(Item item, point location, string text)
|
signal showTooltip(Item item, point location, string text)
|
||||||
signal hideTooltip()
|
signal hideTooltip()
|
||||||
|
|
||||||
|
@ -559,7 +560,15 @@ Item
|
||||||
//: Settings context menu action
|
//: Settings context menu action
|
||||||
visible: !findingSettings;
|
visible: !findingSettings;
|
||||||
text: catalog.i18nc("@action:menu", "Hide this setting");
|
text: catalog.i18nc("@action:menu", "Hide this setting");
|
||||||
onTriggered: definitionsModel.hide(contextMenu.key);
|
onTriggered:
|
||||||
|
{
|
||||||
|
definitionsModel.hide(contextMenu.key);
|
||||||
|
// visible settings have changed, so we're no longer showing a preset
|
||||||
|
if (Cura.SettingVisibilityPresetsModel.activePreset != "")
|
||||||
|
{
|
||||||
|
Cura.SettingVisibilityPresetsModel.setActivePreset("custom");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
MenuItem
|
MenuItem
|
||||||
{
|
{
|
||||||
|
@ -586,6 +595,11 @@ Item
|
||||||
{
|
{
|
||||||
definitionsModel.show(contextMenu.key);
|
definitionsModel.show(contextMenu.key);
|
||||||
}
|
}
|
||||||
|
// visible settings have changed, so we're no longer showing a preset
|
||||||
|
if (Cura.SettingVisibilityPresetsModel.activePreset != "")
|
||||||
|
{
|
||||||
|
Cura.SettingVisibilityPresetsModel.setActivePreset("custom");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MenuItem
|
MenuItem
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue