mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-15 03:28:49 -07:00
* #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:
parent
b4bfa17cee
commit
44e92f61ca
1 changed files with 11 additions and 2 deletions
|
|
@ -50,8 +50,17 @@
|
||||||
|
|
||||||
void SearchLineEdit::keyPressEvent(QKeyEvent *event)
|
void SearchLineEdit::keyPressEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
if (treeView && ((event->key() == Qt::Key_Up) || (event->key() == Qt::Key_Down)))
|
// List of key events that must be handled by the card list instead of the search box
|
||||||
QCoreApplication::sendEvent(treeView, event);
|
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);
|
LineEditUnfocusable::keyPressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue