Skip to content

Commit

Permalink
Enable Ctrl+F hotkey for more inputs
Browse files Browse the repository at this point in the history
PR #20131.
  • Loading branch information
thalieht authored Dec 19, 2023
1 parent 4057972 commit 8dcc734
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/gui/addnewtorrentdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
19 changes: 14 additions & 5 deletions src/gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 10 additions & 0 deletions src/gui/properties/propertieswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/gui/properties/propertieswidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class PropertiesWidget : public QWidget
TrackerListWidget *getTrackerList() const;
PeerListWidget *getPeerList() const;
QTreeView *getFilesList() const;
PropTabBar *tabBar() const;
LineEdit *contentFilterLine() const;

public slots:
void setVisibility(bool visible);
Expand Down

0 comments on commit 8dcc734

Please sign in to comment.