mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 17:18:58 +08:00
Merge pull request #18653 from Ultimaker/CUR-11720-ucp-correct-ovverrides-ii
use notify to update `exportedSettingModel`
This commit is contained in:
commit
22d860f4e2
@ -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
|
||||
|
@ -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..."""
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user