aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mainwindow/mainwindow.cpp12
-rw-r--r--src/mainwindow/widgets/searchform.cpp17
-rw-r--r--src/mainwindow/widgets/searchform.h5
3 files changed, 19 insertions, 15 deletions
diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp
index f83c2a7..eba02c6 100644
--- a/src/mainwindow/mainwindow.cpp
+++ b/src/mainwindow/mainwindow.cpp
@@ -84,7 +84,17 @@ MainWindow::MainWindow(std::shared_ptr<Configuration> &config, QWidget *parent)
auto *searchShortcut = new QShortcut(QKeySequence(config->value<std::string>("mainwindow.shortcuts.search").value().c_str()), this);
connect(searchShortcut, &QShortcut::activated, this, [=]() {
- searchBox->setVisible(!searchBox->isVisible());
+ /* QTBUG-18665
+ * When focusing out of the search box and hiding it, the first
+ * (or earlier?) subwindow gets activated for some reason.
+ */
+ if(searchBox->isVisible()) {
+ auto *w = mdiArea->currentSubWindow();
+ searchBox->hide();
+ mdiArea->setActiveSubWindow(w);
+ } else {
+ searchBox->show();
+ }
});
}
diff --git a/src/mainwindow/widgets/searchform.cpp b/src/mainwindow/widgets/searchform.cpp
index b400079..c6038ff 100644
--- a/src/mainwindow/widgets/searchform.cpp
+++ b/src/mainwindow/widgets/searchform.cpp
@@ -8,7 +8,8 @@
#include "searchform.h"
#include "ui_searchform.h"
-#include <QFocusEvent>
+#include <QShowEvent>
+#include <QHideEvent>
#include <QWebEngineView>
SearchForm::SearchForm(QWidget *parent)
@@ -42,24 +43,18 @@ void SearchForm::setView(QWebEngineView *view)
this->view = view;
}
-void SearchForm::showEvent(QShowEvent *e)
+void SearchForm::showEvent(QShowEvent *event)
{
- e->accept();
ui->lineEdit->setFocus();
ui->lineEdit->selectAll();
+ event->accept();
}
-void SearchForm::hideEvent(QHideEvent *e)
+void SearchForm::hideEvent(QHideEvent *event)
{
- e->accept();
// clear highlighted text when hiding
if(view) {
view->findText("");
}
-}
-
-void SearchForm::focusInEvent(QFocusEvent *e)
-{
- ui->lineEdit->setFocus();
- e->accept();
+ event->accept();
}
diff --git a/src/mainwindow/widgets/searchform.h b/src/mainwindow/widgets/searchform.h
index 59c4ef5..2219711 100644
--- a/src/mainwindow/widgets/searchform.h
+++ b/src/mainwindow/widgets/searchform.h
@@ -29,9 +29,8 @@ public slots:
void setView(QWebEngineView *view);
protected:
- void showEvent(QShowEvent *e) override;
- void hideEvent(QHideEvent *e) override;
- void focusInEvent(QFocusEvent *e) override;
+ void showEvent(QShowEvent *event) override;
+ void hideEvent(QHideEvent *event) override;
private:
Ui::SearchForm *ui;