diff --git a/ankiqt/ui/deckproperties.py b/ankiqt/ui/deckproperties.py
index 3007881d3..ce8947f42 100644
--- a/ankiqt/ui/deckproperties.py
+++ b/ankiqt/ui/deckproperties.py
@@ -72,6 +72,9 @@ class DeckProperties(QDialog):
# hour shift
self.dialog.timeOffset.setText(str(
(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):
self.dialog.sourcesTable.clear()
@@ -240,6 +243,13 @@ class DeckProperties(QDialog):
self.updateField(self.d, 'failedCardMax', v)
except ValueError:
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
try:
self.updateField(self.d, 'utcOffset',
diff --git a/ankiqt/ui/main.py b/ankiqt/ui/main.py
index 52a2cd546..47633adf4 100755
--- a/ankiqt/ui/main.py
+++ b/ankiqt/ui/main.py
@@ -14,7 +14,7 @@ from PyQt4.QtCore import *
from PyQt4.QtGui import *
from anki import DeckStorage
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.media import rebuildMediaDir, downloadMissing
from anki.db import OperationalError, SessionHelper
@@ -119,6 +119,7 @@ class AnkiQt(QMainWindow):
SIGNAL("clicked()"),
self.onClose)
# notices
+ self.noticeShown = 0
self.mainWin.noticeFrame.setShown(False)
self.connect(self.mainWin.noticeButton, SIGNAL("clicked()"),
lambda: self.mainWin.noticeFrame.setShown(False))
@@ -129,9 +130,14 @@ class AnkiQt(QMainWindow):
self.mainWin.noticeButton.setFixedHeight(20)
def setNotice(self, str):
+ self.noticeShown = time.time()
self.mainWin.noticeLabel.setText(str)
self.mainWin.noticeFrame.setShown(True)
+ def maybeClearNotice(self):
+ if time.time() - self.noticeShown > 5:
+ self.mainWin.noticeFrame.setShown(False)
+
def setupViews(self):
self.bodyView = ui.view.View(self, self.mainWin.mainText,
self.mainWin.mainTextFrame)
@@ -299,6 +305,7 @@ Please do not file a bug report with Anki.
""")
elif state == "getQuestion":
# stop anything playing
clearAudioQueue()
+ self.maybeClearNotice()
if self.deck.isEmpty():
return self.moveToState("deckEmpty")
else:
@@ -445,7 +452,8 @@ Please do not file a bug report with Anki.
""")
self.moveToState("getQuestion")
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):
self.deck.refresh()
@@ -454,13 +462,15 @@ Please do not file a bug report with Anki.
""")
self.currentCard.fact.tags = canonifyTags(tags)
self.currentCard.fact.setModified(textChanged=True)
self.deck.updateFactTags([self.currentCard.fact.id])
- self.deck.suspendCards([self.currentCard.id])
+ txt = (_("""\
+%s... is a leech.""")
+ % stripHTML(stripSounds(self.currentCard.question)).\
+ replace("\n", " ")[0:30])
+ if self.deck.getBool('suspendLeeches'):
+ self.deck.suspendCards([self.currentCard.id])
+ txt += _(" It has been suspended.")
self.deck.refresh()
- self.setNotice(_("""\
-%s... is a leech
-and has been suspended.""") %
- stripHTML(self.currentCard.question)[0:30].\
- replace("\n", " "))
+ self.setNotice(txt)
def startRefreshTimer(self):
"Update the screen once a minute until next card is displayed."
diff --git a/designer/deckproperties.ui b/designer/deckproperties.ui
index f99e877a2..05a4fa268 100644
--- a/designer/deckproperties.ui
+++ b/designer/deckproperties.ui
@@ -9,8 +9,8 @@
0
0
- 426
- 401
+ 419
+ 457
@@ -294,7 +294,7 @@ p, li { white-space: pre-wrap; }
-
- <h1>Advanced Scheduling</h1>
+ <h1>Advanced</h1>
@@ -569,6 +569,30 @@ p, li { white-space: pre-wrap; }
+ -
+
+
+ <b>Suspend leeches</b>
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+ <b>Leech failure threshold</b>
+
+
+
+ -
+
+
-
@@ -626,6 +650,8 @@ p, li { white-space: pre-wrap; }
collapse
failedCardMax
timeOffset
+ suspendLeeches
+ leechFails
buttonBox
diff --git a/designer/main.ui b/designer/main.ui
index 78871115e..075880b5f 100644
--- a/designer/main.ui
+++ b/designer/main.ui
@@ -508,7 +508,7 @@
- TextLabel
+
Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter