1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-11 07:18:08 +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();
}
LineEdit *SearchJobWidget::lineEditSearchResultsFilter() const
{
return m_lineEditSearchResultsFilter;
}
void SearchJobWidget::cancelSearch()
{
m_searchHandler->cancelSearch();

View File

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

View File

@ -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)
, 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)
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);

View File

@ -33,6 +33,7 @@
#include <QPointer>
#include <QWidget>
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<SearchJobWidget *> m_allTabs; // To store all tabs
MainWindow *m_mainWindow;
bool m_isNewQueryString;
QShortcut *m_focusSearchHotkey;
};