Merge branch 'master' of git://ichi2.net/ankiqt

This commit is contained in:
Timo Paulssen 2009-03-05 17:22:43 +01:00
commit ddec815e20
4 changed files with 41 additions and 15 deletions

View file

@ -29,6 +29,26 @@ sys.path.append(os.path.dirname(__file__))
# App initialisation # App initialisation
########################################################################## ##########################################################################
class SplashScreen(object):
def __init__(self, max=100):
self.pixmap = QPixmap(":/icons/anki-logo.png")
self.splash = QSplashScreen(self.pixmap)
self.prog = QProgressBar(self.splash)
self.prog.setMaximum(max)
self.prog.setGeometry(self.splash.width()/10, 8*self.splash.height()/10,
8*self.splash.width()/10, self.splash.height()/10)
self.splash.show()
self.val = 1
def update(self):
self.prog.setValue(self.val)
self.val += 1
QApplication.instance().processEvents()
def finish(self, obj):
self.splash.finish(obj)
def run(): def run():
import config import config
@ -54,14 +74,10 @@ def run():
app = QApplication(sys.argv) app = QApplication(sys.argv)
# Create a pixmap - not needed if you have your own.
import forms import forms
import ui import ui
pixmap = QPixmap(":/icons/anki-logo.png")
ui.splash = QSplashScreen(pixmap)
ui.splash.show()
app.processEvents()
ui.splash = SplashScreen(5)
# setup paths for forms, icons # setup paths for forms, icons
sys.path.append(modDir) sys.path.append(modDir)
@ -118,8 +134,9 @@ def run():
# load main window # load main window
ui.importAll() ui.importAll()
ui.dialogs.registerDialogs() ui.dialogs.registerDialogs()
ui.splash.update()
mw = ui.main.AnkiQt(app, conf, args) mw = ui.main.AnkiQt(app, conf, args)
try: try:
styleFile = open(os.path.join(opts.config, "style.css")) styleFile = open(os.path.join(opts.config, "style.css"))

View file

@ -354,7 +354,7 @@ class EditDeck(QMainWindow):
self.dialog.tagList.setFixedWidth(130) self.dialog.tagList.setFixedWidth(130)
self.dialog.tagList.clear() self.dialog.tagList.clear()
self.dialog.tagList.addItems(QStringList( self.dialog.tagList.addItems(QStringList(
[_('<Select Tag>'), _('No tags')] + self.alltags)) [_('All cards'), _('No tags')] + self.alltags))
self.dialog.tagList.view().setFixedWidth(300) self.dialog.tagList.view().setFixedWidth(300)
def drawSort(self): def drawSort(self):

View file

@ -48,6 +48,7 @@ class AnkiQt(QMainWindow):
self.setupSound() self.setupSound()
self.setupTray() self.setupTray()
self.connectMenuActions() self.connectMenuActions()
ui.splash.update()
if self.config['mainWindowGeom']: if self.config['mainWindowGeom']:
self.restoreGeometry(self.config['mainWindowGeom']) self.restoreGeometry(self.config['mainWindowGeom'])
self.setupViews() self.setupViews()
@ -61,10 +62,12 @@ class AnkiQt(QMainWindow):
self.setUnifiedTitleAndToolBarOnMac(True) self.setUnifiedTitleAndToolBarOnMac(True)
pass pass
# load deck # load deck
ui.splash.update()
if not self.maybeLoadLastDeck(args): if not self.maybeLoadLastDeck(args):
self.setEnabled(True) self.setEnabled(True)
self.moveToState("auto") self.moveToState("auto")
# check for updates # check for updates
ui.splash.update()
self.setupAutoUpdate() self.setupAutoUpdate()
self.setupErrorHandler() self.setupErrorHandler()
self.setupMisc() self.setupMisc()
@ -76,6 +79,7 @@ class AnkiQt(QMainWindow):
except: except:
ui.utils.showWarning(_("Broken plugin:\n\n%s") % ui.utils.showWarning(_("Broken plugin:\n\n%s") %
traceback.format_exc()) traceback.format_exc())
ui.splash.update()
ui.splash.finish(self) ui.splash.finish(self)
self.show() self.show()
@ -2013,7 +2017,7 @@ day = :d""", d=yesterday)
addHook("dbProgress", self.onDbProgress) addHook("dbProgress", self.onDbProgress)
addHook("dbFinished", self.onDbFinished) addHook("dbFinished", self.onDbFinished)
self.progressParent = None self.progressParent = None
self.progressWin = None self.progressWins = []
self.busyCursor = False self.busyCursor = False
self.mainThread = QThread.currentThread() self.mainThread = QThread.currentThread()
@ -2025,20 +2029,25 @@ day = :d""", d=yesterday)
return return
self.setBusy() self.setBusy()
parent = self.progressParent or self.app.activeWindow() or self parent = self.progressParent or self.app.activeWindow() or self
self.progressWin = ui.utils.ProgressWin(parent, max, min, title) if self.progressWins:
parent = self.progressWins[-1].diag
p = ui.utils.ProgressWin(parent, max, min, title)
self.progressWins.append(p)
def onUpdateProgress(self, label=None, value=None): def onUpdateProgress(self, label=None, value=None):
if self.mainThread != QThread.currentThread(): if self.mainThread != QThread.currentThread():
return return
if self.progressWin: if self.progressWins:
self.progressWin.update(label, value) self.progressWins[-1].update(label, value)
self.app.processEvents()
def onFinishProgress(self): def onFinishProgress(self):
if self.mainThread != QThread.currentThread(): if self.mainThread != QThread.currentThread():
return return
if self.progressWin: if self.progressWins:
self.progressWin.finish() p = self.progressWins.pop()
self.progressWin = None p.finish()
if not self.progressWins:
self.unsetBusy() self.unsetBusy()
def onDbProgress(self): def onDbProgress(self):
@ -2050,7 +2059,7 @@ day = :d""", d=yesterday)
def onDbFinished(self): def onDbFinished(self):
if self.mainThread != QThread.currentThread(): if self.mainThread != QThread.currentThread():
return return
if not self.progressWin: if not self.progressWins:
self.unsetBusy() self.unsetBusy()
def setBusy(self): def setBusy(self):

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB