Mercurial > hg > bitcoin
changeset 2441:95d544c69449 draft
Automatically focus entry widget when console tab comes into focus
Fixes #1241
author | Wladimir J. van der Laan <laanwj@gmail.com> |
---|---|
date | Wed, 09 May 2012 17:12:05 +0200 |
parents | dd18af87d701 |
children | 2fa6930a8fe5 |
files | src/qt/forms/rpcconsole.ui src/qt/rpcconsole.cpp src/qt/rpcconsole.h |
diffstat | 3 files changed, 21 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/src/qt/forms/rpcconsole.ui +++ b/src/qt/forms/rpcconsole.ui @@ -19,7 +19,7 @@ <property name="currentIndex"> <number>0</number> </property> - <widget class="QWidget" name="tab"> + <widget class="QWidget" name="tab_info"> <attribute name="title"> <string>Information</string> </attribute> @@ -232,7 +232,7 @@ </item> </layout> </widget> - <widget class="QWidget" name="tab_2"> + <widget class="QWidget" name="tab_console"> <attribute name="title"> <string>Console</string> </attribute>
--- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -113,27 +113,6 @@ delete ui; } -bool RPCConsole::event(QEvent *event) -{ - int returnValue = QWidget::event(event); - - if (event->type() == QEvent::LayoutRequest && firstLayout) - { - // Work around QTableWidget issue: - // Call resizeRowsToContents on first Layout request with widget visible, - // to make sure multiline messages that were added before the console was shown - // have the right height. - if(ui->messagesWidget->isVisible()) - { - firstLayout = false; - ui->messagesWidget->resizeRowsToContents(); - } - return true; - } - - return returnValue; -} - bool RPCConsole::eventFilter(QObject* obj, QEvent *event) { if(obj == ui->lineEdit) @@ -314,3 +293,20 @@ { GUIUtil::copyEntryData(ui->messagesWidget, 1, Qt::EditRole); } + +void RPCConsole::on_tabWidget_currentChanged(int index) +{ + if(ui->tabWidget->widget(index) == ui->tab_console) + { + if(firstLayout) + { + // Work around QTableWidget issue: + // Call resizeRowsToContents on first Layout request with widget visible, + // to make sure multiline messages that were added before the console was shown + // have the right height. + firstLayout = false; + ui->messagesWidget->resizeRowsToContents(); + } + ui->lineEdit->setFocus(); + } +}
--- a/src/qt/rpcconsole.h +++ b/src/qt/rpcconsole.h @@ -28,12 +28,13 @@ }; protected: - virtual bool event(QEvent *event); virtual bool eventFilter(QObject* obj, QEvent *event); private slots: void on_lineEdit_returnPressed(); + void on_tabWidget_currentChanged(int index); + public slots: void clear(); void message(int category, const QString &message);