Fix issue with QCompleter
authorLaser9un <laser9un@gmail.com>
Mon, 2 Dec 2019 09:09:01 +0000 (11:09 +0200)
committerLaser9un <laser9un@gmail.com>
Mon, 2 Dec 2019 09:09:01 +0000 (11:09 +0200)
based on: https://github.com/bitcoin/bitcoin/commit/16698cb77e455ae1e2fffd8d0225d2486232a366, https://github.com/bitcoin/bitcoin/commit/081cc02a9815318d5197a9a1db7e582bfa23ea51

src/qt/rpcconsole.cpp

index 1738d0f..ae74ab3 100644 (file)
@@ -244,6 +244,14 @@ bool RPCConsole::eventFilter(QObject* obj, QEvent *event)
                 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));
+                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
@@ -254,6 +262,7 @@ bool RPCConsole::eventFilter(QObject* obj, QEvent *event)
             {
                 ui->lineEdit->setFocus();
                 QApplication::postEvent(ui->lineEdit, new QKeyEvent(*keyevt));
+                autoCompleter->popup()->hide();
                 return true;
             }
         }
@@ -293,9 +302,12 @@ void RPCConsole::setClientModel(ClientModel *model)
         }
 
         autoCompleter = new QCompleter(wordList, this);
+        // ui->lineEdit is initially disabled because running commands is only
+        // possible from now on.
+        ui->lineEdit->setEnabled(true);
         ui->lineEdit->setCompleter(autoCompleter);
-
-        }
+        autoCompleter->popup()->installEventFilter(this);
+    }
 }
 
 static QString categoryClass(int category)