mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
add "immediate" progress back
on ops which we know are going to take time, it makes the interface look more responsive to pop up the progress more quickly
This commit is contained in:
parent
7e221f0acf
commit
a8ad4abf37
9 changed files with 21 additions and 14 deletions
|
@ -441,7 +441,7 @@ and have been disabled: %(found)s"
|
|||
log = []
|
||||
errs = []
|
||||
|
||||
self.mw.progress.start(immediate=True, parent=parent)
|
||||
self.mw.progress.start(parent=parent)
|
||||
try:
|
||||
for path in paths:
|
||||
base = os.path.basename(path)
|
||||
|
|
|
@ -304,7 +304,7 @@ where id > ?""",
|
|||
(_("Are you sure you wish to delete %s?") % deck["name"]) + extra
|
||||
)
|
||||
):
|
||||
self.mw.progress.start(immediate=True)
|
||||
self.mw.progress.start()
|
||||
self.mw.col.decks.rem(did, True)
|
||||
self.mw.progress.finish()
|
||||
self.show()
|
||||
|
|
|
@ -163,7 +163,7 @@ class ExportDialog(QDialog):
|
|||
future.result()
|
||||
self.on_export_finished()
|
||||
|
||||
self.mw.progress.start(immediate=True)
|
||||
self.mw.progress.start()
|
||||
hooks.media_files_did_export.append(exported_media)
|
||||
|
||||
self.mw.taskman.run_in_background(do_export, on_done)
|
||||
|
|
|
@ -192,7 +192,7 @@ you can enter it here. Use \\t to represent tab."""
|
|||
self.importer.model["did"] = did
|
||||
self.mw.col.models.save(self.importer.model, updateReqs=False)
|
||||
self.mw.col.decks.select(did)
|
||||
self.mw.progress.start(immediate=True)
|
||||
self.mw.progress.start()
|
||||
self.mw.checkpoint(_("Import"))
|
||||
|
||||
def on_done(future: Future):
|
||||
|
|
|
@ -532,7 +532,7 @@ close the profile or restart Anki."""
|
|||
label = _("Closing...")
|
||||
else:
|
||||
label = _("Backing Up...")
|
||||
self.progress.start(label=label, immediate=True)
|
||||
self.progress.start(label=label)
|
||||
corrupt = False
|
||||
try:
|
||||
self.maybeOptimize()
|
||||
|
@ -618,7 +618,7 @@ from the profile screen."
|
|||
# have two weeks passed?
|
||||
if (intTime() - self.pm.profile["lastOptimize"]) < 86400 * 14:
|
||||
return
|
||||
self.progress.start(label=_("Optimizing..."), immediate=True)
|
||||
self.progress.start(label=_("Optimizing..."))
|
||||
self.col.optimize()
|
||||
self.pm.profile["lastOptimize"] = intTime()
|
||||
self.pm.save()
|
||||
|
@ -902,14 +902,17 @@ title="%s" %s>%s</button>""" % (
|
|||
self.media_syncer.start()
|
||||
|
||||
def can_auto_sync(self) -> bool:
|
||||
return (self.pm.auto_syncing_enabled()
|
||||
return (
|
||||
self.pm.auto_syncing_enabled()
|
||||
and self.pm.sync_auth()
|
||||
and not self.safeMode
|
||||
and not self.restoringBackup)
|
||||
and not self.restoringBackup
|
||||
)
|
||||
|
||||
# legacy
|
||||
def _sync(self):
|
||||
pass
|
||||
|
||||
onSync = on_sync_button_clicked
|
||||
|
||||
# Tools
|
||||
|
|
|
@ -52,7 +52,6 @@ class ProgressManager:
|
|||
# Creating progress dialogs
|
||||
##########################################################################
|
||||
|
||||
# note: immediate is no longer used
|
||||
def start(
|
||||
self, max=0, min=0, label=None, parent=None, immediate=False
|
||||
) -> Optional[ProgressDialog]:
|
||||
|
@ -83,7 +82,7 @@ class ProgressManager:
|
|||
self._updating = False
|
||||
self._show_timer = QTimer(self.mw)
|
||||
self._show_timer.setSingleShot(True)
|
||||
self._show_timer.start(600)
|
||||
self._show_timer.start(immediate and 100 or 600)
|
||||
qconnect(self._show_timer.timeout, self._on_show_timer)
|
||||
return self._win
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ class DeckStats(QDialog):
|
|||
self.refresh()
|
||||
|
||||
def refresh(self):
|
||||
self.mw.progress.start(immediate=True, parent=self)
|
||||
self.mw.progress.start(parent=self)
|
||||
stats = self.mw.col.stats()
|
||||
stats.wholeCollection = self.wholeCollection
|
||||
self.report = stats.report(type=self.period)
|
||||
|
|
|
@ -31,7 +31,7 @@ from aqt.utils import askUser, askUserDialog, showText, showWarning, tr
|
|||
# fixme: catch auth error in other routines, clear sync auth
|
||||
# fixme: sync progress
|
||||
# fixme: curDeck marking collection modified
|
||||
# fixme: show progress immediately
|
||||
|
||||
|
||||
class FullSyncChoice(enum.Enum):
|
||||
CANCEL = 0
|
||||
|
@ -47,7 +47,9 @@ def get_sync_status(mw: aqt.main.AnkiQt, callback: Callable[[SyncOutput], None])
|
|||
def on_future_done(fut):
|
||||
callback(fut.result())
|
||||
|
||||
mw.taskman.run_in_background(lambda: mw.col.backend.sync_status(auth), on_future_done)
|
||||
mw.taskman.run_in_background(
|
||||
lambda: mw.col.backend.sync_status(auth), on_future_done
|
||||
)
|
||||
|
||||
|
||||
def sync_collection(mw: aqt.main.AnkiQt, on_done: Callable[[], None]) -> None:
|
||||
|
@ -84,6 +86,7 @@ def sync_collection(mw: aqt.main.AnkiQt, on_done: Callable[[], None]) -> None:
|
|||
lambda: mw.col.backend.sync_collection(auth),
|
||||
on_future_done,
|
||||
label=tr(TR.SYNC_CHECKING),
|
||||
immediate=True,
|
||||
)
|
||||
|
||||
|
||||
|
@ -180,6 +183,7 @@ def full_upload(mw: aqt.main.AnkiQt, on_done: Callable[[], None]) -> None:
|
|||
label=tr(TR.SYNC_UPLOADING_TO_ANKIWEB),
|
||||
)
|
||||
|
||||
|
||||
def sync_login(
|
||||
mw: aqt.main.AnkiQt, on_success: Callable[[], None], username="", password=""
|
||||
) -> None:
|
||||
|
|
|
@ -67,8 +67,9 @@ class TaskManager(QObject):
|
|||
on_done: Optional[Callable[[Future], None]] = None,
|
||||
parent: Optional[QWidget] = None,
|
||||
label: Optional[str] = None,
|
||||
immediate: Bool = False,
|
||||
):
|
||||
self.mw.progress.start(parent=parent, label=label)
|
||||
self.mw.progress.start(parent=parent, label=label, immediate=immediate)
|
||||
|
||||
def wrapped_done(fut):
|
||||
self.mw.progress.finish()
|
||||
|
|
Loading…
Reference in a new issue