mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -06:00

Added a connection in WorkspaceDialog.qml to call function whenever the 'exportedSettingModel' changes. This ensures that any changes in the model will now be reflected in the UI table. Furthermore, an added adjustment in SpecificSettingsModel.py now correctly handles the enum type settings, retrieving the correct value from the options list. CURA-11783
54 lines
1.8 KiB
Python
54 lines
1.8 KiB
Python
# Copyright (c) 2024 Ultimaker B.V.
|
|
# Cura is released under the terms of the LGPLv3 or higher.
|
|
|
|
from PyQt6.QtCore import Qt, pyqtSignal
|
|
|
|
from UM.Logger import Logger
|
|
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
|
|
self._update()
|
|
|
|
modelChanged = pyqtSignal()
|
|
|
|
|
|
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 = str(SettingDefinition.settingValueToString(setting_type, value)) + " " + str(unit)
|
|
if setting_type == "enum":
|
|
options = stack.getProperty(setting, "options")
|
|
value = options[stack.getProperty(setting, "value")]
|
|
|
|
else:
|
|
value = str(value)
|
|
|
|
self.appendItem({
|
|
"category": category,
|
|
"label": stack.getProperty(setting, "label"),
|
|
"value": value
|
|
})
|
|
self.modelChanged.emit()
|
|
|
|
def _update(self):
|
|
Logger.debug(f"Updating {self.__class__.__name__}")
|
|
self.setItems([])
|
|
self.modelChanged.emit()
|
|
return
|