Skip to content

Commit

Permalink
move deleting of unmapped settings to action button on message
Browse files Browse the repository at this point in the history
Uranium does not support dynamically adding new menu items (only on initial load). Therefore, move the functionality into an action button on the message.
  • Loading branch information
Kriechi committed Jan 30, 2021
1 parent d9e8098 commit 4fccb8b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 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.3: 2021-01-30
* move deleting of unmapped settings to action button on message
* correctly bump plugin version metadata

## v1.2.2: 2021-01-27
* add OutputDevices on currently active printer after saving config
* remove OutputDevices on currently active printer after deleting config
Expand Down
38 changes: 27 additions & 11 deletions DuetRRFPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ def _check_unmapped_settings(self):

if self._found_unmapped:
Logger.log("d", "Unmapped settings found!")
self.addMenuItem(catalog.i18n("Show unmapped settings..."), self._showUnmappedSettingsMessage)
self.addMenuItem(catalog.i18n("Delete unmapped settings"), self._deleteUnmappedSettings)
self._showUnmappedSettingsMessage()
else:
Logger.log("d", "No unmapped settings found.")
Expand All @@ -75,9 +73,6 @@ def _showUnmappedSettingsMessage(self):
"→ Printers\n"
"→ activate and select your printer\n"
"→ click on 'Connect Duet RepRapFirmware'\n"
"\n"
"You can can delete unmapped settings of unknown printers via:\n"
"→ Extensions menu → DuetRRF → Delete unmapped settings"
)
if self._found_unmapped:
msg += "\n\n"
Expand All @@ -99,24 +94,45 @@ def _showUnmappedSettingsMessage(self):
lifetime=0,
title="DuetRRF: Settings moved to Cura Preferences!",
)
if self._found_unmapped:
message.addAction(
action_id="ignore",
name=catalog.i18nc("@action:button", "Ignore"),
icon="",
description="Close this message",
)
message.addAction(
action_id="delete",
name=catalog.i18nc("@action:button", "Delete"),
icon="",
description="Delete unmapped settings for unknown printers",
)
message.actionTriggered.connect(self._onActionTriggeredUnmappedSettings)
message.show()

def _deleteUnmappedSettings(self):
Logger.log("d", "called: {}".format(self._found_unmapped.keys()))
def _onActionTriggeredUnmappedSettings(self, message, action):
Logger.log("d", "called: {}, {}".format(action, self._found_unmapped.keys()))
message.hide()

if action == "ignore":
return
if action == "delete" and not self._found_unmapped:
return

for printer_id in self._found_unmapped.keys():
delete_config(printer_id)
if delete_config(printer_id):
Logger.log("d", "successfully delete unmapped settings for {}".format(printer_id))
else:
Logger.log("e", "failed to delete unmapped settings for {}".format(printer_id))

message = Message(
"Unmapped settings have been deleted for the following printers:\n{}\n\n"
"Please restart Cura.".format(
"Unmapped settings have been deleted for the following printers:\n{}\n\n".format(
",\n".join(self._found_unmapped.keys())
),
lifetime=5000,
title="DuetRRF: unmapped settings successfully deleted!",
)
message.show()

self._found_unmapped = {}

def _checkDuetRRFOutputDevices(self):
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"name": "DuetRRF",
"author": "Thomas Kriechbaumer",
"description": "Upload and Print to Duet 2 Wifi / Duet 2 Ethernet / Duet 2 Maestro / Duet 3 with RepRapFirmware.",
"version": "1.2.0",
"version": "1.2.3",
"supported_sdk_versions": ["7.3.0", "7.4.0"]
}

0 comments on commit 4fccb8b

Please sign in to comment.