Merge pull request #251 from upday7/master

disable form.viewPage button when add-on was not downloaded from AnkiWeb
This commit is contained in:
Damien Elmes 2018-09-02 18:03:14 +10:00 committed by GitHub
commit 36b763e45f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -302,6 +302,7 @@ class AddonsDialog(QDialog):
f.viewFiles.clicked.connect(self.onViewFiles)
f.delete_2.clicked.connect(self.onDelete)
f.config.clicked.connect(self.onConfig)
self.form.addonList.currentRowChanged.connect(self._onAddonItemSelected)
self.redrawAddons()
self.show()
@ -313,6 +314,13 @@ class AddonsDialog(QDialog):
if self.addons:
self.form.addonList.setCurrentRow(0)
def _onAddonItemSelected(self, row_int):
try:
addon = self.addons[row_int][1]
except IndexError:
addon = ''
self.form.viewPage.setEnabled(bool (re.match(r"^\d+$", addon)))
def annotatedName(self, dir):
meta = self.mgr.addonMeta(dir)
buf = self.mgr.addonName(dir)