From 89783c3e17dd38337f234763b16667fb3eb716e2 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 5 Jun 2009 22:22:53 +0900 Subject: [PATCH] add recent decks menu back, inhibit startup progress bar --- ankiqt/__init__.py | 2 ++ ankiqt/ui/main.py | 37 +++++++++++++++++++++++++++++++++---- designer/main.ui | 11 +++++++++++ 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/ankiqt/__init__.py b/ankiqt/__init__.py index 2f7116a7e..0838bc45c 100644 --- a/ankiqt/__init__.py +++ b/ankiqt/__init__.py @@ -32,6 +32,7 @@ sys.path.append(os.path.dirname(__file__)) class SplashScreen(object): def __init__(self, max=100): + self.finished = False self.pixmap = QPixmap(":/icons/anki-logo.png") self.splash = QSplashScreen(self.pixmap) self.prog = QProgressBar(self.splash) @@ -63,6 +64,7 @@ color: #13486c; def finish(self, obj): self.splash.finish(obj) + self.finished = True class AnkiApp(QApplication): diff --git a/ankiqt/ui/main.py b/ankiqt/ui/main.py index 5b2425a1f..ae42f43b6 100644 --- a/ankiqt/ui/main.py +++ b/ankiqt/ui/main.py @@ -240,6 +240,7 @@ Please do not file a bug report with Anki.
""") self.currentCard = None self.lastCard = None self.editor.deck = self.deck + self.updateRecentFilesMenu() if self.deck: self.enableDeckMenuItems() self.updateViews(state) @@ -269,6 +270,7 @@ Please do not file a bug report with Anki.
""") self.help.hide() self.currentCard = None self.lastCard = None + self.updateRecentFilesMenu() self.disableDeckMenuItems() # hide all deck-associated dialogs self.closeAllDeckWindows() @@ -707,6 +709,30 @@ To upgrade an old deck, download Anki 0.9.8.7.""")) self.config['recentDeckPaths'].insert(0, path) del self.config['recentDeckPaths'][20:] self.config.save() + self.updateRecentFilesMenu() + + def updateRecentFilesMenu(self): + self.config['recentDeckPaths'] = [ + p for p in self.config['recentDeckPaths'] + if os.path.exists(p)] + if not self.config['recentDeckPaths']: + self.mainWin.menuOpenRecent.setEnabled(False) + return + self.mainWin.menuOpenRecent.setEnabled(True) + self.mainWin.menuOpenRecent.clear() + n = 1 + for file in self.config['recentDeckPaths']: + a = QAction(self) + if sys.platform.startswith("darwin"): + a.setShortcut(_("Ctrl+Alt+%d" % n)) + else: + a.setShortcut(_("Alt+%d" % n)) + a.setText(os.path.basename(file)) + a.setStatusTip(os.path.abspath(file)) + self.connect(a, SIGNAL("triggered()"), + lambda n=n: self.loadRecent(n-1)) + self.mainWin.menuOpenRecent.addAction(a) + n += 1 def loadRecent(self, n): self.loadDeck(self.config['recentDeckPaths'][n]) @@ -972,10 +998,12 @@ your deck.""")) l.setAlignment(Qt.AlignRight | Qt.AlignVCenter) layout.addWidget(l, 0, 2) toRemove = [] - self.startProgress(max=len(self.config['recentDeckPaths'])) + if ui.splash.finished: + self.startProgress(max=len(self.config['recentDeckPaths'])) for c, d in enumerate(self.config['recentDeckPaths']): - self.updateProgress(_("Checking deck %(x)d of %(y)d...") % { - 'x': c, 'y': len(self.config['recentDeckPaths'])}) + if ui.splash.finished: + self.updateProgress(_("Checking deck %(x)d of %(y)d...") % { + 'x': c, 'y': len(self.config['recentDeckPaths'])}) if not os.path.exists(d): toRemove.append(d) continue @@ -1033,7 +1061,8 @@ your deck.""")) layout.addWidget(refresh, c+2, 3) for d in toRemove: self.config['recentDeckPaths'].remove(d) - self.finishProgress() + if ui.splash.finished: + self.finishProgress() else: layout.addWidget(QLabel(_( "Welcome to Anki! Click 'Download Deck' to get started.")), 0, 0) diff --git a/designer/main.ui b/designer/main.ui index 4a52aa53b..04694d424 100644 --- a/designer/main.ui +++ b/designer/main.ui @@ -1501,8 +1501,14 @@ + + + Open &Recent + + + @@ -2304,6 +2310,11 @@ Full Database Check... + + + 123 + + newPerDay