From 90d4d62c48b0a333c58e62ba74902a110a6e2005 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 6 Mar 2020 13:14:37 +1000 Subject: [PATCH] use a timer to automatically show progress window We were previously relying on the DB progress hook to cause the progress window to display. Qt's progress dialogs do have built in support for automatically showing, but it's easier to add a timer than change the existing code to use it. --- qt/aqt/progress.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/qt/aqt/progress.py b/qt/aqt/progress.py index e072bcb81..de8b9aef5 100644 --- a/qt/aqt/progress.py +++ b/qt/aqt/progress.py @@ -25,6 +25,7 @@ class ProgressManager: self.app = QApplication.instance() self.inDB = False self.blockUpdates = False + self._show_timer: Optional[QTimer] = None self._win = None self._levels = 0 @@ -114,6 +115,10 @@ class ProgressManager: self._firstTime = time.time() self._lastUpdate = time.time() self._updating = False + self._show_timer = QTimer(self.mw) + self._show_timer.setSingleShot(True) + self._show_timer.start(600) + self._show_timer.timeout.connect(self._on_show_timer) return self._win def update(self, label=None, value=None, process=True, maybeShow=True): @@ -143,6 +148,9 @@ class ProgressManager: if self._win: self._closeWin() self._unsetBusy() + if self._show_timer: + self._show_timer.stop() + self._show_timer = None def clear(self): "Restore the interface after an error." @@ -189,6 +197,10 @@ class ProgressManager: "True if processing." return self._levels + def _on_show_timer(self): + self._show_timer = None + self._showWin() + class ProgressDialog(QDialog): def __init__(self, parent):