mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 07:22:23 -04:00
add ability to customize leech & suspending per deck
This commit is contained in:
parent
33b3c65ad8
commit
0797b4e772
4 changed files with 58 additions and 12 deletions
|
@ -72,6 +72,9 @@ class DeckProperties(QDialog):
|
||||||
# hour shift
|
# hour shift
|
||||||
self.dialog.timeOffset.setText(str(
|
self.dialog.timeOffset.setText(str(
|
||||||
(self.d.utcOffset - time.timezone) / 60.0 / 60.0))
|
(self.d.utcOffset - time.timezone) / 60.0 / 60.0))
|
||||||
|
# leeches
|
||||||
|
self.dialog.suspendLeeches.setChecked(self.d.getBool("suspendLeeches"))
|
||||||
|
self.dialog.leechFails.setValue(self.d.getInt("leechFails"))
|
||||||
|
|
||||||
def drawSourcesTable(self):
|
def drawSourcesTable(self):
|
||||||
self.dialog.sourcesTable.clear()
|
self.dialog.sourcesTable.clear()
|
||||||
|
@ -240,6 +243,13 @@ class DeckProperties(QDialog):
|
||||||
self.updateField(self.d, 'failedCardMax', v)
|
self.updateField(self.d, 'failedCardMax', v)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
try:
|
||||||
|
self.d.setVar("suspendLeeches",
|
||||||
|
not not self.dialog.suspendLeeches.isChecked())
|
||||||
|
self.d.setVar("leechFails",
|
||||||
|
int(self.dialog.leechFails.value()))
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
# hour shift
|
# hour shift
|
||||||
try:
|
try:
|
||||||
self.updateField(self.d, 'utcOffset',
|
self.updateField(self.d, 'utcOffset',
|
||||||
|
|
|
@ -14,7 +14,7 @@ from PyQt4.QtCore import *
|
||||||
from PyQt4.QtGui import *
|
from PyQt4.QtGui import *
|
||||||
from anki import DeckStorage
|
from anki import DeckStorage
|
||||||
from anki.errors import *
|
from anki.errors import *
|
||||||
from anki.sound import hasSound, playFromText, clearAudioQueue
|
from anki.sound import hasSound, playFromText, clearAudioQueue, stripSounds
|
||||||
from anki.utils import addTags, deleteTags, parseTags, canonifyTags, stripHTML
|
from anki.utils import addTags, deleteTags, parseTags, canonifyTags, stripHTML
|
||||||
from anki.media import rebuildMediaDir, downloadMissing
|
from anki.media import rebuildMediaDir, downloadMissing
|
||||||
from anki.db import OperationalError, SessionHelper
|
from anki.db import OperationalError, SessionHelper
|
||||||
|
@ -119,6 +119,7 @@ class AnkiQt(QMainWindow):
|
||||||
SIGNAL("clicked()"),
|
SIGNAL("clicked()"),
|
||||||
self.onClose)
|
self.onClose)
|
||||||
# notices
|
# notices
|
||||||
|
self.noticeShown = 0
|
||||||
self.mainWin.noticeFrame.setShown(False)
|
self.mainWin.noticeFrame.setShown(False)
|
||||||
self.connect(self.mainWin.noticeButton, SIGNAL("clicked()"),
|
self.connect(self.mainWin.noticeButton, SIGNAL("clicked()"),
|
||||||
lambda: self.mainWin.noticeFrame.setShown(False))
|
lambda: self.mainWin.noticeFrame.setShown(False))
|
||||||
|
@ -129,9 +130,14 @@ class AnkiQt(QMainWindow):
|
||||||
self.mainWin.noticeButton.setFixedHeight(20)
|
self.mainWin.noticeButton.setFixedHeight(20)
|
||||||
|
|
||||||
def setNotice(self, str):
|
def setNotice(self, str):
|
||||||
|
self.noticeShown = time.time()
|
||||||
self.mainWin.noticeLabel.setText(str)
|
self.mainWin.noticeLabel.setText(str)
|
||||||
self.mainWin.noticeFrame.setShown(True)
|
self.mainWin.noticeFrame.setShown(True)
|
||||||
|
|
||||||
|
def maybeClearNotice(self):
|
||||||
|
if time.time() - self.noticeShown > 5:
|
||||||
|
self.mainWin.noticeFrame.setShown(False)
|
||||||
|
|
||||||
def setupViews(self):
|
def setupViews(self):
|
||||||
self.bodyView = ui.view.View(self, self.mainWin.mainText,
|
self.bodyView = ui.view.View(self, self.mainWin.mainText,
|
||||||
self.mainWin.mainTextFrame)
|
self.mainWin.mainTextFrame)
|
||||||
|
@ -299,6 +305,7 @@ Please do not file a bug report with Anki.<br>""")
|
||||||
elif state == "getQuestion":
|
elif state == "getQuestion":
|
||||||
# stop anything playing
|
# stop anything playing
|
||||||
clearAudioQueue()
|
clearAudioQueue()
|
||||||
|
self.maybeClearNotice()
|
||||||
if self.deck.isEmpty():
|
if self.deck.isEmpty():
|
||||||
return self.moveToState("deckEmpty")
|
return self.moveToState("deckEmpty")
|
||||||
else:
|
else:
|
||||||
|
@ -445,7 +452,8 @@ Please do not file a bug report with Anki.<br>""")
|
||||||
self.moveToState("getQuestion")
|
self.moveToState("getQuestion")
|
||||||
|
|
||||||
def isLeech(self):
|
def isLeech(self):
|
||||||
return not self.currentCard.successive and self.currentCard.noCount > 15
|
return (not self.currentCard.successive and
|
||||||
|
self.currentCard.noCount >= self.deck.getInt('leechFails'))
|
||||||
|
|
||||||
def handleLeech(self):
|
def handleLeech(self):
|
||||||
self.deck.refresh()
|
self.deck.refresh()
|
||||||
|
@ -454,13 +462,15 @@ Please do not file a bug report with Anki.<br>""")
|
||||||
self.currentCard.fact.tags = canonifyTags(tags)
|
self.currentCard.fact.tags = canonifyTags(tags)
|
||||||
self.currentCard.fact.setModified(textChanged=True)
|
self.currentCard.fact.setModified(textChanged=True)
|
||||||
self.deck.updateFactTags([self.currentCard.fact.id])
|
self.deck.updateFactTags([self.currentCard.fact.id])
|
||||||
|
txt = (_("""\
|
||||||
|
<b>%s</b>... is a <a href="http://ichi2.net/anki/wiki/Leeches">leech</a>.""")
|
||||||
|
% stripHTML(stripSounds(self.currentCard.question)).\
|
||||||
|
replace("\n", " ")[0:30])
|
||||||
|
if self.deck.getBool('suspendLeeches'):
|
||||||
self.deck.suspendCards([self.currentCard.id])
|
self.deck.suspendCards([self.currentCard.id])
|
||||||
|
txt += _(" It has been suspended.")
|
||||||
self.deck.refresh()
|
self.deck.refresh()
|
||||||
self.setNotice(_("""\
|
self.setNotice(txt)
|
||||||
<b>%s</b>... is a <a href="http://ichi2.net/anki/wiki/Leeches">leech</a>
|
|
||||||
and has been suspended.""") %
|
|
||||||
stripHTML(self.currentCard.question)[0:30].\
|
|
||||||
replace("\n", " "))
|
|
||||||
|
|
||||||
def startRefreshTimer(self):
|
def startRefreshTimer(self):
|
||||||
"Update the screen once a minute until next card is displayed."
|
"Update the screen once a minute until next card is displayed."
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>426</width>
|
<width>419</width>
|
||||||
<height>401</height>
|
<height>457</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -294,7 +294,7 @@ p, li { white-space: pre-wrap; }
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_27">
|
<widget class="QLabel" name="label_27">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><h1>Advanced Scheduling</h1></string>
|
<string><h1>Advanced</h1></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -569,6 +569,30 @@ p, li { white-space: pre-wrap; }
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="label_11">
|
||||||
|
<property name="text">
|
||||||
|
<string><b>Suspend leeches</b></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="2">
|
||||||
|
<widget class="QCheckBox" name="suspendLeeches">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QLabel" name="label_15">
|
||||||
|
<property name="text">
|
||||||
|
<string><b>Leech failure threshold</b></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="2">
|
||||||
|
<widget class="QSpinBox" name="leechFails"/>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -626,6 +650,8 @@ p, li { white-space: pre-wrap; }
|
||||||
<tabstop>collapse</tabstop>
|
<tabstop>collapse</tabstop>
|
||||||
<tabstop>failedCardMax</tabstop>
|
<tabstop>failedCardMax</tabstop>
|
||||||
<tabstop>timeOffset</tabstop>
|
<tabstop>timeOffset</tabstop>
|
||||||
|
<tabstop>suspendLeeches</tabstop>
|
||||||
|
<tabstop>leechFails</tabstop>
|
||||||
<tabstop>buttonBox</tabstop>
|
<tabstop>buttonBox</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|
|
@ -508,7 +508,7 @@
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>TextLabel</string>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||||
|
|
Loading…
Reference in a new issue