From c4c27334d54000e937b8a0facd1601406855d6f5 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sun, 23 Dec 2012 14:11:48 -0800 Subject: [PATCH] adding yomichan to toolbar --- yomi_base/anki_host.py | 14 +++++-------- yomichan.py | 46 +++--------------------------------------- 2 files changed, 8 insertions(+), 52 deletions(-) diff --git a/yomi_base/anki_host.py b/yomi_base/anki_host.py index bd2791d..d28bcb6 100644 --- a/yomi_base/anki_host.py +++ b/yomi_base/anki_host.py @@ -16,9 +16,9 @@ # along with this program. If not, see . -import ankiqt -from anki import hooks, lang -from ankiqt import ui +import aqt +#from anki import hooks, lang +#from ankiqt import ui import re @@ -88,15 +88,11 @@ class Anki: def window(self): - return ankiqt.mw + return aqt.mw def toolsMenu(self): - return self.window().mainWin.menuTools - - - def toolBar(self): - return self.window().mainWin.toolBar + return self.window().form.menuTools def addHook(self, name, callback): diff --git a/yomichan.py b/yomichan.py index 97d8915..08cdb96 100755 --- a/yomichan.py +++ b/yomichan.py @@ -46,9 +46,8 @@ class YomichanPlugin(Yomichan): self.action.setIconVisibleInMenu(True) self.action.triggered.connect(self.onShowRequest) - self.anki.addHook('loadDeck', self.onDeckLoad) - self.anki.addHook('deckClosed', self.onDeckClose) - + self.anki.toolsMenu().addAction(self.separator) + self.anki.toolsMenu().addAction(self.action) def onShowRequest(self): if self.window: @@ -61,8 +60,7 @@ class YomichanPlugin(Yomichan): self.languages, None, self.anki, - self.onWindowClose, - self.onWindowUpdate + self.onWindowClose ) self.window.show() @@ -71,44 +69,6 @@ class YomichanPlugin(Yomichan): self.window = None - def onWindowUpdate(self): - if self.preferences.ankiShowIcon: - self.showToolIcon() - else: - self.hideToolIcon() - - - def onDeckLoad(self): - self.anki.toolsMenu().addAction(self.separator) - self.anki.toolsMenu().addAction(self.action) - - if self.preferences.ankiShowIcon: - self.showToolIcon() - - - def onDeckClose(self): - self.anki.toolsMenu().removeAction(self.action) - self.anki.toolsMenu().removeAction(self.separator) - - self.hideToolIcon() - - if self.window: - self.window.close() - self.window = None - - - def hideToolIcon(self): - if self.toolIconVisible: - self.anki.toolBar().removeAction(self.action) - self.toolIconVisible = False - - - def showToolIcon(self): - if not self.toolIconVisible: - self.anki.toolBar().addAction(self.action) - self.toolIconVisible = True - - class YomichanStandalone(Yomichan): def __init__(self): Yomichan.__init__(self)