mirror of
https://github.com/ankitects/anki.git
synced 2025-12-13 06:46:55 -05:00
progress bar tweaks
This commit is contained in:
parent
42302b070e
commit
87ca8e39a8
2 changed files with 12 additions and 3 deletions
|
|
@ -194,6 +194,8 @@ class ProgressDialog(QDialog):
|
||||||
self.form.setupUi(self)
|
self.form.setupUi(self)
|
||||||
self._closingDown = False
|
self._closingDown = False
|
||||||
self.wantCancel = False
|
self.wantCancel = False
|
||||||
|
# required for smooth progress bars
|
||||||
|
self.form.progressBar.setStyleSheet("QProgressBar::chunk { width: 1px; }")
|
||||||
|
|
||||||
def cancel(self):
|
def cancel(self):
|
||||||
self._closingDown = True
|
self._closingDown = True
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,14 @@ def sync(mw: aqt.main.AnkiQt) -> None:
|
||||||
|
|
||||||
def on_done(fut):
|
def on_done(fut):
|
||||||
mw.col.db.begin()
|
mw.col.db.begin()
|
||||||
out: SyncOutput = fut.result()
|
try:
|
||||||
|
out: SyncOutput = fut.result()
|
||||||
|
except InterruptedError:
|
||||||
|
return
|
||||||
|
except Exception as e:
|
||||||
|
showWarning(str(e))
|
||||||
|
return
|
||||||
|
|
||||||
mw.pm.set_host_number(out.host_number)
|
mw.pm.set_host_number(out.host_number)
|
||||||
if out.required == out.NO_CHANGES:
|
if out.required == out.NO_CHANGES:
|
||||||
# all done
|
# all done
|
||||||
|
|
@ -101,8 +108,8 @@ def on_full_sync_timer(mw: aqt.main.AnkiQt) -> None:
|
||||||
if progress.kind != ProgressKind.FullSync:
|
if progress.kind != ProgressKind.FullSync:
|
||||||
return
|
return
|
||||||
|
|
||||||
assert isinstance(progress, FullSyncProgress)
|
assert isinstance(progress.val, FullSyncProgress)
|
||||||
mw.progress.update(value=progress.val.transferred, max=progress.val.total)
|
mw.progress.update(value=progress.val.transferred, max=progress.val.total, process=False)
|
||||||
|
|
||||||
if mw.progress.want_cancel():
|
if mw.progress.want_cancel():
|
||||||
mw.col.backend.abort_sync()
|
mw.col.backend.abort_sync()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue