mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-13 08:43:08 -07:00
Add option for regexps in the transferlist search filter's context menu
This commit is contained in:
parent
305d73180b
commit
052206efa1
5 changed files with 36 additions and 2 deletions
|
@ -232,9 +232,11 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
|
||||
// Name filter
|
||||
m_searchFilter = new LineEdit(this);
|
||||
m_searchFilterAction = m_ui->toolBar->insertWidget(m_ui->actionLock, m_searchFilter);
|
||||
m_searchFilter->setPlaceholderText(tr("Filter torrent list..."));
|
||||
m_searchFilter->setFixedWidth(Utils::Gui::scaledSize(this, 200));
|
||||
m_searchFilter->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(m_searchFilter, &QWidget::customContextMenuRequested, this, &MainWindow::showFilterContextMenu);
|
||||
m_searchFilterAction = m_ui->toolBar->insertWidget(m_ui->actionLock, m_searchFilter);
|
||||
|
||||
QWidget *spacer = new QWidget(this);
|
||||
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
|
@ -700,6 +702,23 @@ void MainWindow::displayRSSTab(bool enable)
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::showFilterContextMenu(const QPoint &)
|
||||
{
|
||||
const Preferences *pref = Preferences::instance();
|
||||
|
||||
QMenu *menu = m_searchFilter->createStandardContextMenu();
|
||||
menu->addSeparator();
|
||||
QAction *useRegexAct = new QAction(tr("Use regular expressions"), menu);
|
||||
useRegexAct->setCheckable(true);
|
||||
useRegexAct->setChecked(pref->getRegexAsFilteringPattern());
|
||||
menu->addAction(useRegexAct);
|
||||
|
||||
connect(useRegexAct, &QAction::toggled, pref, &Preferences::setRegexAsFilteringPattern);
|
||||
connect(useRegexAct, &QAction::toggled, this, [this]() { m_transferListWidget->applyNameFilter(m_searchFilter->text()); });
|
||||
|
||||
menu->exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void MainWindow::displaySearchTab(bool enable)
|
||||
{
|
||||
Preferences::instance()->setSearchEnabled(enable);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue