Add "all" as a setting visibility preset

CURA-7082
This commit is contained in:
Jaime van Kessel 2020-01-02 10:51:40 +01:00
parent 1915100118
commit 8b393317ff
No known key found for this signature in database
GPG key ID: 3710727397403C91
4 changed files with 12 additions and 26 deletions

View file

@ -77,6 +77,10 @@ class SettingVisibilityPresetsModel(QObject):
items.append(setting_visibility_preset)
# Add the "all" visibility:
all_setting_visibility_preset = SettingVisibilityPreset(preset_id = "all", name = "All", weight = 9001)
all_setting_visibility_preset.setSettings(list(CuraApplication.getInstance().getMachineManager().getAllSettingKeys()))
items.append(all_setting_visibility_preset)
# Sort them on weight (and if that fails, use ID)
items.sort(key = lambda k: (int(k.weight), k.presetId))

View file

@ -4,12 +4,11 @@
import time
import re
import unicodedata
from typing import Any, List, Dict, TYPE_CHECKING, Optional, cast
from typing import Any, List, Dict, TYPE_CHECKING, Optional, cast, Set
from PyQt5.QtCore import QObject, pyqtProperty, pyqtSignal, QTimer
from UM.ConfigurationErrorMessage import ConfigurationErrorMessage
from UM.Decorators import deprecated
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
from UM.Settings.InstanceContainer import InstanceContainer
from UM.Settings.Interfaces import ContainerInterface
@ -212,10 +211,13 @@ class MachineManager(QObject):
@pyqtProperty(int, constant=True)
def totalNumberOfSettings(self) -> int:
return len(self.getAllSettingKeys())
def getAllSettingKeys(self) -> Set[str]:
general_definition_containers = CuraContainerRegistry.getInstance().findDefinitionContainers(id="fdmprinter")
if not general_definition_containers:
return 0
return len(general_definition_containers[0].getAllKeys())
return set()
return general_definition_containers[0].getAllKeys()
## Triggered when the global container stack is changed in CuraApplication.
def _onGlobalContainerChanged(self) -> None:

View file

@ -14,8 +14,6 @@ Menu
property QtObject settingVisibilityPresetsModel: CuraApplication.getSettingVisibilityPresetsModel()
signal showAllSettings()
Instantiator
{
model: settingVisibilityPresetsModel.items
@ -36,17 +34,6 @@ Menu
onObjectRemoved: menu.removeItem(object)
}
MenuSeparator {}
MenuItem
{
text: catalog.i18nc("@action:inmenu", "Show All Settings")
checkable: false
exclusiveGroup: group
onTriggered:
{
showAllSettings();
}
}
MenuSeparator {}
MenuItem
{

View file

@ -185,14 +185,7 @@ Item
label: Label {}
}
menu: SettingVisibilityPresetsMenu
{
onShowAllSettings:
{
definitionsModel.setAllVisible(true)
filter.updateDefinitionModel()
}
}
menu: SettingVisibilityPresetsMenu {}
}
// Mouse area that gathers the scroll events to not propagate it to the main view.