#3945 deck list: Navigation keys (PageUp/Down, Home/End) (#5103)
Some checks failed
Build Desktop / Configure (push) Has been cancelled
Build Desktop / ${{matrix.distro}} (Debian11, DEB) (push) Has been cancelled
Build Desktop / ${{matrix.distro}} (Debian12, DEB) (push) Has been cancelled
Build Desktop / ${{matrix.distro}} (Fedora39, RPM) (push) Has been cancelled
Build Desktop / ${{matrix.distro}} (Fedora40, RPM) (push) Has been cancelled
Build Desktop / ${{matrix.distro}} (UbuntuBionic, DEB) (push) Has been cancelled
Build Desktop / ${{matrix.distro}} (UbuntuFocal, DEB, skip) (push) Has been cancelled
Build Desktop / ${{matrix.distro}} (UbuntuJammy, DEB, skip) (push) Has been cancelled
Build Desktop / ${{matrix.distro}} (UbuntuNoble, DEB) (push) Has been cancelled
Build Desktop / ${{matrix.distro}} (yes, ArchLinux, skip) (push) Has been cancelled
Build Desktop / macOS${{matrix.target}} (1, macos-12, 12_Monterey_and_13_Ventura, Release, 14.0.1) (push) Has been cancelled
Build Desktop / macOS${{matrix.target}} (1, macos-14, 14_Sonoma, Release, 15.4) (push) Has been cancelled
Build Desktop / macOS${{matrix.target}} (macos-14, 14_Sonoma_Debug, Debug, 15.4) (push) Has been cancelled
Build Desktop / Windows ${{matrix.target}} (msvc2019_64, 5.15.*, 7) (push) Has been cancelled
Build Desktop / Windows ${{matrix.target}} (msvc2019_64, qtimageformats qtmultimedia qtwebsockets, 6.5.*, 10) (push) Has been cancelled

* #3945 deck list: Navigation keys (PageUp/Down, Home/End) interact with the deck list.

* make Home/End work normally when there is text in the search textbox

* fix debug build, explicit cast from int to Qt::Key enum
This commit is contained in:
Polty
2024-10-09 23:11:12 +02:00
committed by GitHub
parent b4bfa17cee
commit 44e92f61ca

View File

@@ -50,8 +50,17 @@
void SearchLineEdit::keyPressEvent(QKeyEvent *event)
{
if (treeView && ((event->key() == Qt::Key_Up) || (event->key() == Qt::Key_Down)))
QCoreApplication::sendEvent(treeView, event);
// List of key events that must be handled by the card list instead of the search box
static const QVector<Qt::Key> forwardToTreeView = {Qt::Key_Up, Qt::Key_Down, Qt::Key_PageDown, Qt::Key_PageUp};
// forward only if the search text is empty
static const QVector<Qt::Key> forwardWhenEmpty = {Qt::Key_Home, Qt::Key_End};
Qt::Key key = static_cast<Qt::Key>(event->key());
if (treeView) {
if (forwardToTreeView.contains(key))
QCoreApplication::sendEvent(treeView, event);
if (text().isEmpty() && forwardWhenEmpty.contains(key))
QCoreApplication::sendEvent(treeView, event);
}
LineEditUnfocusable::keyPressEvent(event);
}