mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
avoid hanging UI when undoing in browse screen
This commit is contained in:
parent
57a05a2ae3
commit
44dc3f494c
3 changed files with 21 additions and 3 deletions
|
@ -72,8 +72,10 @@ class Checkpoint:
|
||||||
class BackendUndo:
|
class BackendUndo:
|
||||||
name: str
|
name: str
|
||||||
|
|
||||||
|
|
||||||
UndoResult = Union[None, BackendUndo, Checkpoint, ReviewUndo]
|
UndoResult = Union[None, BackendUndo, Checkpoint, ReviewUndo]
|
||||||
|
|
||||||
|
|
||||||
class Collection:
|
class Collection:
|
||||||
sched: Union[V1Scheduler, V2Scheduler]
|
sched: Union[V1Scheduler, V2Scheduler]
|
||||||
|
|
||||||
|
|
|
@ -518,7 +518,7 @@ class Browser(QMainWindow):
|
||||||
# actions
|
# actions
|
||||||
f = self.form
|
f = self.form
|
||||||
# edit
|
# edit
|
||||||
qconnect(f.actionUndo.triggered, self.mw.onUndo)
|
qconnect(f.actionUndo.triggered, self.undo)
|
||||||
qconnect(f.actionInvertSelection.triggered, self.invertSelection)
|
qconnect(f.actionInvertSelection.triggered, self.invertSelection)
|
||||||
qconnect(f.actionSelectNotes.triggered, self.selectNotes)
|
qconnect(f.actionSelectNotes.triggered, self.selectNotes)
|
||||||
if not isMac:
|
if not isMac:
|
||||||
|
@ -1498,6 +1498,16 @@ where id in %s"""
|
||||||
def on_tag_list_update(self) -> None:
|
def on_tag_list_update(self) -> None:
|
||||||
self.sidebar.refresh()
|
self.sidebar.refresh()
|
||||||
|
|
||||||
|
# Undo
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
def undo(self) -> None:
|
||||||
|
# need to make sure we don't hang the UI by redrawing the card list
|
||||||
|
# during the long-running op. mw.undo will take care of the progress
|
||||||
|
# dialog
|
||||||
|
self.setUpdatesEnabled(False)
|
||||||
|
self.mw.undo(lambda _: self.setUpdatesEnabled(True))
|
||||||
|
|
||||||
def onUndoState(self, on: bool) -> None:
|
def onUndoState(self, on: bool) -> None:
|
||||||
self.form.actionUndo.setEnabled(on)
|
self.form.actionUndo.setEnabled(on)
|
||||||
if on:
|
if on:
|
||||||
|
|
|
@ -27,8 +27,14 @@ import aqt.toolbar
|
||||||
import aqt.webview
|
import aqt.webview
|
||||||
from anki import hooks
|
from anki import hooks
|
||||||
from anki._backend import RustBackend as _RustBackend
|
from anki._backend import RustBackend as _RustBackend
|
||||||
from anki.collection import BackendUndo, Checkpoint, Collection, Config, \
|
from anki.collection import (
|
||||||
ReviewUndo, UndoResult
|
BackendUndo,
|
||||||
|
Checkpoint,
|
||||||
|
Collection,
|
||||||
|
Config,
|
||||||
|
ReviewUndo,
|
||||||
|
UndoResult,
|
||||||
|
)
|
||||||
from anki.decks import Deck
|
from anki.decks import Deck
|
||||||
from anki.hooks import runHook
|
from anki.hooks import runHook
|
||||||
from anki.sound import AVTag, SoundOrVideoTag
|
from anki.sound import AVTag, SoundOrVideoTag
|
||||||
|
|
Loading…
Reference in a new issue