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;