mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 22:42:25 -04:00
db busy handler & busy cursor
This commit is contained in:
parent
a62799613e
commit
7f0832fd61
1 changed files with 27 additions and 0 deletions
|
@ -2009,7 +2009,11 @@ day = :d""", d=yesterday)
|
||||||
addHook("startProgress", self.onStartProgress)
|
addHook("startProgress", self.onStartProgress)
|
||||||
addHook("updateProgress", self.onUpdateProgress)
|
addHook("updateProgress", self.onUpdateProgress)
|
||||||
addHook("finishProgress", self.onFinishProgress)
|
addHook("finishProgress", self.onFinishProgress)
|
||||||
|
addHook("dbProgress", self.onDbProgress)
|
||||||
|
addHook("dbFinished", self.onDbFinished)
|
||||||
self.progressParent = None
|
self.progressParent = None
|
||||||
|
self.progressWin = None
|
||||||
|
self.busyCursor = False
|
||||||
self.mainThread = QThread.currentThread()
|
self.mainThread = QThread.currentThread()
|
||||||
|
|
||||||
def setProgressParent(self, parent):
|
def setProgressParent(self, parent):
|
||||||
|
@ -2018,6 +2022,7 @@ day = :d""", d=yesterday)
|
||||||
def onStartProgress(self, max=100, min=0, title=None):
|
def onStartProgress(self, max=100, min=0, title=None):
|
||||||
if self.mainThread != QThread.currentThread():
|
if self.mainThread != QThread.currentThread():
|
||||||
return
|
return
|
||||||
|
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)
|
self.progressWin = ui.utils.ProgressWin(parent, max, min, title)
|
||||||
|
|
||||||
|
@ -2033,6 +2038,28 @@ day = :d""", d=yesterday)
|
||||||
if self.progressWin:
|
if self.progressWin:
|
||||||
self.progressWin.finish()
|
self.progressWin.finish()
|
||||||
self.progressWin = None
|
self.progressWin = None
|
||||||
|
self.unsetBusy()
|
||||||
|
|
||||||
|
def onDbProgress(self):
|
||||||
|
if self.mainThread != QThread.currentThread():
|
||||||
|
return
|
||||||
|
self.setBusy()
|
||||||
|
self.app.processEvents()
|
||||||
|
|
||||||
|
def onDbFinished(self):
|
||||||
|
if self.mainThread != QThread.currentThread():
|
||||||
|
return
|
||||||
|
if not self.progressWin:
|
||||||
|
self.unsetBusy()
|
||||||
|
|
||||||
|
def setBusy(self):
|
||||||
|
if not self.busyCursor:
|
||||||
|
self.app.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||||
|
self.busyCursor = True
|
||||||
|
|
||||||
|
def unsetBusy(self):
|
||||||
|
self.app.restoreOverrideCursor()
|
||||||
|
self.busyCursor = None
|
||||||
|
|
||||||
# Advanced features
|
# Advanced features
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
Loading…
Reference in a new issue