aboutsummaryrefslogtreecommitdiff
path: root/src/qt/rpcconsole.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qt/rpcconsole.cpp')
-rw-r--r--src/qt/rpcconsole.cpp39
1 files changed, 30 insertions, 9 deletions
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index 7d5b6fed53..3dc32d0e47 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -15,12 +15,11 @@
#include <openssl/crypto.h>
+// TODO: add a scrollback limit, as there is currently none
// TODO: make it possible to filter out categories (esp debug messages when implemented)
// TODO: receive errors and debug messages through ClientModel
-const int CONSOLE_SCROLLBACK = 50;
const int CONSOLE_HISTORY = 50;
-
const QSize ICON_SIZE(24, 24);
const struct {
@@ -192,13 +191,14 @@ RPCConsole::RPCConsole(QWidget *parent) :
{
ui->setupUi(this);
-#ifndef Q_WS_MAC
+#ifndef Q_OS_MAC
ui->openDebugLogfileButton->setIcon(QIcon(":/icons/export"));
ui->showCLOptionsButton->setIcon(QIcon(":/icons/options"));
#endif
// Install event filter for up and down arrow
ui->lineEdit->installEventFilter(this);
+ ui->messagesWidget->installEventFilter(this);
connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear()));
@@ -218,15 +218,34 @@ RPCConsole::~RPCConsole()
bool RPCConsole::eventFilter(QObject* obj, QEvent *event)
{
- if(obj == ui->lineEdit)
+ if(event->type() == QEvent::KeyPress) // Special key handling
{
- if(event->type() == QEvent::KeyPress)
+ QKeyEvent *keyevt = static_cast<QKeyEvent*>(event);
+ int key = keyevt->key();
+ Qt::KeyboardModifiers mod = keyevt->modifiers();
+ switch(key)
{
- QKeyEvent *key = static_cast<QKeyEvent*>(event);
- switch(key->key())
+ case Qt::Key_Up: if(obj == ui->lineEdit) { browseHistory(-1); return true; } break;
+ 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));
+ 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 && (
+ (!mod && !keyevt->text().isEmpty() && key != Qt::Key_Tab) ||
+ ((mod & Qt::ControlModifier) && key == Qt::Key_V) ||
+ ((mod & Qt::ShiftModifier) && key == Qt::Key_Insert)))
{
- case Qt::Key_Up: browseHistory(-1); return true;
- case Qt::Key_Down: browseHistory(1); return true;
+ ui->lineEdit->setFocus();
+ QApplication::postEvent(ui->lineEdit, new QKeyEvent(*keyevt));
+ return true;
}
}
}
@@ -269,6 +288,8 @@ static QString categoryClass(int category)
void RPCConsole::clear()
{
ui->messagesWidget->clear();
+ history.clear();
+ historyPtr = 0;
ui->lineEdit->clear();
ui->lineEdit->setFocus();