mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 20:44:15 +00:00
Avoid allocating a new menu/action manually
This commit is contained in:
parent
04e7b3f6d2
commit
412e326cf2
@ -478,8 +478,7 @@ void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &)
|
|||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
}
|
}
|
||||||
|
|
||||||
QMenu *subMenu = new QMenu(menu);
|
QMenu *subMenu = menu->addMenu(tr("Priority"));
|
||||||
subMenu->setTitle(tr("Priority"));
|
|
||||||
|
|
||||||
connect(m_ui->actionNotDownloaded, &QAction::triggered, subMenu, [applyPriorities]()
|
connect(m_ui->actionNotDownloaded, &QAction::triggered, subMenu, [applyPriorities]()
|
||||||
{
|
{
|
||||||
@ -505,8 +504,6 @@ void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &)
|
|||||||
});
|
});
|
||||||
subMenu->addAction(m_ui->actionMaximum);
|
subMenu->addAction(m_ui->actionMaximum);
|
||||||
|
|
||||||
menu->addMenu(subMenu);
|
|
||||||
|
|
||||||
menu->popup(QCursor::pos());
|
menu->popup(QCursor::pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -528,21 +528,17 @@ void MainWindow::addToolbarContextMenu()
|
|||||||
m_ui->toolBar->setContextMenuPolicy(Qt::CustomContextMenu);
|
m_ui->toolBar->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
connect(m_ui->toolBar, &QWidget::customContextMenuRequested, this, &MainWindow::toolbarMenuRequested);
|
connect(m_ui->toolBar, &QWidget::customContextMenuRequested, this, &MainWindow::toolbarMenuRequested);
|
||||||
|
|
||||||
QAction *iconsOnly = new QAction(tr("Icons Only"), m_toolbarMenu);
|
QAction *iconsOnly = m_toolbarMenu->addAction(tr("Icons Only"));
|
||||||
connect(iconsOnly, &QAction::triggered, this, &MainWindow::toolbarIconsOnly);
|
connect(iconsOnly, &QAction::triggered, this, &MainWindow::toolbarIconsOnly);
|
||||||
QAction *textOnly = new QAction(tr("Text Only"), m_toolbarMenu);
|
QAction *textOnly = m_toolbarMenu->addAction(tr("Text Only"));
|
||||||
connect(textOnly, &QAction::triggered, this, &MainWindow::toolbarTextOnly);
|
connect(textOnly, &QAction::triggered, this, &MainWindow::toolbarTextOnly);
|
||||||
QAction *textBesideIcons = new QAction(tr("Text Alongside Icons"), m_toolbarMenu);
|
QAction *textBesideIcons = m_toolbarMenu->addAction(tr("Text Alongside Icons"));
|
||||||
connect(textBesideIcons, &QAction::triggered, this, &MainWindow::toolbarTextBeside);
|
connect(textBesideIcons, &QAction::triggered, this, &MainWindow::toolbarTextBeside);
|
||||||
QAction *textUnderIcons = new QAction(tr("Text Under Icons"), m_toolbarMenu);
|
QAction *textUnderIcons = m_toolbarMenu->addAction(tr("Text Under Icons"));
|
||||||
connect(textUnderIcons, &QAction::triggered, this, &MainWindow::toolbarTextUnder);
|
connect(textUnderIcons, &QAction::triggered, this, &MainWindow::toolbarTextUnder);
|
||||||
QAction *followSystemStyle = new QAction(tr("Follow System Style"), m_toolbarMenu);
|
QAction *followSystemStyle = m_toolbarMenu->addAction(tr("Follow System Style"));
|
||||||
connect(followSystemStyle, &QAction::triggered, this, &MainWindow::toolbarFollowSystem);
|
connect(followSystemStyle, &QAction::triggered, this, &MainWindow::toolbarFollowSystem);
|
||||||
m_toolbarMenu->addAction(iconsOnly);
|
|
||||||
m_toolbarMenu->addAction(textOnly);
|
|
||||||
m_toolbarMenu->addAction(textBesideIcons);
|
|
||||||
m_toolbarMenu->addAction(textUnderIcons);
|
|
||||||
m_toolbarMenu->addAction(followSystemStyle);
|
|
||||||
auto *textPositionGroup = new QActionGroup(m_toolbarMenu);
|
auto *textPositionGroup = new QActionGroup(m_toolbarMenu);
|
||||||
textPositionGroup->addAction(iconsOnly);
|
textPositionGroup->addAction(iconsOnly);
|
||||||
iconsOnly->setCheckable(true);
|
iconsOnly->setCheckable(true);
|
||||||
@ -693,11 +689,9 @@ void MainWindow::showFilterContextMenu(const QPoint &)
|
|||||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
|
|
||||||
QAction *useRegexAct = new QAction(tr("Use regular expressions"), menu);
|
QAction *useRegexAct = menu->addAction(tr("Use regular expressions"));
|
||||||
useRegexAct->setCheckable(true);
|
useRegexAct->setCheckable(true);
|
||||||
useRegexAct->setChecked(pref->getRegexAsFilteringPatternForTransferList());
|
useRegexAct->setChecked(pref->getRegexAsFilteringPatternForTransferList());
|
||||||
menu->addAction(useRegexAct);
|
|
||||||
|
|
||||||
connect(useRegexAct, &QAction::toggled, pref, &Preferences::setRegexAsFilteringPatternForTransferList);
|
connect(useRegexAct, &QAction::toggled, pref, &Preferences::setRegexAsFilteringPatternForTransferList);
|
||||||
connect(useRegexAct, &QAction::toggled, this, [this]() { m_transferListWidget->applyNameFilter(m_searchFilter->text()); });
|
connect(useRegexAct, &QAction::toggled, this, [this]() { m_transferListWidget->applyNameFilter(m_searchFilter->text()); });
|
||||||
|
|
||||||
|
@ -600,10 +600,8 @@ void PropertiesWidget::displayFilesListMenu(const QPoint &)
|
|||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
}
|
}
|
||||||
|
|
||||||
QMenu *subMenu = new QMenu(menu);
|
|
||||||
|
|
||||||
if (!m_torrent->isSeed()) {
|
if (!m_torrent->isSeed()) {
|
||||||
subMenu->setTitle(tr("Priority"));
|
QMenu *subMenu = menu->addMenu(tr("Priority"));
|
||||||
|
|
||||||
const auto applyPriorities = [this, selectedRows](const BitTorrent::DownloadPriority prio)
|
const auto applyPriorities = [this, selectedRows](const BitTorrent::DownloadPriority prio)
|
||||||
{
|
{
|
||||||
@ -639,8 +637,6 @@ void PropertiesWidget::displayFilesListMenu(const QPoint &)
|
|||||||
applyPriorities(BitTorrent::DownloadPriority::Maximum);
|
applyPriorities(BitTorrent::DownloadPriority::Maximum);
|
||||||
});
|
});
|
||||||
subMenu->addAction(m_ui->actionMaximum);
|
subMenu->addAction(m_ui->actionMaximum);
|
||||||
|
|
||||||
menu->addMenu(subMenu);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The selected torrent might have disappeared during exec()
|
// The selected torrent might have disappeared during exec()
|
||||||
|
@ -361,11 +361,9 @@ void SearchJobWidget::showFilterContextMenu(const QPoint &)
|
|||||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
|
|
||||||
QAction *useRegexAct = new QAction(tr("Use regular expressions"), menu);
|
QAction *useRegexAct = menu->addAction(tr("Use regular expressions"));
|
||||||
useRegexAct->setCheckable(true);
|
useRegexAct->setCheckable(true);
|
||||||
useRegexAct->setChecked(pref->getRegexAsFilteringPatternForSearchJob());
|
useRegexAct->setChecked(pref->getRegexAsFilteringPatternForSearchJob());
|
||||||
menu->addAction(useRegexAct);
|
|
||||||
|
|
||||||
connect(useRegexAct, &QAction::toggled, pref, &Preferences::setRegexAsFilteringPatternForSearchJob);
|
connect(useRegexAct, &QAction::toggled, pref, &Preferences::setRegexAsFilteringPatternForSearchJob);
|
||||||
connect(useRegexAct, &QAction::toggled, this, [this]() { filterSearchResults(m_lineEditSearchResultsFilter->text()); });
|
connect(useRegexAct, &QAction::toggled, this, [this]() { filterSearchResults(m_lineEditSearchResultsFilter->text()); });
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user