Skip to content

Commit

Permalink
qt: Do not use QKeyEvent copy constructor
Browse files Browse the repository at this point in the history
This change is preparation for Qt 6, and it fixes an experimental build
with Qt 6.2.4 as copying of `QEvent` has been disabled in Qt 6.0.0 (see
19f9b0d5f54379151eb71e98555b203ad6756276 upstream commit).
  • Loading branch information
hebasto committed Apr 10, 2022
1 parent e0680bb commit 8691a44
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/qt/rpcconsole.cpp
Expand Up @@ -610,6 +610,7 @@ bool RPCConsole::eventFilter(QObject* obj, QEvent *event)
if(event->type() == QEvent::KeyPress) // Special key handling
{
QKeyEvent *keyevt = static_cast<QKeyEvent*>(event);
const auto type = keyevt->type();
int key = keyevt->key();
Qt::KeyboardModifiers mod = keyevt->modifiers();
switch(key)
Expand All @@ -618,31 +619,30 @@ bool RPCConsole::eventFilter(QObject* obj, QEvent *event)
case Qt::Key_Down: if(obj == ui->lineEdit) { browseHistory(1); return true; } break;
case Qt::Key_PageUp: /* pass paging keys to messages widget */
case Qt::Key_PageDown:
if(obj == ui->lineEdit)
{
QApplication::postEvent(ui->messagesWidget, new QKeyEvent(*keyevt));
if (obj == ui->lineEdit) {
QApplication::postEvent(ui->messagesWidget, new QKeyEvent(type, key, mod));
return true;
}
break;
case Qt::Key_Return:
case Qt::Key_Enter:
// forward these events to lineEdit
if(obj == autoCompleter->popup()) {
QApplication::postEvent(ui->lineEdit, new QKeyEvent(*keyevt));
if (obj == autoCompleter->popup()) {
QApplication::postEvent(ui->lineEdit, new QKeyEvent(type, key, mod));
autoCompleter->popup()->hide();
return true;
}
break;
default:
// Typing in messages widget brings focus to line edit, and redirects key there
// Exclude most combinations and keys that emit no text, except paste shortcuts
if(obj == ui->messagesWidget && (
if (obj == ui->messagesWidget && (
(!mod && !keyevt->text().isEmpty() && key != Qt::Key_Tab) ||
((mod & Qt::ControlModifier) && key == Qt::Key_V) ||
((mod & Qt::ShiftModifier) && key == Qt::Key_Insert)))
{
ui->lineEdit->setFocus();
QApplication::postEvent(ui->lineEdit, new QKeyEvent(*keyevt));
QApplication::postEvent(ui->lineEdit, new QKeyEvent(type, key, mod));
return true;
}
}
Expand Down

0 comments on commit 8691a44

Please sign in to comment.