mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 07:22:23 -04:00
fix edit & delete bugs in add-ons section
This commit is contained in:
parent
19cb527edf
commit
3afef3edb0
1 changed files with 6 additions and 5 deletions
|
@ -37,7 +37,9 @@ class AddonManager(object):
|
|||
|
||||
def directories(self):
|
||||
return [d for d in os.listdir(self.addonsFolder())
|
||||
if not d.startswith('.') and os.path.isdir(os.path.join(self.addonsFolder(), d))]
|
||||
if not d.startswith('.') and
|
||||
not d == "__pycache__" and
|
||||
os.path.isdir(os.path.join(self.addonsFolder(), d))]
|
||||
|
||||
def loadAddons(self):
|
||||
for file in self.files():
|
||||
|
@ -67,11 +69,10 @@ class AddonManager(object):
|
|||
m = self.mw.form.menuPlugins.addMenu(
|
||||
os.path.splitext(file)[0])
|
||||
self._menus.append(m)
|
||||
a = QAction(_("Edit..."), self.mw, triggered=self.onEdit)
|
||||
p = os.path.join(self.addonsFolder(), file)
|
||||
|
||||
a = QAction(_("Edit..."), self.mw, triggered=lambda x, y=p: self.onEdit(y))
|
||||
m.addAction(a)
|
||||
a = QAction(_("Delete..."), self.mw, triggered=self.onRem)
|
||||
a = QAction(_("Delete..."), self.mw, triggered=lambda x, y=p: self.onRem(y))
|
||||
m.addAction(a)
|
||||
|
||||
def onEdit(self, path):
|
||||
|
@ -84,7 +85,7 @@ class AddonManager(object):
|
|||
d.exec_()
|
||||
|
||||
def onAcceptEdit(self, path, frm):
|
||||
open(path, "w").write(frm.text.toPlainText().encode("utf8"))
|
||||
open(path, "wb").write(frm.text.toPlainText().encode("utf8"))
|
||||
showInfo(_("Edits saved. Please restart Anki."))
|
||||
|
||||
def onRem(self, path):
|
||||
|
|
Loading…
Reference in a new issue