diff --git a/ankiqt/ui/help.py b/ankiqt/ui/help.py index 9ca420c63..4494e2a0e 100644 --- a/ankiqt/ui/help.py +++ b/ankiqt/ui/help.py @@ -30,41 +30,17 @@ class HelpArea(object): self.widget.show() def hide(self): - self.currentKey = None self.helpFrame.hide() self.widget.hide() if self.mainWindow: self.mainWindow.runHook("helpChanged") - def showKey(self, key, noFlush=False, dict=False): - "Look up KEY in DATA and show." - text = self.data[key] - # accomodate some quirks in QTextEdit's html interpreter - text = text.strip() - if dict: - text = text % dict - self.showText(text, noFlush, key=key) - - def showHideableKey(self, key, dict=False): - "Look up a hideable KEY in DATA and show." - if self.config.get("hide:" + key, False): - # user requested not to see this key. if previous key was help, we - # need to hide it - if self.currentKey in self.data: - self.hide() - return - self.showKey(key, noFlush=True, dict=dict) - self.addRemover(key) - self.flush() - - def showText(self, text, noFlush=False, py={}, key="misc"): + def showText(self, text, py={}): self.show() self.buffer = text self.addHider() self.handlers = py - if not noFlush: - self.flush() - self.currentKey = key + self.flush() if self.mainWindow: self.mainWindow.runHook("helpChanged") @@ -79,11 +55,6 @@ class HelpArea(object): self.widget.setHtml(style + '
' + self.buffer + '
') - def addRemover(self, key): - self.buffer += (" / " + - _("Don't show this again.") - + "") % key - def addHider(self): self.buffer += _("

Hide this") @@ -96,6 +67,8 @@ class HelpArea(object): # hide for good self.config[addr] = True self.hide() + if "hide" in self.handlers: + self.handlers["hide"]() elif addr.startswith("py:"): key = addr[3:] if key in self.handlers: diff --git a/ankiqt/ui/main.py b/ankiqt/ui/main.py index ef8ca42a8..4ac353916 100644 --- a/ankiqt/ui/main.py +++ b/ankiqt/ui/main.py @@ -132,7 +132,12 @@ class AnkiQt(QMainWindow): self.lastState = getattr(self, "state", None) self.state = state self.updateTitleBar() + if 'state' != 'noDeck': + self.mainWin.welcomeText.hide() + self.mainWin.mainText.show() if state == "noDeck": + self.mainWin.welcomeText.show() + self.mainWin.mainText.hide() self.help.hide() self.currentCard = None self.lastCard = None @@ -753,13 +758,13 @@ class AnkiQt(QMainWindow): self.anchorPrefixes = { 'welcome': self.onWelcomeAnchor, } - self.connect(self.mainWin.mainText, + self.connect(self.mainWin.welcomeText, SIGNAL("anchorClicked(QUrl)"), self.anchorClicked) def anchorClicked(self, url): # prevent the link being handled - self.mainWin.mainText.setSource(QUrl("")) + self.mainWin.welcomeText.setSource(QUrl("")) addr = unicode(url.toString()) fields = addr.split(":") if len(fields) > 1 and fields[0] in self.anchorPrefixes: @@ -843,7 +848,6 @@ class AnkiQt(QMainWindow): def onCardStats(self): self.addHook("showQuestion", self.onCardStats) - self.addHook("helpChanged", self.removeCardStatsHook) txt = "" if self.currentCard: txt += _("

Current card

