mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Add dec to make methods no-op if no selection
This commit is contained in:
parent
c71b684a94
commit
458d891d28
2 changed files with 14 additions and 0 deletions
|
@ -65,6 +65,7 @@ browsing-nd-names = { $num }: { $name }
|
||||||
browsing-new = (new)
|
browsing-new = (new)
|
||||||
browsing-new-note-type = New note type:
|
browsing-new-note-type = New note type:
|
||||||
browsing-no-flag = No Flag
|
browsing-no-flag = No Flag
|
||||||
|
browsing-no-selection = No cards or notes selected.
|
||||||
browsing-note = Note
|
browsing-note = Note
|
||||||
# Exactly one character representing 'Notes'; should differ from browsing-card-initial.
|
# Exactly one character representing 'Notes'; should differ from browsing-card-initial.
|
||||||
browsing-note-initial = N
|
browsing-note-initial = N
|
||||||
|
|
|
@ -1009,6 +1009,19 @@ def ensure_editor_saved_on_trigger(func: Callable) -> Callable:
|
||||||
return pyqtSlot()(ensure_editor_saved(func)) # type: ignore
|
return pyqtSlot()(ensure_editor_saved(func)) # type: ignore
|
||||||
|
|
||||||
|
|
||||||
|
def skip_if_selection_is_empty(func: Callable) -> Callable:
|
||||||
|
"""Make the wrapped method a no-op and show a hint if the table selection is empty."""
|
||||||
|
|
||||||
|
@wraps(func)
|
||||||
|
def decorated(self: Any, *args: Any, **kwargs: Any) -> None:
|
||||||
|
if self.table.len_selection() > 0:
|
||||||
|
func(self, *args, **kwargs)
|
||||||
|
else:
|
||||||
|
tooltip(tr.browsing_no_selection())
|
||||||
|
|
||||||
|
return decorated
|
||||||
|
|
||||||
|
|
||||||
class KeyboardModifiersPressed:
|
class KeyboardModifiersPressed:
|
||||||
"Util for type-safe checks of currently-pressed modifier keys."
|
"Util for type-safe checks of currently-pressed modifier keys."
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue