Add dec to make methods no-op if no selection
This commit is contained in:
parent
c71b684a94
commit
458d891d28
@ -65,6 +65,7 @@ browsing-nd-names = { $num }: { $name }
|
||||
browsing-new = (new)
|
||||
browsing-new-note-type = New note type:
|
||||
browsing-no-flag = No Flag
|
||||
browsing-no-selection = No cards or notes selected.
|
||||
browsing-note = Note
|
||||
# Exactly one character representing 'Notes'; should differ from browsing-card-initial.
|
||||
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
|
||||
|
||||
|
||||
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:
|
||||
"Util for type-safe checks of currently-pressed modifier keys."
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user