") @@ -853,12 +857,12 @@ class AnkiQt(QMainWindow): txt += anki.stats.CardStats(self.deck, self.lastCard).report() if not txt: txt = _("No current card or last card.") - self.help.showText(txt, key="cardStats") + self.help.showText(txt, py={'hide': self.removeCardStatsHook}) def removeCardStatsHook(self): "Remove the update hook if the help menu was changed." - if self.help.currentKey != "cardStats": - self.removeHook("showQuestion", self.onCardStats) + print "rem" + self.removeHook("showQuestion", self.onCardStats) def onShowGraph(self): self.setStatus(_("Loading graphs (may take time)..")) @@ -1078,8 +1082,7 @@ class AnkiQt(QMainWindow): # bug triggered by preferences dialog - underlying c++ widgets are not # garbage collected until the middle of the child thread import gc; gc.collect() - self.bodyView.clearWindow() - self.bodyView.flush() + self.mainWin.welcomeText.setText(u"") self.syncThread = ui.sync.Sync(self, u, p, interactive, create, onlyMerge, self.sourcesToCheck) self.connect(self.syncThread, SIGNAL("setStatus"), self.setSyncStatus) @@ -1093,6 +1096,9 @@ class AnkiQt(QMainWindow): self.connect(self.syncThread, SIGNAL("closeSyncProgress"), self.closeSyncProgress) self.connect(self.syncThread, SIGNAL("updateSyncProgress"), self.updateSyncProgress) self.syncThread.start() + self.mainWin.buttonWidget.hide() + self.mainWin.mainText.hide() + self.mainWin.welcomeText.show() self.setEnabled(False) while not self.syncThread.isFinished(): self.app.processEvents() @@ -1102,6 +1108,7 @@ class AnkiQt(QMainWindow): def syncFinished(self): "Reopen after sync finished." + self.mainWin.buttonWidget.show() if self.loadAfterSync: self.loadDeck(self.deckPath, sync=False) self.deck.syncName = self.syncName @@ -1133,7 +1140,7 @@ class AnkiQt(QMainWindow): def setSyncStatus(self, text, *args): self.setStatus(text, *args) - self.mainWin.mainText.append("" + text + "") + self.mainWin.welcomeText.append("" + text + "") def syncClockOff(self, diff): ui.utils.showWarning( diff --git a/ankiqt/ui/view.py b/ankiqt/ui/view.py index 4ba8b1a6c..cf01738ad 100644 --- a/ankiqt/ui/view.py +++ b/ankiqt/ui/view.py @@ -30,9 +30,6 @@ class View(object): self.oldState = getattr(self, 'state', None) self.state = state if self.state == "initial": - self.shownLearnHelp = False - self.shownReviewHelp = False - self.shownFinalHelp = False return elif self.state == "noDeck": self.clearWindow() @@ -47,7 +44,6 @@ class View(object): return self.clearWindow() self.setBackgroundColour() - self.maybeHelp() if not self.main.deck.isEmpty(): if not self.main.lastCard or ( not self.main.config['showLastCardContent'] and @@ -165,34 +161,11 @@ class View(object): self.write(msg) self.write("
") - # Help - ########################################################################## - - def maybeHelp(self): - return - stats = self.main.deck.sched.getStats() - if not stats['pending']: - self.main.help.hide() - elif (self.main.currentCard and - self.main.currentCard.nextTime > time.time()): - if not self.shownFinalHelp: - self.shownFinalHelp = True - self.main.help.showHideableKey("finalReview") - elif stats['learnMode']: - if not self.shownLearnHelp: - if stats['pending'] != 0: - self.shownLearnHelp = True - self.main.help.showHideableKey("learn") - else: - if not self.shownReviewHelp: - self.shownReviewHelp = True - self.main.help.showHideableKey("review") - # Welcome/empty/finished deck messages ########################################################################## def drawWelcomeMessage(self): - self.write(_(""" + self.main.mainWin.welcomeText.setText(_("""

Welcome to Anki!

diff --git a/designer/main.ui b/designer/main.ui index ac410c767..cc1bb13d6 100644 --- a/designer/main.ui +++ b/designer/main.ui @@ -129,6 +129,16 @@ 5 + + + + Qt::ClickFocus + + + QFrame::NoFrame + + + @@ -137,6 +147,9 @@ 0 + + Qt::WheelFocus + about:blank