Skip to content

Commit 626aec7

Browse files
committed
set default focus to the TextEdit of Finder
1 parent b301471 commit 626aec7

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

finder/finder.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Finder::Finder(QWidget *parent):
2828
connect(mFindButton, &QPushButton::clicked, this, &Finder::onFindButtonClicked);
2929
connect(mFindPreButton, &QPushButton::clicked, this, &Finder::onFindPreButtonClicked);
3030
connect(mExpressionEdit, &QLineEdit::editingFinished, this, &Finder::onFindButtonClicked);
31+
connect(this, &QDockWidget::visibilityChanged, this, &Finder::onVisibilityChanged);
3132
}
3233

3334
Finder::~Finder()
@@ -55,6 +56,13 @@ void Finder::onFindTriggered(bool backward)
5556
emit findTriggered(mExpressionEdit->text(), options, mRegModeBox->isChecked());
5657
}
5758

59+
void Finder::onVisibilityChanged(bool visible)
60+
{
61+
if (visible) {
62+
mExpressionEdit->setFocus();
63+
}
64+
}
65+
5866

5967

6068

finder/finder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class Finder : public QDockWidget
3131
private slots:
3232
void onFindButtonClicked();
3333
void onFindPreButtonClicked();
34+
void onVisibilityChanged(bool visible);
3435

3536
private:
3637
void onFindTriggered(bool backward);

0 commit comments

Comments
 (0)