diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index 67371fac0..5a02d3df7 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -382,6 +382,12 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::TorrentDescriptor &to m_filterLine->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); connect(m_filterLine, &LineEdit::textChanged, m_ui->contentTreeView, &TorrentContentWidget::setFilterPattern); m_ui->contentFilterLayout->insertWidget(3, m_filterLine); + const auto *focusSearchHotkey = new QShortcut(QKeySequence::Find, this); + connect(focusSearchHotkey, &QShortcut::activated, this, [this]() + { + m_filterLine->setFocus(); + m_filterLine->selectAll(); + }); loadState(); diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index e69f6fca4..edd8004b9 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -82,6 +82,7 @@ #include "powermanagement/powermanagement.h" #include "properties/peerlistwidget.h" #include "properties/propertieswidget.h" +#include "properties/proptabbar.h" #include "rss/rsswidget.h" #include "search/searchwidget.h" #include "speedlimitdialog.h" @@ -724,10 +725,18 @@ void MainWindow::displaySearchTab(bool enable) } } -void MainWindow::focusSearchFilter() +void MainWindow::toggleFocusBetweenLineEdits() { - m_columnFilterEdit->setFocus(); - m_columnFilterEdit->selectAll(); + if (m_columnFilterEdit->hasFocus() && (m_propertiesWidget->tabBar()->currentIndex() == PropTabBar::FilesTab)) + { + m_propertiesWidget->contentFilterLine()->setFocus(); + m_propertiesWidget->contentFilterLine()->selectAll(); + } + else + { + m_columnFilterEdit->setFocus(); + m_columnFilterEdit->selectAll(); + } } void MainWindow::updateNbTorrents() @@ -852,9 +861,9 @@ void MainWindow::createKeyboardShortcuts() const auto *switchExecutionLogShortcut = new QShortcut((Qt::ALT | Qt::Key_4), this); connect(switchExecutionLogShortcut, &QShortcut::activated, this, &MainWindow::displayExecutionLogTab); const auto *switchSearchFilterShortcut = new QShortcut(QKeySequence::Find, m_transferListWidget); - connect(switchSearchFilterShortcut, &QShortcut::activated, this, &MainWindow::focusSearchFilter); + connect(switchSearchFilterShortcut, &QShortcut::activated, this, &MainWindow::toggleFocusBetweenLineEdits); const auto *switchSearchFilterShortcutAlternative = new QShortcut((Qt::CTRL | Qt::Key_E), m_transferListWidget); - connect(switchSearchFilterShortcutAlternative, &QShortcut::activated, this, &MainWindow::focusSearchFilter); + connect(switchSearchFilterShortcutAlternative, &QShortcut::activated, this, &MainWindow::toggleFocusBetweenLineEdits); m_ui->actionDocumentation->setShortcut(QKeySequence::HelpContents); m_ui->actionOptions->setShortcut(Qt::ALT | Qt::Key_O); diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index 65d1088c8..4fc08a253 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -125,7 +125,7 @@ private slots: void displaySearchTab(); void displayRSSTab(); void displayExecutionLogTab(); - void focusSearchFilter(); + void toggleFocusBetweenLineEdits(); void reloadSessionStats(); void reloadTorrentStats(const QVector &torrents); void loadPreferences(); diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index e9f30c095..cc3e5b6cc 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -257,6 +257,16 @@ QTreeView *PropertiesWidget::getFilesList() const return m_ui->filesList; } +PropTabBar *PropertiesWidget::tabBar() const +{ + return m_tabBar; +} + +LineEdit *PropertiesWidget::contentFilterLine() const +{ + return m_contentFilterLine; +} + void PropertiesWidget::updateSavePath(BitTorrent::Torrent *const torrent) { if (torrent == m_torrent) diff --git a/src/gui/properties/propertieswidget.h b/src/gui/properties/propertieswidget.h index f8dfc9eba..31a1963b0 100644 --- a/src/gui/properties/propertieswidget.h +++ b/src/gui/properties/propertieswidget.h @@ -73,6 +73,8 @@ public: TrackerListWidget *getTrackerList() const; PeerListWidget *getPeerList() const; QTreeView *getFilesList() const; + PropTabBar *tabBar() const; + LineEdit *contentFilterLine() const; public slots: void setVisibility(bool visible);