From 12b5cf033169d5336908fb5e9e362d4ae8b75ff3 Mon Sep 17 00:00:00 2001 From: Ettore Dreucci Date: Wed, 23 Aug 2017 00:21:08 +0200 Subject: [PATCH] replaced hard function call with signal connection Signed-off-by: Ettore Dreucci --- src/gui/MainWindow.cpp | 4 ---- src/gui/SearchWidget.cpp | 3 ++- src/gui/SearchWidget.h | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index ec1406c4a..3fe6d09a0 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -465,10 +465,6 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode) m_searchWidgetAction->setEnabled(true); - //if not already in search mode focus the search widget and select all its content - if (!inSearch) { - m_ui->toolBar->findChild("SearchWidget")->searchFocus(); - } break; } case DatabaseWidget::EditMode: diff --git a/src/gui/SearchWidget.cpp b/src/gui/SearchWidget.cpp index 7aa5f2901..ed3a50b2a 100644 --- a/src/gui/SearchWidget.cpp +++ b/src/gui/SearchWidget.cpp @@ -119,7 +119,8 @@ void SearchWidget::databaseChanged(DatabaseWidget* dbWidget) if (dbWidget != nullptr) { // Set current search text from this database m_ui->searchEdit->setText(dbWidget->getCurrentSearch()); - + // Keyboard focus on search widget at database unlocking + connect(dbWidget, SIGNAL(unlockedDatabase()), this, SLOT(searchFocus())); // Enforce search policy emit caseSensitiveChanged(m_actionCaseSensitive->isChecked()); emit limitGroupChanged(m_actionLimitGroup->isChecked()); diff --git a/src/gui/SearchWidget.h b/src/gui/SearchWidget.h index 15e3488fb..2441ef60b 100644 --- a/src/gui/SearchWidget.h +++ b/src/gui/SearchWidget.h @@ -55,13 +55,13 @@ signals: public slots: void databaseChanged(DatabaseWidget* dbWidget = 0); - void searchFocus(); private slots: void startSearchTimer(); void startSearch(); void updateCaseSensitive(); void updateLimitGroup(); + void searchFocus(); private: const QScopedPointer m_ui;