PICARD-1624: Update default CD lookup shortcut on option save

This ensures the CD lookup keyboard shortcut uses the correct CD drive if the user changed it in options.
This commit is contained in:
Philipp Wolfer
2019-10-04 09:28:58 +02:00
parent ace0f60da6
commit 9792820eb6
2 changed files with 8 additions and 3 deletions

View File

@@ -565,14 +565,18 @@ class MainWindow(QtWidgets.QMainWindow, PreserveGeometry):
self.check_update_action.triggered.connect(self.do_update_check)
def _update_cd_lookup_actions(self, result=None, error=None):
drives = result
if error:
log.error("CDROM: Error on CD-ROM drive detection: %r", error)
elif not drives:
else:
self.update_cd_lookup_drives(result)
def update_cd_lookup_drives(self, drives):
if not drives:
log.warning("CDROM: No CD-ROM drives found - Lookup CD functionality disabled")
else:
shortcut_drive = config.setting["cd_lookup_device"].split(",")[0] if len(drives) > 1 else ""
self.cd_lookup_action.setEnabled(True)
self.cd_lookup_action.setEnabled(discid is not None)
self.cd_lookup_menu.clear()
for drive in drives:
action = self.cd_lookup_menu.addAction(drive)
action.setData(drive)

View File

@@ -72,6 +72,7 @@ class CDLookupOptionsPage(OptionsPage):
config.setting["cd_lookup_device"] = self.ui.cd_lookup_device.currentText()
else:
config.setting["cd_lookup_device"] = self.ui.cd_lookup_device.text()
self.tagger.window.update_cd_lookup_drives(self.drives)
register_options_page(CDLookupOptionsPage)