tooltips for cram/options

This commit is contained in:
Damien Elmes 2012-04-17 19:30:26 +09:00
parent e639d3c227
commit b57b2aa66a
2 changed files with 23 additions and 12 deletions

View file

@ -3,7 +3,8 @@
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
from aqt.qt import * from aqt.qt import *
from aqt.utils import askUser, getOnlyText, openLink, showWarning, showInfo from aqt.utils import askUser, getOnlyText, openLink, showWarning, showInfo, \
shortcut
from anki.utils import isMac from anki.utils import isMac
import anki.js import anki.js
from anki.errors import DeckRenameError from anki.errors import DeckRenameError
@ -232,14 +233,17 @@ Are you sure you wish to delete %s and all its cards?""")%deck['name']):
def _drawButtons(self): def _drawButtons(self):
links = [ links = [
["shared", _("Get Shared")], ["", "shared", _("Get Shared")],
["create", _("Create")], ["", "create", _("Create")],
["import", _("Import File")], ["Ctrl+i", "import", _("Import File")],
["cram", _("Cram")], ["c", "cram", _("Cram")],
] ]
buf = "" buf = ""
for b in links: for b in links:
buf += "<button onclick='py.link(\"%s\");'>%s</button>" % tuple(b) if b[0]:
b[0] = _("Shortcut key: %s") % shortcut(b[0])
buf += """
<button title='%s' onclick='py.link(\"%s\");'>%s</button>""" % tuple(b)
self.bottom.draw(buf) self.bottom.draw(buf)
self.bottom.web.setFixedHeight(isMac and 28 or 36) self.bottom.web.setFixedHeight(isMac and 28 or 36)
self.bottom.web.setLinkHandler(self._linkHandler) self.bottom.web.setLinkHandler(self._linkHandler)

View file

@ -6,7 +6,7 @@ import simplejson
from aqt.qt import * from aqt.qt import *
from anki.consts import NEW_CARDS_RANDOM, dynOrderLabels from anki.consts import NEW_CARDS_RANDOM, dynOrderLabels
from anki.hooks import addHook from anki.hooks import addHook
from aqt.utils import showInfo, openLink from aqt.utils import showInfo, openLink, shortcut
from anki.utils import isMac from anki.utils import isMac
import aqt import aqt
from anki.sound import clearAudioQueue from anki.sound import clearAudioQueue
@ -55,11 +55,15 @@ class Overview(object):
openLink(aqt.appShared+"info/%s?v=%s"%(self.sid, self.sidVer)) openLink(aqt.appShared+"info/%s?v=%s"%(self.sid, self.sidVer))
def _keyHandler(self, evt): def _keyHandler(self, evt):
cram = self.mw.col.decks.current()['dyn']
key = unicode(evt.text()) key = unicode(evt.text())
if key == "o": if key == "o":
self.mw.onDeckConf() self.mw.onDeckConf()
if key == "c": if key == "c" and not cram:
self.mw.onCram() self.mw.onCram()
if key == "r" and cram:
self.mw.col.sched.rebuildDyn()
self.mw.reset()
# HTML # HTML
############################################################ ############################################################
@ -168,15 +172,18 @@ text-align: center;
def _renderBottom(self): def _renderBottom(self):
links = [ links = [
["opts", _("Options")], ["o", "opts", _("Options")],
] ]
if self.mw.col.decks.current()['dyn']: if self.mw.col.decks.current()['dyn']:
links.append(["refresh", _("Rebuild")]) links.append(["r", "refresh", _("Rebuild")])
else: else:
links.append(["cram", _("Cram")]) links.append(["c", "cram", _("Cram")])
buf = "" buf = ""
for b in links: for b in links:
buf += "<button onclick='py.link(\"%s\");'>%s</button>" % tuple(b) if b[0]:
b[0] = _("Shortcut key: %s") % shortcut(b[0])
buf += """
<button title="%s" onclick='py.link(\"%s\");'>%s</button>""" % tuple(b)
self.bottom.draw(buf) self.bottom.draw(buf)
self.bottom.web.setFixedHeight(isMac and 28 or 36) self.bottom.web.setFixedHeight(isMac and 28 or 36)
self.bottom.web.setLinkHandler(self._linkHandler) self.bottom.web.setLinkHandler(self._linkHandler)