delay progress dialog appearance (prevents flashing, avoids stuck window bugs)

This commit is contained in:
Damien Elmes 2010-01-23 20:36:07 +09:00
parent 68b8b8a5dc
commit 4fcc04cf30
2 changed files with 10 additions and 2 deletions

View file

@ -2604,6 +2604,8 @@ it to your friends.
return
self.setBusy()
self.inDbHandler = True
if self.progressWins:
self.progressWins[0].maybeShow()
self.app.processEvents(QEventLoop.ExcludeUserInputEvents)
self.inDbHandler = False

View file

@ -233,16 +233,22 @@ class ProgressWin(object):
self.diag.setCancelButton(None)
self.diag.setAutoClose(False)
self.diag.setAutoReset(False)
self.diag.setMinimumDuration(0)
self.diag.show()
# qt doesn't seem to honour this consistently, and it's not triggered
# by the db progress handler, so we set it high and use maybeShow() below
self.diag.setMinimumDuration(100000)
self.counter = min
self.min = min
self.max = max
self.firstTime = time.time()
self.lastTime = time.time()
self.app = QApplication.instance()
if max == 0:
self.diag.setLabelText(_("Processing..."))
def maybeShow(self):
if time.time() - self.firstTime > 2:
self.diag.show()
def update(self, label=None, value=None, process=True):
#print self.min, self.counter, self.max, label, time.time() - self.lastTime
self.lastTime = time.time()