Skip to content

Commit

Permalink
properly reload OutputDevices on config changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kriechi committed Jan 27, 2021
1 parent ab8aebc commit d9e8098
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 8 additions & 2 deletions DuetRRFAction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion DuetRRFPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit d9e8098

Please sign in to comment.