1234567891011121314151617181920212223242526272829303132333435363738 |
- # Copyright (c) 2024 Ultimaker B.V.
- # Cura is released under the terms of the LGPLv3 or higher.
- from PyQt6.QtCore import Qt
- from UM.Settings.SettingDefinition import SettingDefinition
- from UM.Qt.ListModel import ListModel
- class SpecificSettingsModel(ListModel):
- CategoryRole = Qt.ItemDataRole.UserRole + 1
- LabelRole = Qt.ItemDataRole.UserRole + 2
- ValueRole = Qt.ItemDataRole.UserRole + 3
- def __init__(self, parent = None):
- super().__init__(parent = parent)
- self.addRoleName(self.CategoryRole, "category")
- self.addRoleName(self.LabelRole, "label")
- self.addRoleName(self.ValueRole, "value")
- self._i18n_catalog = None
- def addSettingsFromStack(self, stack, category, settings):
- for setting, value in settings.items():
- unit = stack.getProperty(setting, "unit")
- setting_type = stack.getProperty(setting, "type")
- if setting_type is not None:
- # This is not very good looking, but will do for now
- value = SettingDefinition.settingValueToString(setting_type, value) + " " + unit
- else:
- value = str(value)
- self.appendItem({
- "category": category,
- "label": stack.getProperty(setting, "label"),
- "value": value
- })
|