Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/5.7' into 5.7
Browse files Browse the repository at this point in the history
  • Loading branch information
casperlamboo committed Mar 29, 2024
2 parents 600f5cd + 6d59664 commit 16ce5c8
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 6 deletions.
18 changes: 15 additions & 3 deletions plugins/3MFReader/SpecificSettingsModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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()
Expand Down
10 changes: 10 additions & 0 deletions plugins/3MFReader/WorkspaceDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,16 @@ UM.Dialog
headers: ["category", "label", "value"]
rows: manager.exportedSettingModelItems
}

Connections
{
target: manager
function onExportedSettingModelChanged()
{
tableModel.clear()
tableModel.rows = manager.exportedSettingModelItems
}
}
}
}

Expand Down
7 changes: 6 additions & 1 deletion plugins/3MFWriter/SettingExport.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion plugins/3MFWriter/SettingSelection.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RowLayout

UM.Label
{
text: modelData.value
text: modelData.valuename
}

UM.HelpIcon
Expand Down
11 changes: 10 additions & 1 deletion plugins/3MFWriter/SettingsExportModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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))

Expand Down

0 comments on commit 16ce5c8

Please sign in to comment.