mirror of
https://github.com/ankitects/anki.git
synced 2025-09-22 07:52:24 -04:00
tooltips
This commit is contained in:
parent
7909181f32
commit
ac7602675a
5 changed files with 73 additions and 46 deletions
|
@ -1422,9 +1422,9 @@ class BrowserToolbar(Toolbar):
|
||||||
|
|
||||||
def _centerLinks(self):
|
def _centerLinks(self):
|
||||||
links = [
|
links = [
|
||||||
["setDeck", _("Move to Deck")],
|
["setDeck", _("Move to Deck"), ""],
|
||||||
["addTags", _("Add Tags")],
|
["addTags", _("Add Tags"), ""],
|
||||||
["remTags", _("Remove Tags")],
|
["remTags", _("Remove Tags"), ""],
|
||||||
]
|
]
|
||||||
return self._linkHTML(links)
|
return self._linkHTML(links)
|
||||||
|
|
||||||
|
|
|
@ -234,7 +234,7 @@ class Editor(object):
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
def _addButton(self, name, func, key=None, tip=None, size=True, text="",
|
def _addButton(self, name, func, key=None, tip=None, size=True, text="",
|
||||||
check=False, native=False):
|
check=False, native=False, canDisable=True):
|
||||||
b = QPushButton(text)
|
b = QPushButton(text)
|
||||||
if check:
|
if check:
|
||||||
b.connect(b, SIGNAL("clicked(bool)"), func)
|
b.connect(b, SIGNAL("clicked(bool)"), func)
|
||||||
|
@ -255,6 +255,7 @@ class Editor(object):
|
||||||
if check:
|
if check:
|
||||||
b.setCheckable(True)
|
b.setCheckable(True)
|
||||||
self.iconsBox.addWidget(b)
|
self.iconsBox.addWidget(b)
|
||||||
|
if canDisable:
|
||||||
self._buttons[name] = b
|
self._buttons[name] = b
|
||||||
return b
|
return b
|
||||||
|
|
||||||
|
@ -271,10 +272,10 @@ class Editor(object):
|
||||||
b = self._addButton
|
b = self._addButton
|
||||||
b("fields", self.onFields, "",
|
b("fields", self.onFields, "",
|
||||||
shortcut(_("Customize Fields")), size=False, text=_("Fields..."),
|
shortcut(_("Customize Fields")), size=False, text=_("Fields..."),
|
||||||
native=True)
|
native=True, canDisable=False)
|
||||||
b("layout", self.onCardLayout, "Ctrl+l",
|
b("layout", self.onCardLayout, "Ctrl+l",
|
||||||
shortcut(_("Customize Card Layout (Ctrl+l)")),
|
shortcut(_("Customize Card Layout (Ctrl+l)")),
|
||||||
size=False, text=_("Layout..."), native=True)
|
size=False, text=_("Layout..."), native=True, canDisable=False)
|
||||||
# align to right
|
# align to right
|
||||||
self.iconsBox.addItem(QSpacerItem(20,1, QSizePolicy.Expanding))
|
self.iconsBox.addItem(QSpacerItem(20,1, QSizePolicy.Expanding))
|
||||||
b("text_bold", self.toggleBold, "Ctrl+b", _("Bold text (Ctrl+b)"),
|
b("text_bold", self.toggleBold, "Ctrl+b", _("Bold text (Ctrl+b)"),
|
||||||
|
|
|
@ -18,7 +18,8 @@ import anki.consts
|
||||||
import aqt, aqt.progress, aqt.webview, aqt.toolbar
|
import aqt, aqt.progress, aqt.webview, aqt.toolbar
|
||||||
from aqt.utils import saveGeom, restoreGeom, showInfo, showWarning, \
|
from aqt.utils import saveGeom, restoreGeom, showInfo, showWarning, \
|
||||||
saveState, restoreState, getOnlyText, askUser, GetTextDialog, \
|
saveState, restoreState, getOnlyText, askUser, GetTextDialog, \
|
||||||
askUserDialog, applyStyles, getText, showText, showCritical, getFile
|
askUserDialog, applyStyles, getText, showText, showCritical, getFile, \
|
||||||
|
tooltip
|
||||||
|
|
||||||
## fixme: open plugin folder broken on win32?
|
## fixme: open plugin folder broken on win32?
|
||||||
|
|
||||||
|
@ -565,8 +566,10 @@ Debug info:\n%s""") % traceback.format_exc(), help="DeckErrors")
|
||||||
f = self.reviewer.card.note()
|
f = self.reviewer.card.note()
|
||||||
if f.hasTag("marked"):
|
if f.hasTag("marked"):
|
||||||
f.delTag("marked")
|
f.delTag("marked")
|
||||||
|
tooltip("Mark Removed.")
|
||||||
else:
|
else:
|
||||||
f.addTag("marked")
|
f.addTag("marked")
|
||||||
|
tooltip("Mark Added.")
|
||||||
f.flush()
|
f.flush()
|
||||||
|
|
||||||
def onSuspend(self):
|
def onSuspend(self):
|
||||||
|
@ -574,16 +577,19 @@ Debug info:\n%s""") % traceback.format_exc(), help="DeckErrors")
|
||||||
self.col.sched.suspendCards(
|
self.col.sched.suspendCards(
|
||||||
[c.id for c in self.reviewer.card.note().cards()])
|
[c.id for c in self.reviewer.card.note().cards()])
|
||||||
self.reviewer.nextCard()
|
self.reviewer.nextCard()
|
||||||
|
tooltip("Note suspended.")
|
||||||
|
|
||||||
def onDelete(self):
|
def onDelete(self):
|
||||||
self.checkpoint(_("Delete"))
|
self.checkpoint(_("Delete"))
|
||||||
self.col.remNotes([self.reviewer.card.note().id])
|
self.col.remNotes([self.reviewer.card.note().id])
|
||||||
self.reviewer.nextCard()
|
self.reviewer.nextCard()
|
||||||
|
tooltip("Note and its cards deleted.")
|
||||||
|
|
||||||
def onBuryNote(self):
|
def onBuryNote(self):
|
||||||
self.checkpoint(_("Bury"))
|
self.checkpoint(_("Bury"))
|
||||||
self.col.sched.buryNote(self.reviewer.card.nid)
|
self.col.sched.buryNote(self.reviewer.card.nid)
|
||||||
self.reviewer.nextCard()
|
self.reviewer.nextCard()
|
||||||
|
tooltip("Note buried.")
|
||||||
|
|
||||||
# Undo & autosave
|
# Undo & autosave
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
|
@ -195,27 +195,42 @@ function _typeAnsPress() {
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _keyHandler(self, evt):
|
def _keyHandler(self, evt):
|
||||||
print "rev event", evt.key()
|
|
||||||
if self.state == "question":
|
|
||||||
show = False
|
|
||||||
if evt.key() == Qt.Key_Space and self.typeAns() is None:
|
|
||||||
show = True
|
|
||||||
elif evt.key() == Qt.Key_Escape:
|
|
||||||
self.web.eval("$('#typeans').blur();")
|
|
||||||
if show:
|
|
||||||
self._showAnswer()
|
|
||||||
self.web.eval("_showans();")
|
|
||||||
return True
|
|
||||||
elif self.state == "answer":
|
|
||||||
if evt.key() == Qt.Key_Space:
|
|
||||||
self.web.eval("_onSpace();")
|
|
||||||
else:
|
|
||||||
key = unicode(evt.text())
|
key = unicode(evt.text())
|
||||||
if key and key >= "1" and key <= "4":
|
if key == "e":
|
||||||
key=int(key)
|
self.mw.onEditCurrent()
|
||||||
if self.card.queue == 2 or key < 4:
|
elif key == " " and self.state == "question":
|
||||||
self._answerCard(key)
|
self._showAnswer()
|
||||||
return True
|
elif key == "r":
|
||||||
|
self.replayAudio()
|
||||||
|
elif key == "*":
|
||||||
|
self.mw.onMark()
|
||||||
|
elif key == "-":
|
||||||
|
self.mw.onBuryNote()
|
||||||
|
elif key == "=":
|
||||||
|
self.mw.onSuspend()
|
||||||
|
elif evt.key() == Qt.Key_Delete:
|
||||||
|
self.mw.onDelete()
|
||||||
|
print "key", evt.key()
|
||||||
|
# if self.state == "question":
|
||||||
|
# show = False
|
||||||
|
# if evt.key() == Qt.Key_Space and self.typeAns() is None:
|
||||||
|
# show = True
|
||||||
|
# elif evt.key() == Qt.Key_Escape:
|
||||||
|
# self.web.eval("$('#typeans').blur();")
|
||||||
|
# if show:
|
||||||
|
# self._showAnswer()
|
||||||
|
# self.web.eval("_showans();")
|
||||||
|
# return True
|
||||||
|
# elif self.state == "answer":
|
||||||
|
# if evt.key() == Qt.Key_Space:
|
||||||
|
# self.web.eval("_onSpace();")
|
||||||
|
# else:
|
||||||
|
# key = unicode(evt.text())
|
||||||
|
# if key and key >= "1" and key <= "4":
|
||||||
|
# key=int(key)
|
||||||
|
# if self.card.queue == 2 or key < 4:
|
||||||
|
# self._answerCard(key)
|
||||||
|
# return True
|
||||||
|
|
||||||
def _linkHandler(self, url):
|
def _linkHandler(self, url):
|
||||||
if url == "ans":
|
if url == "ans":
|
||||||
|
@ -492,14 +507,15 @@ Card was a <a href="%s">leech</a>.""") % link)
|
||||||
|
|
||||||
def showContextMenu(self):
|
def showContextMenu(self):
|
||||||
opts = [
|
opts = [
|
||||||
[_("Replay Audio (r)"), self.replayAudio],
|
[_("Replay Audio"), "r", self.replayAudio],
|
||||||
[_("Mark Note (m)"), self.mw.onMark],
|
[_("Mark Note"), "*", self.mw.onMark],
|
||||||
[_("Bury Note (b)"), self.mw.onBuryNote],
|
[_("Bury Note"), "-", self.mw.onBuryNote],
|
||||||
[_("Suspend Note (!)"), self.mw.onSuspend],
|
[_("Suspend Note"), "=", self.mw.onSuspend],
|
||||||
[shortcut(_("Delete Note (Ctrl+delete)")), self.mw.onDelete]
|
[_("Delete Note"), "Delete", self.mw.onDelete]
|
||||||
]
|
]
|
||||||
m = QMenu(self.mw)
|
m = QMenu(self.mw)
|
||||||
for label, func in opts:
|
for label, scut, func in opts:
|
||||||
a = m.addAction(label)
|
a = m.addAction(label)
|
||||||
|
a.setShortcut(QKeySequence(scut))
|
||||||
a.connect(a, SIGNAL("triggered()"), func)
|
a.connect(a, SIGNAL("triggered()"), func)
|
||||||
m.exec_(QCursor.pos())
|
m.exec_(QCursor.pos())
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
from aqt.webview import AnkiWebView
|
from aqt.webview import AnkiWebView
|
||||||
|
from anki.lang import _
|
||||||
|
|
||||||
class Toolbar(object):
|
class Toolbar(object):
|
||||||
|
|
||||||
|
@ -26,31 +27,34 @@ class Toolbar(object):
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
rightIcons = [
|
rightIcons = [
|
||||||
["stats", "qrc:/icons/view-statistics.png"],
|
["stats", "qrc:/icons/view-statistics.png",
|
||||||
["sync", "qrc:/icons/view-refresh.png"],
|
_("Show statistics. Shortcut key: %s") % "S"],
|
||||||
|
["sync", "qrc:/icons/view-refresh.png",
|
||||||
|
_("Synchronize with AnkiWeb. Shortcut key: %s") % "y"],
|
||||||
]
|
]
|
||||||
|
|
||||||
def _centerLinks(self):
|
def _centerLinks(self):
|
||||||
links = [
|
links = [
|
||||||
["decks", _("Decks")],
|
["decks", _("Decks"), _("Shortcut key: %s") % "d"],
|
||||||
["study", _("Study")],
|
["study", _("Study"), _("Shortcut key: %s") % "s"],
|
||||||
["add", _("Add")],
|
["add", _("Add"), _("Shortcut key: %s") % "a"],
|
||||||
["browse", _("Browse")],
|
["browse", _("Browse"), _("Shortcut key: %s") % "b"],
|
||||||
]
|
]
|
||||||
return self._linkHTML(links)
|
return self._linkHTML(links)
|
||||||
|
|
||||||
def _linkHTML(self, links):
|
def _linkHTML(self, links):
|
||||||
buf = ""
|
buf = ""
|
||||||
for ln, name in links:
|
for ln, name, title in links:
|
||||||
buf += '<a class=hitem href="%s">%s</a>' % (ln, name)
|
buf += '<a class=hitem title="%s" href="%s">%s</a>' % (
|
||||||
|
title, ln, name)
|
||||||
buf += " "*3
|
buf += " "*3
|
||||||
return buf
|
return buf
|
||||||
|
|
||||||
def _rightIcons(self):
|
def _rightIcons(self):
|
||||||
buf = ""
|
buf = ""
|
||||||
for ln, icon in self.rightIcons:
|
for ln, icon, title in self.rightIcons:
|
||||||
buf += '<a class=hitem href="%s"><img src="%s"></a>' % (
|
buf += '<a class=hitem title="%s" href="%s"><img src="%s"></a>' % (
|
||||||
ln, icon)
|
title, ln, icon)
|
||||||
return buf
|
return buf
|
||||||
|
|
||||||
# Link handling
|
# Link handling
|
||||||
|
|
Loading…
Reference in a new issue