diff --git a/src/gui/search/searchjobwidget.cpp b/src/gui/search/searchjobwidget.cpp index 9d140001c..8be2a611d 100644 --- a/src/gui/search/searchjobwidget.cpp +++ b/src/gui/search/searchjobwidget.cpp @@ -198,6 +198,11 @@ int SearchJobWidget::visibleResultsCount() const return m_proxyModel->rowCount(); } +LineEdit *SearchJobWidget::lineEditSearchResultsFilter() const +{ + return m_lineEditSearchResultsFilter; +} + void SearchJobWidget::cancelSearch() { m_searchHandler->cancelSearch(); diff --git a/src/gui/search/searchjobwidget.h b/src/gui/search/searchjobwidget.h index 3b2409189..6e4872f1e 100644 --- a/src/gui/search/searchjobwidget.h +++ b/src/gui/search/searchjobwidget.h @@ -79,6 +79,7 @@ public: Status status() const; int visibleResultsCount() const; + LineEdit *lineEditSearchResultsFilter() const; void cancelSearch(); diff --git a/src/gui/search/searchwidget.cpp b/src/gui/search/searchwidget.cpp index 43cac5dee..d4e3fba9f 100644 --- a/src/gui/search/searchwidget.cpp +++ b/src/gui/search/searchwidget.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -154,6 +155,9 @@ SearchWidget::SearchWidget(MainWindow *mainWindow) , this, &SearchWidget::selectMultipleBox); connect(m_ui->selectPlugin, static_cast(&QComboBox::currentIndexChanged) , this, &SearchWidget::fillCatCombobox); + + m_focusSearchHotkey = new QShortcut(QKeySequence::Find, this); + connect(m_focusSearchHotkey, &QShortcut::activated, this, &SearchWidget::toggleFocusBetweenLineEdits); } void SearchWidget::fillCatCombobox() @@ -260,6 +264,18 @@ void SearchWidget::selectMultipleBox(int index) on_pluginsButton_clicked(); } +void SearchWidget::toggleFocusBetweenLineEdits() +{ + if (m_ui->lineEditSearchPattern->hasFocus() && m_currentSearchTab) { + m_currentSearchTab->lineEditSearchResultsFilter()->setFocus(); + m_currentSearchTab->lineEditSearchResultsFilter()->selectAll(); + } + else { + m_ui->lineEditSearchPattern->setFocus(); + m_ui->lineEditSearchPattern->selectAll(); + } +} + void SearchWidget::on_pluginsButton_clicked() { new PluginSelectDialog(SearchPluginManager::instance(), this); diff --git a/src/gui/search/searchwidget.h b/src/gui/search/searchwidget.h index 4ecb46f4a..153beea15 100644 --- a/src/gui/search/searchwidget.h +++ b/src/gui/search/searchwidget.h @@ -33,6 +33,7 @@ #include #include +class QShortcut; class QSignalMapper; class QTabWidget; @@ -68,6 +69,7 @@ private: void resultsCountUpdated(); void tabStatusChanged(QWidget *tab); void selectMultipleBox(int index); + void toggleFocusBetweenLineEdits(); void fillCatCombobox(); void fillPluginComboBox(); @@ -85,4 +87,5 @@ private: QList m_allTabs; // To store all tabs MainWindow *m_mainWindow; bool m_isNewQueryString; + QShortcut *m_focusSearchHotkey; };