strip reviewing card info into separate add-on

This commit is contained in:
Damien Elmes 2012-04-20 02:16:21 +09:00
parent 04cf8e9eb9
commit ff6abe2b9d
3 changed files with 0 additions and 102 deletions

View file

@ -63,7 +63,6 @@ class AnkiQt(QMainWindow):
self.setupSystemSpecific()
self.setupSignals()
self.setupAutoUpdate()
self.setupCardStats()
self.setupSchema()
self.updateTitleBar()
# screens
@ -574,23 +573,6 @@ upload, overwriting any changes either here or on AnkiWeb. Proceed?""")):
else:
aw.close()
# Dockable widgets
##########################################################################
def addDockable(self, title, w):
dock = QDockWidget(title, self)
dock.setObjectName(title)
dock.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
dock.setFeatures(QDockWidget.DockWidgetClosable)
dock.setWidget(w)
if self.width() < 600:
self.resize(QSize(600, self.height()))
self.addDockWidget(Qt.RightDockWidgetArea, dock)
return dock
def remDockable(self, dock):
self.removeDockWidget(dock)
# Marking, suspending and deleting
##########################################################################
# These are only available while reviewing
@ -673,10 +655,6 @@ upload, overwriting any changes either here or on AnkiWeb. Proceed?""")):
from aqt.editcurrent import EditCurrent
EditCurrent(self)
def setupCardStats(self):
import aqt.stats
self.cardStats = aqt.stats.CardStats(self)
def onDeckConf(self, deck=None):
if not deck:
deck = self.col.decks.current()
@ -691,9 +669,6 @@ upload, overwriting any changes either here or on AnkiWeb. Proceed?""")):
self.col.reset()
self.moveToState("overview")
def onCardStats(self):
self.cardStats.toggle()
def onStats(self):
aqt.stats.DeckStats(self)
@ -758,7 +733,6 @@ upload, overwriting any changes either here or on AnkiWeb. Proceed?""")):
self.connect(m.actionExport, s, self.onExport)
self.connect(m.actionExit, s, self, SLOT("close()"))
self.connect(m.actionPreferences, s, self.onPrefs)
self.connect(m.actionCstats, s, self.onCardStats)
self.connect(m.actionAbout, s, self.onAbout)
self.connect(m.actionUndo, s, self.onUndo)
self.connect(m.actionFullDatabaseCheck, s, self.onCheckDB)

View file

@ -11,66 +11,6 @@ from anki.utils import namedtmp
from anki.hooks import addHook
import aqt
# Card stats
######################################################################
class CardStats(object):
def __init__(self, mw):
self.mw = mw
self.shown = False
addHook("showQuestion", self._update)
addHook("deckClosing", self.hide)
addHook("reviewCleanup", self.hide)
def show(self):
if not self.shown:
class ThinAnkiWebView(AnkiWebView):
def sizeHint(self):
return QSize(200, 100)
self.web = ThinAnkiWebView()
self.shown = self.mw.addDockable(_("Card Info"), self.web)
self.shown.connect(self.shown, SIGNAL("visibilityChanged(bool)"),
self._visChange)
self._update()
def hide(self):
if self.shown:
self.mw.remDockable(self.shown)
self.shown = None
self.mw.form.actionCstats.setChecked(False)
def toggle(self):
if self.shown:
self.hide()
else:
self.show()
def _visChange(self, vis):
if not vis:
# schedule removal for after evt has finished
self.mw.progress.timer(100, self.hide, False)
def _update(self):
if not self.shown:
return
txt = ""
r = self.mw.reviewer
d = self.mw.col
if r.card:
txt += _("<h1>Current</h1>")
txt += d.cardStats(r.card)
lc = r.lastCard()
if lc:
txt += _("<h1>Last</h1>")
txt += d.cardStats(lc)
if not txt:
txt = _("No current card or last card.")
self.web.setHtml("""
<html><head>
<style>table { font-size: 12px; } h1 { font-size: 14px; }
body { font-family: "%s"; } </style>
</head><body><center>%s</center></body></html>"""% (fontForPlatform(), txt))
# Deck Stats
######################################################################

View file

@ -112,8 +112,6 @@
</widget>
<addaction name="actionStudyDeck"/>
<addaction name="separator"/>
<addaction name="actionCstats"/>
<addaction name="separator"/>
<addaction name="menuMaintenance"/>
<addaction name="separator"/>
<addaction name="menuPlugins"/>
@ -155,20 +153,6 @@
<enum>QAction::AboutRole</enum>
</property>
</action>
<action name="actionCstats">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;Card Info</string>
</property>
<property name="statusTip">
<string>Show statistics about the current card and last card</string>
</property>
<property name="shortcut">
<string>Shift+C</string>
</property>
</action>
<action name="actionUndo">
<property name="enabled">
<bool>false</bool>