From 4fcc04cf30ae62b3778a032976c9e5cba2107779 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 23 Jan 2010 20:36:07 +0900 Subject: [PATCH] delay progress dialog appearance (prevents flashing, avoids stuck window bugs) --- ankiqt/ui/main.py | 2 ++ ankiqt/ui/utils.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ankiqt/ui/main.py b/ankiqt/ui/main.py index fdfb2bcd1..63f62bf28 100755 --- a/ankiqt/ui/main.py +++ b/ankiqt/ui/main.py @@ -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 diff --git a/ankiqt/ui/utils.py b/ankiqt/ui/utils.py index c8e31f6b1..5824ac0b3 100644 --- a/ankiqt/ui/utils.py +++ b/ankiqt/ui/utils.py @@ -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()