Merge pull request #18653 from Ultimaker/CUR-11720-ucp-correct-ovverrides-ii

use notify to update `exportedSettingModel`
This commit is contained in:
Casper Lamboo 2024-03-18 17:05:30 +01:00 committed by GitHub
commit 22d860f4e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 3 deletions

View File

@ -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

View File

@ -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,10 +358,13 @@ 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
@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..."""

View File

@ -184,8 +184,9 @@ 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())
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
}