mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
add recent decks menu back, inhibit startup progress bar
This commit is contained in:
parent
636a661569
commit
89783c3e17
3 changed files with 46 additions and 4 deletions
|
@ -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):
|
||||
|
||||
|
|
|
@ -240,6 +240,7 @@ Please do not file a bug report with Anki.<br>""")
|
|||
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.<br>""")
|
|||
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)
|
||||
|
|
|
@ -1501,8 +1501,14 @@
|
|||
<addaction name="actionDownloadSharedDeck" />
|
||||
<addaction name="actionDownloadSharedPlugin" />
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuOpenRecent" >
|
||||
<property name="title" >
|
||||
<string>Open &Recent</string>
|
||||
</property>
|
||||
</widget>
|
||||
<addaction name="actionNew" />
|
||||
<addaction name="actionOpen" />
|
||||
<addaction name="menuOpenRecent" />
|
||||
<addaction name="menuDownload" />
|
||||
<addaction name="actionImport" />
|
||||
<addaction name="separator" />
|
||||
|
@ -2304,6 +2310,11 @@
|
|||
<string>Full Database Check...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action123" >
|
||||
<property name="text" >
|
||||
<string>123</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>newPerDay</tabstop>
|
||||
|
|
Loading…
Reference in a new issue