From 40bc08f482bd9529be1a8f00f41b9b3fbf5a8109 Mon Sep 17 00:00:00 2001 From: Saumya Jain Date: Thu, 14 Mar 2024 17:09:11 +0100 Subject: [PATCH 1/4] Apparantly the first time override is written it is not overriden by next upload. Now, it does CURA-11720 --- plugins/3MFReader/WorkspaceDialog.qml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index a8cdad92bd..f0f74b60b7 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -171,6 +171,7 @@ UM.Dialog WorkspaceRow { + id: numberOfOverrides leftLabelText: catalog.i18nc("@action:label", "Settings Loaded from UCP file") rightLabelText: catalog.i18ncp("@action:label", "%1 override", "%1 overrides", manager.exportedSettingModel.rowCount()).arg(manager.exportedSettingModel.rowCount()) buttonText: tableViewSpecificSettings.shouldBeVisible ? catalog.i18nc("@action:button", "Hide settings") : catalog.i18nc("@action:button", "Show settings") @@ -204,6 +205,7 @@ UM.Dialog { tableModel.clear() tableModel.rows = modelRows + numberOfOverrides.rightLabelText = catalog.i18ncp("@action:label", "%1 override", "%1 overrides", manager.exportedSettingModel.rowCount()).arg(manager.exportedSettingModel.rowCount()) } } From a58cd69b394d4f81d94644b1d2cb2ecea9b6d97d Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Mon, 18 Mar 2024 11:54:23 +0100 Subject: [PATCH 2/4] use notify to update `exportedSettingModel` --- plugins/3MFReader/SpecificSettingsModel.py | 6 +++++- plugins/3MFReader/WorkspaceDialog.py | 4 +++- plugins/3MFReader/WorkspaceDialog.qml | 1 - 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/3MFReader/SpecificSettingsModel.py b/plugins/3MFReader/SpecificSettingsModel.py index ac8e7af3ef..ec4a68e337 100644 --- a/plugins/3MFReader/SpecificSettingsModel.py +++ b/plugins/3MFReader/SpecificSettingsModel.py @@ -1,7 +1,7 @@ # Copyright (c) 2024 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. -from PyQt6.QtCore import Qt +from PyQt6.QtCore import Qt, pyqtSignal from UM.Logger import Logger from UM.Settings.SettingDefinition import SettingDefinition @@ -22,6 +22,8 @@ class SpecificSettingsModel(ListModel): self._i18n_catalog = None self._update() + modelChanged = pyqtSignal() + def addSettingsFromStack(self, stack, category, settings): for setting, value in settings.items(): @@ -39,8 +41,10 @@ class SpecificSettingsModel(ListModel): "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 diff --git a/plugins/3MFReader/WorkspaceDialog.py b/plugins/3MFReader/WorkspaceDialog.py index 4b9f1eaa6f..13851c041d 100644 --- a/plugins/3MFReader/WorkspaceDialog.py +++ b/plugins/3MFReader/WorkspaceDialog.py @@ -77,6 +77,7 @@ class WorkspaceDialog(QObject): self._is_compatible_machine = False self._allow_create_machine = True self._exported_settings_model = SpecificSettingsModel() + self._exported_settings_model.modelChanged.connect(self.exportedSettingModelChanged.emit) self._current_machine_pos_index = 0 self._is_ucp = False @@ -104,6 +105,7 @@ class WorkspaceDialog(QObject): missingPackagesChanged = pyqtSignal() isCompatibleMachineChanged = pyqtSignal() isUcpChanged = pyqtSignal() + exportedSettingModelChanged = pyqtSignal() @pyqtProperty(bool, notify = isPrinterGroupChanged) def isPrinterGroup(self) -> bool: @@ -356,7 +358,7 @@ class WorkspaceDialog(QObject): def allowCreateMachine(self): return self._allow_create_machine - @pyqtProperty(QObject) + @pyqtProperty(QObject, notify=exportedSettingModelChanged) def exportedSettingModel(self): return self._exported_settings_model diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index f0f74b60b7..95dce875c1 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -205,7 +205,6 @@ UM.Dialog { tableModel.clear() tableModel.rows = modelRows - numberOfOverrides.rightLabelText = catalog.i18ncp("@action:label", "%1 override", "%1 overrides", manager.exportedSettingModel.rowCount()).arg(manager.exportedSettingModel.rowCount()) } } From 4dd0113a784687c0fd0ed5397acb9a4bf01d428c Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Mon, 18 Mar 2024 12:14:58 +0100 Subject: [PATCH 3/4] Add dedicate functions for `exportedSettingModelItems` and `exportedSettingModelRowCount` --- plugins/3MFReader/WorkspaceDialog.py | 7 +++++++ plugins/3MFReader/WorkspaceDialog.qml | 11 ++--------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/plugins/3MFReader/WorkspaceDialog.py b/plugins/3MFReader/WorkspaceDialog.py index 13851c041d..c3e4187652 100644 --- a/plugins/3MFReader/WorkspaceDialog.py +++ b/plugins/3MFReader/WorkspaceDialog.py @@ -362,6 +362,13 @@ class WorkspaceDialog(QObject): def exportedSettingModel(self): return self._exported_settings_model + @pyqtProperty("QVariantList", notify=exportedSettingModelChanged) + def exportedSettingModelItems(self): + return self._exported_settings_model.items + + @pyqtProperty(int, notify=exportedSettingModelChanged) + def exportedSettingModelRowCount(self): + return self._exported_settings_model.rowCount() @pyqtSlot() def closeBackend(self) -> None: """Close the backend: otherwise one could end up with "Slicing...""" diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index 95dce875c1..950c72a3d6 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -173,7 +173,7 @@ UM.Dialog { id: numberOfOverrides leftLabelText: catalog.i18nc("@action:label", "Settings Loaded from UCP file") - rightLabelText: catalog.i18ncp("@action:label", "%1 override", "%1 overrides", manager.exportedSettingModel.rowCount()).arg(manager.exportedSettingModel.rowCount()) + rightLabelText: catalog.i18ncp("@action:label", "%1 override", "%1 overrides", manager.exportedSettingModelRowCount).arg(manager.exportedSettingModelRowCount) buttonText: tableViewSpecificSettings.shouldBeVisible ? catalog.i18nc("@action:button", "Hide settings") : catalog.i18nc("@action:button", "Show settings") onButtonClicked: tableViewSpecificSettings.shouldBeVisible = !tableViewSpecificSettings.shouldBeVisible } @@ -196,16 +196,9 @@ UM.Dialog { id: tableModel headers: ["category", "label", "value"] - rows: manager.exportedSettingModel.items + rows: manager.exportedSettingModelItems } } - - property var modelRows: manager.exportedSettingModel.items - onModelRowsChanged: - { - tableModel.clear() - tableModel.rows = modelRows - } } comboboxVisible: manager.qualityChangesConflict From 4da17d643d91cb10b0185770c550dfc0f147e38f Mon Sep 17 00:00:00 2001 From: Saumya Jain Date: Mon, 18 Mar 2024 12:46:10 +0100 Subject: [PATCH 4/4] Update model data handling in 3MFReader plugin partially revert 4dd0113a784687c0fd0ed5397acb9a4bf01d428c CURA-11720 --- plugins/3MFReader/WorkspaceDialog.py | 4 ---- plugins/3MFReader/WorkspaceDialog.qml | 9 ++++++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/3MFReader/WorkspaceDialog.py b/plugins/3MFReader/WorkspaceDialog.py index c3e4187652..bc4581b749 100644 --- a/plugins/3MFReader/WorkspaceDialog.py +++ b/plugins/3MFReader/WorkspaceDialog.py @@ -362,10 +362,6 @@ class WorkspaceDialog(QObject): def exportedSettingModel(self): return self._exported_settings_model - @pyqtProperty("QVariantList", notify=exportedSettingModelChanged) - def exportedSettingModelItems(self): - return self._exported_settings_model.items - @pyqtProperty(int, notify=exportedSettingModelChanged) def exportedSettingModelRowCount(self): return self._exported_settings_model.rowCount() diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index d7e776411f..febd082a4c 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -209,9 +209,16 @@ UM.Dialog { id: tableModel headers: ["category", "label", "value"] - rows: manager.exportedSettingModelItems + rows: manager.exportedSettingModel.items } } + + property var modelRows: manager.exportedSettingModel.items + onModelRowsChanged: + { + tableModel.clear() + tableModel.rows = modelRows + } } comboboxVisible: manager.qualityChangesConflict