Browse Source

Add hotkey for toggling focus between the search LineEdits

adaptive-webui-19844
thalieht 6 years ago
parent
commit
ae03ecea21
  1. 5
      src/gui/search/searchjobwidget.cpp
  2. 1
      src/gui/search/searchjobwidget.h
  3. 16
      src/gui/search/searchwidget.cpp
  4. 3
      src/gui/search/searchwidget.h

5
src/gui/search/searchjobwidget.cpp

@ -198,6 +198,11 @@ int SearchJobWidget::visibleResultsCount() const @@ -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();

1
src/gui/search/searchjobwidget.h

@ -79,6 +79,7 @@ public: @@ -79,6 +79,7 @@ public:
Status status() const;
int visibleResultsCount() const;
LineEdit *lineEditSearchResultsFilter() const;
void cancelSearch();

16
src/gui/search/searchwidget.cpp

@ -41,6 +41,7 @@ @@ -41,6 +41,7 @@
#include <QMimeData>
#include <QProcess>
#include <QRegularExpression>
#include <QShortcut>
#include <QSignalMapper>
#include <QSortFilterProxyModel>
#include <QStandardItemModel>
@ -154,6 +155,9 @@ SearchWidget::SearchWidget(MainWindow *mainWindow) @@ -154,6 +155,9 @@ SearchWidget::SearchWidget(MainWindow *mainWindow)
, this, &SearchWidget::selectMultipleBox);
connect(m_ui->selectPlugin, static_cast<void (QComboBox::*)(int)>(&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) @@ -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);

3
src/gui/search/searchwidget.h

@ -33,6 +33,7 @@ @@ -33,6 +33,7 @@
#include <QPointer>
#include <QWidget>
class QShortcut;
class QSignalMapper;
class QTabWidget;
@ -68,6 +69,7 @@ private: @@ -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: @@ -85,4 +87,5 @@ private:
QList<SearchJobWidget *> m_allTabs; // To store all tabs
MainWindow *m_mainWindow;
bool m_isNewQueryString;
QShortcut *m_focusSearchHotkey;
};

Loading…
Cancel
Save