diff --git a/ankiqt/ui/main.py b/ankiqt/ui/main.py index 069f57ff8..e21e0f934 100644 --- a/ankiqt/ui/main.py +++ b/ankiqt/ui/main.py @@ -78,6 +78,7 @@ class AnkiQt(QMainWindow): traceback.format_exc()) def setupMainWindow(self): + # main window self.mainWin = ankiqt.forms.main.Ui_MainWindow() self.mainWin.setupUi(self) self.mainWin.mainText = ui.view.AnkiWebView(self.mainWin.mainTextFrame) @@ -88,6 +89,13 @@ class AnkiQt(QMainWindow): self.connect(self.mainWin.mainText.pageAction(QWebPage.Reload), SIGNAL("activated()"), lambda: self.moveToState("auto")) + # congrats + self.connect(self.mainWin.learnMoreButton, + SIGNAL("clicked()"), + self.onLearnMore) + self.connect(self.mainWin.reviewEarlyButton, + SIGNAL("clicked()"), + self.onReviewEarly) def setupViews(self): self.bodyView = ui.view.View(self, self.mainWin.mainText, @@ -226,11 +234,12 @@ Please do not file a bug report with Anki.\n\n""") # if the same card is being shown and it's not # due yet, give up return self.moveToState("deckFinished") - if (self.config['showStudyScreen'] and - not self.deck.sessionStartTime): - return self.moveToState("studyScreen") - if self.deck.sessionLimitReached(): - return self.moveToState("studyScreen") + if not self.deck.reviewEarly: + if (self.config['showStudyScreen'] and + not self.deck.sessionStartTime): + return self.moveToState("studyScreen") + if self.deck.sessionLimitReached(): + return self.moveToState("studyScreen") self.enableCardMenuItems() return self.moveToState("showQuestion") else: @@ -242,8 +251,13 @@ Please do not file a bug report with Anki.\n\n""") self.deck.s.flush() self.hideButtons() self.disableCardMenuItems() + self.switchToCongratsScreen() + self.mainWin.learnMoreButton.setEnabled( + not not self.deck.newCount) self.startRefreshTimer() self.bodyView.setState(state) + # make sure the buttons aren't focused + self.mainWin.congratsLabel.setFocus() elif state == "showQuestion": if self.deck.mediaDir(): os.chdir(self.deck.mediaDir()) @@ -408,9 +422,12 @@ new: def switchToStudyScreen(self): self.mainWin.mainStack.setCurrentIndex(3) - def switchToReviewScreen(self): + def switchToCongratsScreen(self): self.mainWin.mainStack.setCurrentIndex(4) + def switchToReviewScreen(self): + self.mainWin.mainStack.setCurrentIndex(5) + # Buttons ########################################################################## @@ -674,6 +691,8 @@ To upgrade an old deck, download Anki 0.9.8.7.""")) "(Auto)save and close. Prompt if necessary. True if okay to proceed." self.hideWelcome = hideWelcome if self.deck is not None: + if self.deck.reviewEarly: + self.deck.resetAfterReviewEarly() if self.deck.modifiedSinceSave(): if (self.deck.path is None or (not self.config['saveOnClose'] and @@ -1366,6 +1385,17 @@ day = :d""", d=yesterday) self.deck.syncName = None self.reset() + # Reviewing and learning ahead + ########################################################################## + + def onLearnMore(self): + self.deck.extraNewCards += 5 + self.reset() + + def onReviewEarly(self): + self.deck.reviewEarly = True + self.reset() + # Language handling ########################################################################## diff --git a/ankiqt/ui/modelchooser.py b/ankiqt/ui/modelchooser.py index b0a51fbdd..6ae8fb8e1 100644 --- a/ankiqt/ui/modelchooser.py +++ b/ankiqt/ui/modelchooser.py @@ -66,14 +66,13 @@ class ModelChooser(QHBoxLayout): onFinish=self.onModelEdited) def onModelEdited(self): - idx = self.models.currentIndex() self.drawModels() - self.onChange(idx) + self.changed(self.deck.currentModel) def onChange(self, idx): model = self._models[idx] self.deck.currentModel = model - self.changed(model) + self.changed(self.deck.currentModel) self.deck.setModified() def changed(self, model): diff --git a/ankiqt/ui/view.py b/ankiqt/ui/view.py index ec4deae8f..27f003db7 100644 --- a/ankiqt/ui/view.py +++ b/ankiqt/ui/view.py @@ -12,10 +12,12 @@ from anki.hooks import runHook import types, time, re, os, urllib, sys from ankiqt import ui from ankiqt.ui.utils import mungeQA +from anki.utils import fmtTimeSpan from PyQt4.QtWebKit import QWebPage, QWebView failedCharColour = "#FF0000" passedCharColour = "#00FF00" +futureWarningColour = "#FF0000" # Views - define the way a user is prompted for questions, etc ########################################################################## @@ -53,7 +55,8 @@ class View(object): self.clearWindow() self.haveTop = (self.main.lastCard and ( self.main.config['showLastCardContent'] or - self.main.config['showLastCardInterval'])) + self.main.config['showLastCardInterval'])) or ( + self.main.currentCard and self.main.currentCard.due > time.time()) self.drawRule = (self.main.config['qaDivider'] and self.main.currentCard and not self.main.currentCard.cardModel.questionInAnswer) @@ -178,9 +181,20 @@ class View(object): def drawTopSection(self): "Show previous card, next scheduled time, and stats." self.buffer += "
" + self.drawFutureWarning() self.drawLastCard() self.buffer += "
" + def drawFutureWarning(self): + if not self.main.currentCard: + return + if self.main.currentCard.due <= time.time(): + return + self.write("" % futureWarningColour + + _("This card was due in %s.") % fmtTimeSpan( + self.main.currentCard.due - time.time()) + + "") + def drawLastCard(self): "Show the last card if not the current one, and next time." if self.main.lastCard: @@ -262,7 +276,8 @@ Start adding your own material. def drawDeckFinishedMessage(self): "Tell the user the deck is finished." - self.write(self.main.deck.deckFinishedMsg()) + self.main.mainWin.congratsLabel.setText( + self.main.deck.deckFinishedMsg()) class AnkiWebView(QWebView): diff --git a/designer/cardlist.ui b/designer/cardlist.ui index 6ab90049f..88d045c01 100644 --- a/designer/cardlist.ui +++ b/designer/cardlist.ui @@ -321,7 +321,7 @@ - :/icons/arrow-down.png:/icons/arrow-down.png + :/icons/go-next.png:/icons/go-next.png &Next Card @@ -333,7 +333,7 @@ - :/icons/arrow-up.png:/icons/arrow-up.png + :/icons/go-previous.png:/icons/go-previous.png &Previous Card @@ -345,7 +345,7 @@ - :/icons/arrow-up-double.png:/icons/arrow-up-double.png + :/icons/go-first.png:/icons/go-first.png F&irst Card @@ -357,7 +357,7 @@ - :/icons/arrow-down-double.png:/icons/arrow-down-double.png + :/icons/go-last.png:/icons/go-last.png &Last Card diff --git a/designer/main.ui b/designer/main.ui index e746285d7..6e45a8db3 100644 --- a/designer/main.ui +++ b/designer/main.ui @@ -138,379 +138,6 @@ 0 - - - - - 0 - 99 - - - - 0 - - - - - 0 - 0 - 364 - 280 - - - - - - - 0 - 0 - 100 - 30 - - - - - - - Qt::ClickFocus - - - QFrame::NoFrame - - - - - - - - - 0 - 0 - 100 - 30 - - - - - 0 - - - 4 - - - - - - - - - - 0 - 0 - 364 - 280 - - - - - 0 - - - - - 0 - - - 4 - - - - - - 350 - 0 - - - - <h1>Welcome!</h1> - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 6 - - - - - - - - - 400 - 16777215 - - - - Qt::Horizontal - - - - - - - 2 - - - 6 - - - 0 - - - - - - 140 - 0 - - - - <b>Session limit (mins):</b> - - - 4 - - - - - - - - 0 - 0 - - - - - 50 - 16777215 - - - - - - - - - 140 - 0 - - - - <b>New cards per day:</b> - - - 4 - - - - - - - - 0 - 0 - - - - - 50 - 16777215 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 50 - 16777215 - - - - - - - - <b>Session limit (reps): - - - 4 - - - - - - - 4 - - - - - More>> - - - true - - - false - - - false - - - - - - - Help - - - - - - - - - - - - - - 4 - - - 2 - - - 4 - - - 0 - - - 0 - - - - - - 250 - 0 - - - - - - - - - 400 - 16777215 - - - - - - - - - 400 - 16777215 - - - - - - - - Show failed cards last - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 1000 - 20 - - - - - - - - @@ -831,12 +458,480 @@ 0 0 364 - 79 + 89 + + + + + 0 + 99 + + + + 0 + + + + + 0 + 0 + 364 + 270 + + + + + + + 0 + 0 + 364 + 270 + + + + + + + Qt::ClickFocus + + + QFrame::NoFrame + + + + + + + + + 0 + 0 + 364 + 270 + + + + + 0 + + + 4 + + + + + + + + + + 0 + 0 + 364 + 270 + + + + + 0 + + + + + 0 + + + 4 + + + + + + 350 + 0 + + + + TextLabel + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 6 + + + + + + + + + 400 + 16777215 + + + + Qt::Horizontal + + + + + + + 2 + + + 6 + + + 0 + + + + + + 140 + 0 + + + + <b>Session limit (mins):</b> + + + 4 + + + + + + + + 0 + 0 + + + + + 50 + 16777215 + + + + + + + + + 140 + 0 + + + + <b>New cards per day:</b> + + + 4 + + + + + + + + 0 + 0 + + + + + 50 + 16777215 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 50 + 16777215 + + + + + + + + <b>Session limit (reps): + + + 4 + + + + + + + 4 + + + + + More>> + + + true + + + false + + + false + + + + + + + Help + + + + + + + + + + + + + + 4 + + + 2 + + + 4 + + + 0 + + + 0 + + + + + + 250 + 0 + + + + + + + + + 400 + 16777215 + + + + + + + + + 400 + 16777215 + + + + + + + + Show failed cards last + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 1000 + 20 + + + + + + + + + + 0 + 0 + 364 + 270 + + + + + + + + + + + TextLabel + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 10 + + + + + + + + &Learn More + + + + 32 + 32 + + + + + + + + Re&view Early + + + + 32 + 32 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + diff --git a/icons.qrc b/icons.qrc index c82b7bde4..6ad58d9a9 100644 --- a/icons.qrc +++ b/icons.qrc @@ -1,14 +1,17 @@ + icons/view-calendar-tasks.png + icons/help-hint.png + icons/go-first.png + icons/go-jump-today.png + icons/go-last.png + icons/go-next.png + icons/go-previous.png icons/player-time.png icons/find.png icons/editclear.png icons/view-statistics.png - icons/arrow-down-double.png icons/emblem-favorite.png - icons/arrow-up-double.png - icons/arrow-down.png - icons/arrow-up.png icons/view-pim-calendar.png icons/anki-tag.png icons/edit-redo.png diff --git a/icons/appointment-new.png b/icons/appointment-new.png new file mode 100644 index 000000000..fd225f4b7 Binary files /dev/null and b/icons/appointment-new.png differ diff --git a/icons/go-first.png b/icons/go-first.png new file mode 100644 index 000000000..68498491c Binary files /dev/null and b/icons/go-first.png differ diff --git a/icons/go-jump-today.png b/icons/go-jump-today.png new file mode 100644 index 000000000..764247d28 Binary files /dev/null and b/icons/go-jump-today.png differ diff --git a/icons/go-last.png b/icons/go-last.png new file mode 100644 index 000000000..fca58e3fb Binary files /dev/null and b/icons/go-last.png differ diff --git a/icons/go-next.png b/icons/go-next.png new file mode 100644 index 000000000..c4da8a9a3 Binary files /dev/null and b/icons/go-next.png differ diff --git a/icons/go-previous.png b/icons/go-previous.png new file mode 100644 index 000000000..68ed8a13e Binary files /dev/null and b/icons/go-previous.png differ diff --git a/icons/help-hint.png b/icons/help-hint.png new file mode 100644 index 000000000..209f1d28c Binary files /dev/null and b/icons/help-hint.png differ diff --git a/icons/view-calendar-tasks.png b/icons/view-calendar-tasks.png new file mode 100644 index 000000000..1f09147b4 Binary files /dev/null and b/icons/view-calendar-tasks.png differ