1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-23 13:04:23 +00:00

Make num enter key work the same as return in searchjobwidget

This commit is contained in:
thalieht 2019-03-22 20:01:35 +02:00
parent 6de02b0f2a
commit 3731a3ea65
2 changed files with 16 additions and 3 deletions

View File

@ -33,6 +33,7 @@
#include <QClipboard> #include <QClipboard>
#include <QDesktopServices> #include <QDesktopServices>
#include <QHeaderView> #include <QHeaderView>
#include <QKeyEvent>
#include <QMenu> #include <QMenu>
#include <QPalette> #include <QPalette>
#include <QStandardItemModel> #include <QStandardItemModel>
@ -160,9 +161,6 @@ SearchJobWidget::SearchJobWidget(SearchHandler *searchHandler, QWidget *parent)
connect(searchHandler, &SearchHandler::searchFailed, this, &SearchJobWidget::searchFailed); connect(searchHandler, &SearchHandler::searchFailed, this, &SearchJobWidget::searchFailed);
connect(this, &QObject::destroyed, searchHandler, &QObject::deleteLater); connect(this, &QObject::destroyed, searchHandler, &QObject::deleteLater);
QShortcut *enterHotkey = new QShortcut(Qt::Key_Return, m_ui->resultsBrowser, nullptr, nullptr, Qt::WidgetShortcut);
connect(enterHotkey, &QShortcut::activated, this, &SearchJobWidget::downloadTorrents);
setStatusTip(statusText(m_status)); setStatusTip(statusText(m_status));
} }
@ -479,3 +477,15 @@ CachedSettingValue<SearchJobWidget::NameFilteringMode> &SearchJobWidget::nameFil
static CachedSettingValue<NameFilteringMode> setting("Search/FilteringMode", NameFilteringMode::OnlyNames); static CachedSettingValue<NameFilteringMode> setting("Search/FilteringMode", NameFilteringMode::OnlyNames);
return setting; return setting;
} }
void SearchJobWidget::keyPressEvent(QKeyEvent *event)
{
switch (event->key()) {
case Qt::Key_Enter:
case Qt::Key_Return:
downloadTorrents();
break;
default:
QWidget::keyPressEvent(event);
}
}

View File

@ -90,6 +90,9 @@ signals:
void resultsCountUpdated(); void resultsCountUpdated();
void statusChanged(); void statusChanged();
protected:
void keyPressEvent(QKeyEvent *event) override;
private: private:
void loadSettings(); void loadSettings();
void saveSettings() const; void saveSettings() const;