Browse Source

Merge pull request #1243 from laanwj/2012_05_uiconsole_focus

Automatically focus entry widget when console tab comes into focus
miguelfreitas
Gregory Maxwell 13 years ago
parent
commit
1eb2d8e0bf
  1. 8
      src/qt/forms/rpcconsole.ui
  2. 38
      src/qt/rpcconsole.cpp
  3. 3
      src/qt/rpcconsole.h

8
src/qt/forms/rpcconsole.ui

@ -19,9 +19,9 @@
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="tab_info">
<attribute name="title"> <attribute name="title">
<string>Information</string> <string>&amp;Information</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout" columnstretch="0,1"> <layout class="QGridLayout" name="gridLayout" columnstretch="0,1">
<property name="horizontalSpacing"> <property name="horizontalSpacing">
@ -232,9 +232,9 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_2"> <widget class="QWidget" name="tab_console">
<attribute name="title"> <attribute name="title">
<string>Console</string> <string>&amp;Console</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing"> <property name="spacing">

38
src/qt/rpcconsole.cpp

@ -113,27 +113,6 @@ RPCConsole::~RPCConsole()
delete ui; 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) bool RPCConsole::eventFilter(QObject* obj, QEvent *event)
{ {
if(obj == ui->lineEdit) if(obj == ui->lineEdit)
@ -314,3 +293,20 @@ void RPCConsole::copyMessage()
{ {
GUIUtil::copyEntryData(ui->messagesWidget, 1, Qt::EditRole); 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();
}
}

3
src/qt/rpcconsole.h

@ -28,12 +28,13 @@ public:
}; };
protected: protected:
virtual bool event(QEvent *event);
virtual bool eventFilter(QObject* obj, QEvent *event); virtual bool eventFilter(QObject* obj, QEvent *event);
private slots: private slots:
void on_lineEdit_returnPressed(); void on_lineEdit_returnPressed();
void on_tabWidget_currentChanged(int index);
public slots: public slots:
void clear(); void clear();
void message(int category, const QString &message); void message(int category, const QString &message);

Loading…
Cancel
Save