From d9e809860bbc42429f3401f0ae67d91138c27b40 Mon Sep 17 00:00:00 2001 From: Thomas Kriechbaumer Date: Wed, 27 Jan 2021 21:55:47 +0100 Subject: [PATCH] properly reload OutputDevices on config changes --- CHANGELOG.md | 4 ++++ DuetRRFAction.py | 10 ++++++++-- DuetRRFPlugin.py | 2 +- build.sh | 2 ++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1b9093..6366b23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog of Cura-DuetRRFPlugin +## v1.2.2: 2021-01-27 + * add OutputDevices on currently active printer after saving config + * remove OutputDevices on currently active printer after deleting config + ## v1.2.1: 2021-01-21 * fix button width on high-dpi screens * fix race condition when checking for unmapped settings diff --git a/DuetRRFAction.py b/DuetRRFAction.py index 697928a..e2cea22 100644 --- a/DuetRRFAction.py +++ b/DuetRRFAction.py @@ -22,10 +22,10 @@ def __init__(self, parent: QObject = None) -> None: super().__init__("DuetRRFAction", catalog.i18nc("@action", "Connect Duet RepRapFirmware")) self._qml_url = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'resources', 'qml', 'DuetRRFAction.qml') - self._application = CuraApplication.getInstance() + self._application = CuraApplication.getInstance() + self._application.globalContainerStackChanged.connect(self._onGlobalContainerStackChanged) ContainerRegistry.getInstance().containerAdded.connect(self._onContainerAdded) - CuraApplication.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerStackChanged) def _onGlobalContainerStackChanged(self) -> None: self.printerSettingsUrlChanged.emit() @@ -89,10 +89,16 @@ def saveConfig(self, url, duet_password, http_user, http_password): save_config(url, duet_password, http_user, http_password) Logger.log("d", "config saved") + # trigger a stack change to reload the output devices + self._application.globalContainerStackChanged.emit() + @pyqtSlot() def deleteConfig(self): if delete_config(): Logger.log("d", "config deleted") + + # trigger a stack change to reload the output devices + self._application.globalContainerStackChanged.emit() else: Logger.log("d", "no config to delete") diff --git a/DuetRRFPlugin.py b/DuetRRFPlugin.py index 5f5eb54..dcd051c 100644 --- a/DuetRRFPlugin.py +++ b/DuetRRFPlugin.py @@ -126,7 +126,7 @@ def _checkDuetRRFOutputDevices(self): manager = self.getOutputDeviceManager() - # remove all DuetRRF output devices - the new stack might not need them + # remove all DuetRRF output devices - the new stack might not need them or have a different config manager.removeOutputDevice("duetrrf-configure") manager.removeOutputDevice("duetrrf-print") manager.removeOutputDevice("duetrrf-simulate") diff --git a/build.sh b/build.sh index c685511..2f32064 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +set -o errexit + TAG=$(git describe --abbrev=0 --tags --exact-match) git archive ${TAG} --prefix=DuetRRFPlugin/ --format=zip -o ~/Downloads/DuetRRFPlugin_${TAG}.zip