From 6aadba36a2852c49300f241b44246b8c34b05027 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 14 Jan 2023 13:16:32 +0530 Subject: [PATCH] Add dedicated shortcuts for change/show next occurrence --- src/calibre/gui2/tweak_book/spell.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/calibre/gui2/tweak_book/spell.py b/src/calibre/gui2/tweak_book/spell.py index 61a5e44588..695f9a5794 100644 --- a/src/calibre/gui2/tweak_book/spell.py +++ b/src/calibre/gui2/tweak_book/spell.py @@ -1130,6 +1130,17 @@ class SpellCheck(Dialog): a.setShortcut(QKeySequence(Qt.Key.Key_Up)) self.addAction(a) + def button_action(sc, tt, button): + a = QAction(self) + self.addAction(a) + a.setShortcut(QKeySequence(sc, QKeySequence.SequenceFormat.PortableText)) + button.setToolTip(tt + f' [{a.shortcut().toString(QKeySequence.SequenceFormat.NativeText)}]') + a.triggered.connect(button.click) + return a + + self.action_change_word = button_action('ctrl+right', _('Change all occurrences of this word'), self.change_button) + self.action_show_next_occurrence = button_action('alt+right', _('Show next occurrence of this word in the book'), self.next_occurrence) + def next_word(self): v = self.suggested_list if self.focusWidget() is self.suggested_list else self.words_view v.next_word()