diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index c063bcf18..4ae6f1a17 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -478,8 +478,7 @@ void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &) menu->addSeparator(); } - QMenu *subMenu = new QMenu(menu); - subMenu->setTitle(tr("Priority")); + QMenu *subMenu = menu->addMenu(tr("Priority")); connect(m_ui->actionNotDownloaded, &QAction::triggered, subMenu, [applyPriorities]() { @@ -505,8 +504,6 @@ void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &) }); subMenu->addAction(m_ui->actionMaximum); - menu->addMenu(subMenu); - menu->popup(QCursor::pos()); } diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index f529629e0..d714daf75 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -528,21 +528,17 @@ void MainWindow::addToolbarContextMenu() m_ui->toolBar->setContextMenuPolicy(Qt::CustomContextMenu); 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); - QAction *textOnly = new QAction(tr("Text Only"), m_toolbarMenu); + QAction *textOnly = m_toolbarMenu->addAction(tr("Text Only")); 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); - 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); - 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); - 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); textPositionGroup->addAction(iconsOnly); iconsOnly->setCheckable(true); @@ -693,11 +689,9 @@ void MainWindow::showFilterContextMenu(const QPoint &) menu->setAttribute(Qt::WA_DeleteOnClose); menu->addSeparator(); - QAction *useRegexAct = new QAction(tr("Use regular expressions"), menu); + QAction *useRegexAct = menu->addAction(tr("Use regular expressions")); useRegexAct->setCheckable(true); useRegexAct->setChecked(pref->getRegexAsFilteringPatternForTransferList()); - menu->addAction(useRegexAct); - connect(useRegexAct, &QAction::toggled, pref, &Preferences::setRegexAsFilteringPatternForTransferList); connect(useRegexAct, &QAction::toggled, this, [this]() { m_transferListWidget->applyNameFilter(m_searchFilter->text()); }); diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index daedec77f..fe5e562f6 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -600,10 +600,8 @@ void PropertiesWidget::displayFilesListMenu(const QPoint &) menu->addSeparator(); } - QMenu *subMenu = new QMenu(menu); - if (!m_torrent->isSeed()) { - subMenu->setTitle(tr("Priority")); + QMenu *subMenu = menu->addMenu(tr("Priority")); const auto applyPriorities = [this, selectedRows](const BitTorrent::DownloadPriority prio) { @@ -639,8 +637,6 @@ void PropertiesWidget::displayFilesListMenu(const QPoint &) applyPriorities(BitTorrent::DownloadPriority::Maximum); }); subMenu->addAction(m_ui->actionMaximum); - - menu->addMenu(subMenu); } // The selected torrent might have disappeared during exec() diff --git a/src/gui/search/searchjobwidget.cpp b/src/gui/search/searchjobwidget.cpp index 6dbc80ce6..18c94de05 100644 --- a/src/gui/search/searchjobwidget.cpp +++ b/src/gui/search/searchjobwidget.cpp @@ -361,11 +361,9 @@ void SearchJobWidget::showFilterContextMenu(const QPoint &) menu->setAttribute(Qt::WA_DeleteOnClose); menu->addSeparator(); - QAction *useRegexAct = new QAction(tr("Use regular expressions"), menu); + QAction *useRegexAct = menu->addAction(tr("Use regular expressions")); useRegexAct->setCheckable(true); useRegexAct->setChecked(pref->getRegexAsFilteringPatternForSearchJob()); - menu->addAction(useRegexAct); - connect(useRegexAct, &QAction::toggled, pref, &Preferences::setRegexAsFilteringPatternForSearchJob); connect(useRegexAct, &QAction::toggled, this, [this]() { filterSearchResults(m_lineEditSearchResultsFilter->text()); });