From 1c7b900aef0392571c163912d94175474e8feedb Mon Sep 17 00:00:00 2001 From: luddens Date: Tue, 28 Jan 2020 15:30:58 +0100 Subject: [PATCH] set focus on searchbar when opening a tab the searchbar isn't update if it has the focus --- src/searchbar.cpp | 3 +++ src/tabbar.cpp | 1 + src/topwidget.h | 1 + 3 files changed, 5 insertions(+) diff --git a/src/searchbar.cpp b/src/searchbar.cpp index 5584a01..f6b220e 100644 --- a/src/searchbar.cpp +++ b/src/searchbar.cpp @@ -81,6 +81,9 @@ SearchBar::SearchBar(QWidget *parent) : void SearchBar::on_currentTitleChanged(const QString& title) { + if (this->hasFocus()) { + return; + } if (!title.startsWith("zim://")) { setText(title); } else { diff --git a/src/tabbar.cpp b/src/tabbar.cpp index acac895..9923167 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -29,6 +29,7 @@ TabBar::TabBar(QWidget *parent) : auto widget = this->createNewTab(true); QUITIFNULL(current); widget->setUrl(current->url()); + KiwixApp::instance()->getMainWindow()->getTopWidget()->getSearchBar().setFocus(Qt::MouseFocusReason); }); connect(app->getAction(KiwixApp::CloseTabAction), &QAction::triggered, this, [=]() { diff --git a/src/topwidget.h b/src/topwidget.h index 4b95058..d2cb912 100644 --- a/src/topwidget.h +++ b/src/topwidget.h @@ -14,6 +14,7 @@ public: explicit TopWidget(QWidget *parent = nullptr); virtual ~TopWidget(); + SearchBar &getSearchBar() { return m_searchEntry; }; protected: void mousePressEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event);