diff --git a/plugins/3MFReader/SpecificSettingsModel.py b/plugins/3MFReader/SpecificSettingsModel.py index af203ad759f..1b1319d3915 100644 --- a/plugins/3MFReader/SpecificSettingsModel.py +++ b/plugins/3MFReader/SpecificSettingsModel.py @@ -3,6 +3,7 @@ from PyQt6.QtCore import Qt, pyqtSignal +from UM import i18nCatalog from UM.Logger import Logger from UM.Settings.SettingDefinition import SettingDefinition from UM.Qt.ListModel import ListModel @@ -19,7 +20,7 @@ def __init__(self, parent = None): self.addRoleName(self.LabelRole, "label") self.addRoleName(self.ValueRole, "value") - self._i18n_catalog = None + self._settings_catalog = i18nCatalog("fdmprinter.def.json") self._update() modelChanged = pyqtSignal() @@ -32,13 +33,24 @@ def addSettingsFromStack(self, stack, category, settings): 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) + value = str(SettingDefinition.settingValueToString(setting_type, value)) + if unit: + value += " " + str(unit) + if setting_type == "enum": + options = stack.getProperty(setting, "options") + value_msgctxt = f"{str(setting)} option {str(value)}" + value_msgid = options[stack.getProperty(setting, "value")] + value = self._settings_catalog.i18nc(value_msgctxt, value_msgid) else: value = str(value) + label_msgctxt = f"{str(setting)} label" + label_msgid = stack.getProperty(setting, "label") + label = self._settings_catalog.i18nc(label_msgctxt, label_msgid) + self.appendItem({ "category": category, - "label": stack.getProperty(setting, "label"), + "label": label, "value": value }) self.modelChanged.emit() diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index eeb33da4c7b..adb070e8623 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -216,6 +216,16 @@ UM.Dialog headers: ["category", "label", "value"] rows: manager.exportedSettingModelItems } + + Connections + { + target: manager + function onExportedSettingModelChanged() + { + tableModel.clear() + tableModel.rows = manager.exportedSettingModelItems + } + } } } diff --git a/plugins/3MFWriter/SettingExport.py b/plugins/3MFWriter/SettingExport.py index dca72ddffae..61c7d91b545 100644 --- a/plugins/3MFWriter/SettingExport.py +++ b/plugins/3MFWriter/SettingExport.py @@ -6,11 +6,12 @@ class SettingExport(QObject): - def __init__(self, id, name, value, selectable, show): + def __init__(self, id, name, value, value_name, selectable, show): super().__init__() self.id = id self._name = name self._value = value + self._value_name = value_name self._selected = selectable self._selectable = selectable self._show_in_menu = show @@ -23,6 +24,10 @@ def name(self): def value(self): return self._value + @pyqtProperty(str, constant=True) + def valuename(self): + return str(self._value_name) + selectedChanged = pyqtSignal(bool) def setSelected(self, selected): diff --git a/plugins/3MFWriter/SettingSelection.qml b/plugins/3MFWriter/SettingSelection.qml index 53594153b7f..85c2f636aa5 100644 --- a/plugins/3MFWriter/SettingSelection.qml +++ b/plugins/3MFWriter/SettingSelection.qml @@ -24,7 +24,7 @@ RowLayout UM.Label { - text: modelData.value + text: modelData.valuename } UM.HelpIcon diff --git a/plugins/3MFWriter/SettingsExportModel.py b/plugins/3MFWriter/SettingsExportModel.py index 10b7f8f775b..0ee8885adaf 100644 --- a/plugins/3MFWriter/SettingsExportModel.py +++ b/plugins/3MFWriter/SettingsExportModel.py @@ -6,6 +6,7 @@ from PyQt6.QtCore import QObject, pyqtProperty +from UM import i18nCatalog from UM.Settings.SettingDefinition import SettingDefinition from UM.Settings.InstanceContainer import InstanceContainer from UM.Settings.SettingFunction import SettingFunction @@ -109,6 +110,7 @@ def settingsGroups(self) -> List[SettingsExportGroup]: @staticmethod def _exportSettings(settings_stack): + settings_catalog = i18nCatalog("fdmprinter.def.json") user_settings_container = settings_stack.userChanges user_keys = user_settings_container.getAllKeys() exportable_settings = SettingsExportModel.EXPORTABLE_SETTINGS @@ -118,9 +120,15 @@ def _exportSettings(settings_stack): for setting_to_export in user_keys: show_in_menu = setting_to_export not in SettingsExportModel.PER_MODEL_EXPORTABLE_SETTINGS_KEYS - label = settings_stack.getProperty(setting_to_export, "label") + label_msgtxt = f"{str(setting_to_export)} label" + label_msgid = settings_stack.getProperty(setting_to_export, "label") + label = settings_catalog.i18nc(label_msgtxt, label_msgid) value = settings_stack.getProperty(setting_to_export, "value") unit = settings_stack.getProperty(setting_to_export, "unit") + options = settings_stack.getProperty(setting_to_export, "options") + value_msgctxt = f"{str(setting_to_export)} option {str(value)}" + value_msgid = options.get(value, "") + value_name = settings_catalog.i18nc(value_msgctxt, value_msgid) setting_type = settings_stack.getProperty(setting_to_export, "type") if setting_type is not None: @@ -131,6 +139,7 @@ def _exportSettings(settings_stack): settings_export.append(SettingExport(setting_to_export, label, value, + value_name, is_exportable or setting_to_export in exportable_settings, show_in_menu))