mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Spell check dialog: Allow up and down arrow keys to work regardless of focus
This commit is contained in:
parent
1adeef4743
commit
6f107061fc
@ -10,12 +10,12 @@ from collections import OrderedDict, defaultdict
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QT_VERSION_STR, QAbstractItemView, QAbstractTableModel, QApplication, QCheckBox,
|
QT_VERSION_STR, QAbstractItemView, QAbstractTableModel, QAction, QApplication,
|
||||||
QComboBox, QDialog, QDialogButtonBox, QFont, QFormLayout, QGridLayout, QHBoxLayout,
|
QCheckBox, QComboBox, QDialog, QDialogButtonBox, QFont, QFormLayout, QGridLayout,
|
||||||
QIcon, QInputDialog, QKeySequence, QLabel, QLineEdit, QListWidget, QListWidgetItem,
|
QHBoxLayout, QIcon, QInputDialog, QKeySequence, QLabel, QLineEdit, QListWidget,
|
||||||
QMenu, QModelIndex, QPlainTextEdit, QPushButton, QSize, QStackedLayout, Qt,
|
QListWidgetItem, QMenu, QModelIndex, QPlainTextEdit, QPushButton, QSize,
|
||||||
QTableView, QTimer, QToolButton, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget,
|
QStackedLayout, Qt, QTableView, QTimer, QToolButton, QTreeWidget, QTreeWidgetItem,
|
||||||
pyqtSignal,
|
QVBoxLayout, QWidget, pyqtSignal,
|
||||||
)
|
)
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
@ -856,6 +856,17 @@ class WordsView(QTableView):
|
|||||||
self.setTabKeyNavigation(False)
|
self.setTabKeyNavigation(False)
|
||||||
self.verticalHeader().close()
|
self.verticalHeader().close()
|
||||||
|
|
||||||
|
def change_current_word_by(self, delta=1):
|
||||||
|
row = self.currentIndex().row()
|
||||||
|
row = (row + delta + self.model().rowCount()) % self.model().rowCount()
|
||||||
|
self.highlight_row(row)
|
||||||
|
|
||||||
|
def next_word(self):
|
||||||
|
self.change_current_word_by(1)
|
||||||
|
|
||||||
|
def previous_word(self):
|
||||||
|
self.change_current_word_by(-1)
|
||||||
|
|
||||||
def keyPressEvent(self, ev):
|
def keyPressEvent(self, ev):
|
||||||
if ev == QKeySequence.StandardKey.Copy:
|
if ev == QKeySequence.StandardKey.Copy:
|
||||||
self.copy_to_clipboard()
|
self.copy_to_clipboard()
|
||||||
@ -1099,6 +1110,14 @@ class SpellCheck(Dialog):
|
|||||||
self.hb = h = FlowLayout()
|
self.hb = h = FlowLayout()
|
||||||
self.summary = s = QLabel('')
|
self.summary = s = QLabel('')
|
||||||
self.main.l.addLayout(h), h.addWidget(s), h.addWidget(om), h.addWidget(cs), h.addWidget(cs2)
|
self.main.l.addLayout(h), h.addWidget(s), h.addWidget(om), h.addWidget(cs), h.addWidget(cs2)
|
||||||
|
self.action_next_word = a = QAction(self)
|
||||||
|
a.setShortcut(QKeySequence(Qt.Key.Key_Down))
|
||||||
|
a.triggered.connect(self.words_view.next_word)
|
||||||
|
self.addAction(a)
|
||||||
|
self.action_previous_word = a = QAction(self)
|
||||||
|
a.triggered.connect(self.words_view.previous_word)
|
||||||
|
a.setShortcut(QKeySequence(Qt.Key.Key_Up))
|
||||||
|
self.addAction(a)
|
||||||
|
|
||||||
def keyPressEvent(self, ev):
|
def keyPressEvent(self, ev):
|
||||||
if ev.key() in (Qt.Key.Key_Enter, Qt.Key.Key_Return):
|
if ev.key() in (Qt.Key.Key_Enter, Qt.Key.Key_Return):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user