mirror of
https://github.com/ankitects/anki.git
synced 2025-09-22 07:52:24 -04:00
add leech detection, message window on sync failure
This commit is contained in:
parent
d3fb52199a
commit
32639bcbd5
3 changed files with 1495 additions and 265 deletions
|
@ -15,7 +15,7 @@ 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
|
||||||
from anki.utils import addTags, deleteTags, parseTags, canonifyTags
|
from anki.utils import addTags, deleteTags, parseTags, canonifyTags, stripHTML
|
||||||
from anki.media import rebuildMediaDir
|
from anki.media import rebuildMediaDir
|
||||||
from anki.db import OperationalError, SessionHelper
|
from anki.db import OperationalError, SessionHelper
|
||||||
from anki.stdmodels import BasicModel
|
from anki.stdmodels import BasicModel
|
||||||
|
@ -115,6 +115,14 @@ class AnkiQt(QMainWindow):
|
||||||
self.connect(self.mainWin.reviewEarlyButton,
|
self.connect(self.mainWin.reviewEarlyButton,
|
||||||
SIGNAL("clicked()"),
|
SIGNAL("clicked()"),
|
||||||
self.onReviewEarly)
|
self.onReviewEarly)
|
||||||
|
# notices
|
||||||
|
self.mainWin.noticeFrame.setShown(False)
|
||||||
|
self.connect(self.mainWin.noticeButton, SIGNAL("clicked()"),
|
||||||
|
lambda: self.mainWin.noticeFrame.setShown(False))
|
||||||
|
|
||||||
|
def setNotice(self, str):
|
||||||
|
self.mainWin.noticeLabel.setText(str)
|
||||||
|
self.mainWin.noticeFrame.setShown(True)
|
||||||
|
|
||||||
def setupViews(self):
|
def setupViews(self):
|
||||||
self.bodyView = ui.view.View(self, self.mainWin.mainText,
|
self.bodyView = ui.view.View(self, self.mainWin.mainText,
|
||||||
|
@ -414,6 +422,8 @@ Please do not file a bug report with Anki.<br>""")
|
||||||
self.deck.s.expunge(self.currentCard)
|
self.deck.s.expunge(self.currentCard)
|
||||||
# answer
|
# answer
|
||||||
self.deck.answerCard(self.currentCard, quality)
|
self.deck.answerCard(self.currentCard, quality)
|
||||||
|
if self.currentCard.reps > 15 and self.currentCard.successive == 0:
|
||||||
|
self.handleLeech()
|
||||||
self.lastScheduledTime = anki.utils.fmtTimeSpan(
|
self.lastScheduledTime = anki.utils.fmtTimeSpan(
|
||||||
self.currentCard.due - time.time())
|
self.currentCard.due - time.time())
|
||||||
self.lastQuality = quality
|
self.lastQuality = quality
|
||||||
|
@ -426,6 +436,21 @@ Please do not file a bug report with Anki.<br>""")
|
||||||
self.save()
|
self.save()
|
||||||
self.moveToState("getQuestion")
|
self.moveToState("getQuestion")
|
||||||
|
|
||||||
|
def handleLeech(self):
|
||||||
|
self.deck.refresh()
|
||||||
|
tags = self.currentCard.fact.tags
|
||||||
|
tags = addTags("Suspended", tags)
|
||||||
|
tags = addTags("Leech", tags)
|
||||||
|
self.currentCard.fact.tags = canonifyTags(tags)
|
||||||
|
self.currentCard.fact.setModified(textChanged=True)
|
||||||
|
self.deck.updateFactTags([self.currentCard.fact.id])
|
||||||
|
for card in self.currentCard.fact.cards:
|
||||||
|
self.deck.updatePriority(card)
|
||||||
|
self.deck.refresh()
|
||||||
|
self.setNotice(_("""\
|
||||||
|
%s... was a <a href="http://ichi2.net/anki/wiki/Leeches">leech</a>.""") %
|
||||||
|
stripHTML(self.currentCard.question)[0:30])
|
||||||
|
|
||||||
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."
|
||||||
if getattr(self, 'refreshTimer', None):
|
if getattr(self, 'refreshTimer', None):
|
||||||
|
@ -2079,15 +2104,10 @@ it to your friends.
|
||||||
setCurrentIndex(1)
|
setCurrentIndex(1)
|
||||||
|
|
||||||
def noSyncResponse(self):
|
def noSyncResponse(self):
|
||||||
msg = _("""\
|
msg = _("Sync Failed. Please check your internet connection.")
|
||||||
<h1>Sync Failed</h1>
|
|
||||||
Couldn't contact Anki Online. Please check your internet connection.""")
|
|
||||||
if self.config['proxyHost']:
|
if self.config['proxyHost']:
|
||||||
msg += _(" Also check your proxy settings.")
|
msg += _(" (and proxy settings)")
|
||||||
if self.config['syncInMsgBox']:
|
self.setNotice(msg)
|
||||||
ui.utils.showWarning(msg)
|
|
||||||
else:
|
|
||||||
self.showToolTip(msg)
|
|
||||||
|
|
||||||
def openSyncProgress(self):
|
def openSyncProgress(self):
|
||||||
self.syncProgressDialog = QProgressDialog(_("Syncing Media..."),
|
self.syncProgressDialog = QProgressDialog(_("Syncing Media..."),
|
||||||
|
|
|
@ -304,4 +304,3 @@ You should aim to answer each question within<br>
|
||||||
|
|
||||||
def setTimer(self, txt):
|
def setTimer(self, txt):
|
||||||
self.timer.setText("<qt>" + txt + " ")
|
self.timer.setText("<qt>" + txt + " ")
|
||||||
|
|
||||||
|
|
1665
designer/main.ui
1665
designer/main.ui
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue