mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00

* Update JS deps * Update semver-compat Rust deps * Update some semver-incompat Rust deps - hyper/axum held back because reqwests is not ready - rusqlite held back due to burn-rs incompat version - wiremock held back due to compile issue * pylint wants changes to our _rsbridge.pyi * Update Python deps Also solves a security warning in orjson Reformat with latest black
38 lines
1,018 B
Python
38 lines
1,018 B
Python
# Copyright: Ankitects Pty Ltd and contributors
|
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
|
|
from anki.collection import UndoStatus
|
|
|
|
|
|
@dataclass
|
|
class UndoActionsInfo:
|
|
can_undo: bool
|
|
can_redo: bool
|
|
|
|
undo_text: str
|
|
redo_text: str
|
|
|
|
# menu item is hidden when legacy undo is active, since it can't be undone
|
|
show_redo: bool
|
|
|
|
@staticmethod
|
|
def from_undo_status(status: UndoStatus) -> UndoActionsInfo:
|
|
from aqt import tr
|
|
|
|
return UndoActionsInfo(
|
|
can_undo=bool(status.undo),
|
|
can_redo=bool(status.redo),
|
|
undo_text=(
|
|
tr.undo_undo_action(val=status.undo) if status.undo else tr.undo_undo()
|
|
),
|
|
redo_text=(
|
|
tr.undo_redo_action(action=status.redo)
|
|
if status.redo
|
|
else tr.undo_redo()
|
|
),
|
|
show_redo=status.last_step > 0,
|
|
)
|