Enable Ctrl+F hotkey for more inputs

PR #20131.
This commit is contained in:
thalieht 2023-12-19 19:52:47 +02:00 committed by GitHub
parent 4057972b2d
commit 8dcc734df5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 6 deletions

View file

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

View file

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

View file

@ -125,7 +125,7 @@ private slots:
void displaySearchTab();
void displayRSSTab();
void displayExecutionLogTab();
void focusSearchFilter();
void toggleFocusBetweenLineEdits();
void reloadSessionStats();
void reloadTorrentStats(const QVector<BitTorrent::Torrent *> &torrents);
void loadPreferences();

View file

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

View file

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