1

adding yomichan to toolbar

This commit is contained in:
Alex Yatskov 2012-12-23 14:11:48 -08:00
parent 2274c85ec9
commit c4c27334d5
2 changed files with 8 additions and 52 deletions

View File

@ -16,9 +16,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
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):

View File

@ -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)