1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-25 22:14:32 +00:00

Add hotkey for toggling focus between the search LineEdits

This commit is contained in:
thalieht 2018-07-05 11:16:14 +03:00
parent 2e9c61c452
commit ae03ecea21
4 changed files with 25 additions and 0 deletions

View File

@ -198,6 +198,11 @@ int SearchJobWidget::visibleResultsCount() const
return m_proxyModel->rowCount(); return m_proxyModel->rowCount();
} }
LineEdit *SearchJobWidget::lineEditSearchResultsFilter() const
{
return m_lineEditSearchResultsFilter;
}
void SearchJobWidget::cancelSearch() void SearchJobWidget::cancelSearch()
{ {
m_searchHandler->cancelSearch(); m_searchHandler->cancelSearch();

View File

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

View File

@ -41,6 +41,7 @@
#include <QMimeData> #include <QMimeData>
#include <QProcess> #include <QProcess>
#include <QRegularExpression> #include <QRegularExpression>
#include <QShortcut>
#include <QSignalMapper> #include <QSignalMapper>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QStandardItemModel> #include <QStandardItemModel>
@ -154,6 +155,9 @@ SearchWidget::SearchWidget(MainWindow *mainWindow)
, this, &SearchWidget::selectMultipleBox); , this, &SearchWidget::selectMultipleBox);
connect(m_ui->selectPlugin, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged) connect(m_ui->selectPlugin, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged)
, this, &SearchWidget::fillCatCombobox); , this, &SearchWidget::fillCatCombobox);
m_focusSearchHotkey = new QShortcut(QKeySequence::Find, this);
connect(m_focusSearchHotkey, &QShortcut::activated, this, &SearchWidget::toggleFocusBetweenLineEdits);
} }
void SearchWidget::fillCatCombobox() void SearchWidget::fillCatCombobox()
@ -260,6 +264,18 @@ void SearchWidget::selectMultipleBox(int index)
on_pluginsButton_clicked(); 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() void SearchWidget::on_pluginsButton_clicked()
{ {
new PluginSelectDialog(SearchPluginManager::instance(), this); new PluginSelectDialog(SearchPluginManager::instance(), this);

View File

@ -33,6 +33,7 @@
#include <QPointer> #include <QPointer>
#include <QWidget> #include <QWidget>
class QShortcut;
class QSignalMapper; class QSignalMapper;
class QTabWidget; class QTabWidget;
@ -68,6 +69,7 @@ private:
void resultsCountUpdated(); void resultsCountUpdated();
void tabStatusChanged(QWidget *tab); void tabStatusChanged(QWidget *tab);
void selectMultipleBox(int index); void selectMultipleBox(int index);
void toggleFocusBetweenLineEdits();
void fillCatCombobox(); void fillCatCombobox();
void fillPluginComboBox(); void fillPluginComboBox();
@ -85,4 +87,5 @@ private:
QList<SearchJobWidget *> m_allTabs; // To store all tabs QList<SearchJobWidget *> m_allTabs; // To store all tabs
MainWindow *m_mainWindow; MainWindow *m_mainWindow;
bool m_isNewQueryString; bool m_isNewQueryString;
QShortcut *m_focusSearchHotkey;
}; };