Skip to content

Commit e4d9bed

Browse files
authored
Qt: Get rid of the last few QMenu::exec() (#3628)
Completes c025da4
1 parent 483f9ba commit e4d9bed

File tree

6 files changed

+16
-22
lines changed

6 files changed

+16
-22
lines changed

src/duckstation-qt/gamecheatsettingswidget.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ void GameCheatSettingsWidget::onCheatListContextMenuRequested(const QPoint& pos)
344344
Cheats::CodeInfo* selected = getSelectedCode();
345345
const std::string selected_code = selected ? selected->name : std::string();
346346

347-
QMenu* context_menu = QtUtils::NewPopupMenu(m_ui.cheatList);
347+
QMenu* const context_menu = QtUtils::NewPopupMenu(m_ui.cheatList);
348348

349349
context_menu->addAction(QIcon::fromTheme(QStringLiteral("add-line")), tr("Add Cheat..."), this,
350350
&GameCheatSettingsWidget::newCode);
@@ -364,7 +364,7 @@ void GameCheatSettingsWidget::onCheatListContextMenuRequested(const QPoint& pos)
364364
context_menu->addAction(QIcon::fromTheme(QStringLiteral("refresh-line")), tr("Reload Cheats"), this,
365365
&GameCheatSettingsWidget::onReloadClicked);
366366

367-
context_menu->exec(m_ui.cheatList->mapToGlobal(pos));
367+
context_menu->popup(m_ui.cheatList->mapToGlobal(pos));
368368
}
369369

370370
void GameCheatSettingsWidget::onRemoveCodeClicked()
@@ -559,7 +559,7 @@ void GameCheatSettingsWidget::onImportClicked()
559559
QMenu* const menu = QtUtils::NewPopupMenu(this);
560560
menu->addAction(tr("From File..."), this, &GameCheatSettingsWidget::onImportFromFileTriggered);
561561
menu->addAction(tr("From Text..."), this, &GameCheatSettingsWidget::onImportFromTextTriggered);
562-
menu->exec(QCursor::pos());
562+
menu->popup(QCursor::pos());
563563
}
564564

565565
void GameCheatSettingsWidget::onImportFromFileTriggered()

src/duckstation-qt/gamelistwidget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2485,7 +2485,7 @@ void GameListListView::setAndSaveColumnHidden(int column, bool hidden)
24852485

24862486
void GameListListView::onHeaderContextMenuRequested(const QPoint& point)
24872487
{
2488-
QMenu* menu = QtUtils::NewPopupMenu(this);
2488+
QMenu* const menu = QtUtils::NewPopupMenu(this);
24892489

24902490
for (int column = 0; column < GameListModel::Column_Count; column++)
24912491
{
@@ -2498,7 +2498,7 @@ void GameListListView::onHeaderContextMenuRequested(const QPoint& point)
24982498
action->setChecked(!isColumnHidden(column));
24992499
}
25002500

2501-
menu->exec(mapToGlobal(point));
2501+
menu->popup(mapToGlobal(point));
25022502
}
25032503

25042504
void GameListListView::adjustIconSize(int delta)

src/duckstation-qt/mainwindow.cpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,11 +1089,6 @@ void MainWindow::populateSaveStateMenu(std::string_view game_serial, QMenu* menu
10891089
add_slot(tr("Global Save %1 (%2)"), tr("Global Save %1 (Empty)"), empty_serial, static_cast<s32>(slot));
10901090
}
10911091

1092-
void MainWindow::onCheatsActionTriggered()
1093-
{
1094-
m_ui.menuCheats->exec(QCursor::pos());
1095-
}
1096-
10971092
void MainWindow::onCheatsMenuAboutToShow()
10981093
{
10991094
m_ui.menuCheats->clear();
@@ -1121,7 +1116,7 @@ void MainWindow::onCheatsMenuAboutToShow()
11211116
return;
11221117
}
11231118

1124-
QMenu* apply_submenu = menu->addMenu(tr("&Apply Cheat"));
1119+
QMenu* const apply_submenu = menu->addMenu(tr("&Apply Cheat"));
11251120
QtUtils::StylePopupMenu(apply_submenu);
11261121
for (const QString& name : names)
11271122
{
@@ -1776,7 +1771,7 @@ void MainWindow::onGameListEntryContextMenuRequested(const QPoint& point)
17761771
menu->addAction(tr("Add Search Directory..."),
17771772
[this]() { getSettingsWindow()->getGameListSettingsWidget()->addSearchDirectory(this); });
17781773

1779-
menu->exec(point);
1774+
menu->popup(point);
17801775
}
17811776

17821777
void MainWindow::setGameListEntryCoverImage(const GameList::Entry* entry)
@@ -2142,7 +2137,7 @@ void MainWindow::onToolbarContextMenuRequested(const QPoint& pos)
21422137
action->setEnabled(show_labels);
21432138
connect(action, &QAction::toggled, this, &MainWindow::onViewToolbarLabelsBesideIconsActionToggled);
21442139

2145-
QMenu* position_menu = menu->addMenu(tr("Position"));
2140+
QMenu* const position_menu = menu->addMenu(tr("Position"));
21462141
QtUtils::StylePopupMenu(position_menu);
21472142
for (const auto& [area, name] : s_toolbar_areas)
21482143
{
@@ -2165,7 +2160,7 @@ void MainWindow::onToolbarContextMenuRequested(const QPoint& pos)
21652160
continue;
21662161
}
21672162

2168-
QAction* menu_action = menu->addAction((m_ui.*action_ptr)->text());
2163+
QAction* const menu_action = menu->addAction((m_ui.*action_ptr)->text());
21692164
menu_action->setCheckable(true);
21702165
menu_action->setChecked(StringUtil::IsInStringList(active_buttons, name));
21712166
connect(menu_action, &QAction::toggled, this, [this, name](bool checked) {
@@ -2480,7 +2475,7 @@ void MainWindow::connectSignals()
24802475
connect(m_ui.actionStartDiscToolbar, &QAction::triggered, this, &MainWindow::onStartDiscActionTriggered);
24812476
connect(m_ui.actionStartBios, &QAction::triggered, this, &MainWindow::onStartBIOSActionTriggered);
24822477
connect(m_ui.actionResumeLastState, &QAction::triggered, g_emu_thread, &EmuThread::resumeSystemFromMostRecentState);
2483-
connect(m_ui.actionChangeDisc, &QAction::triggered, [this] { m_ui.menuChangeDisc->exec(QCursor::pos()); });
2478+
connect(m_ui.actionChangeDisc, &QAction::triggered, [this] { m_ui.menuChangeDisc->popup(QCursor::pos()); });
24842479
connect(m_ui.actionChangeDiscFromFile, &QAction::triggered, this, &MainWindow::onChangeDiscFromFileActionTriggered);
24852480
connect(m_ui.actionChangeDiscFromDevice, &QAction::triggered, this,
24862481
&MainWindow::onChangeDiscFromDeviceActionTriggered);
@@ -2490,7 +2485,7 @@ void MainWindow::connectSignals()
24902485
connect(m_ui.menuLoadState, &QMenu::aboutToShow, this, &MainWindow::onLoadStateMenuAboutToShow);
24912486
connect(m_ui.menuSaveState, &QMenu::aboutToShow, this, &MainWindow::onSaveStateMenuAboutToShow);
24922487
connect(m_ui.menuCheats, &QMenu::aboutToShow, this, &MainWindow::onCheatsMenuAboutToShow);
2493-
connect(m_ui.actionCheatsToolbar, &QAction::triggered, this, &MainWindow::onCheatsActionTriggered);
2488+
connect(m_ui.actionCheatsToolbar, &QAction::triggered, [this] { m_ui.menuCheats->popup(QCursor::pos()); });
24942489
connect(m_ui.actionStartFullscreenUI, &QAction::triggered, this, &MainWindow::onStartFullscreenUITriggered);
24952490
connect(m_ui.actionStartFullscreenUI2, &QAction::triggered, this, &MainWindow::onStartFullscreenUITriggered);
24962491
connect(m_ui.actionRemoveDisc, &QAction::triggered, this, &MainWindow::onRemoveDiscActionTriggered);
@@ -2508,8 +2503,8 @@ void MainWindow::connectSignals()
25082503
connect(m_ui.actionScreenshot, &QAction::triggered, g_emu_thread, &EmuThread::saveScreenshot);
25092504
connect(m_ui.actionScanForNewGames, &QAction::triggered, this, &MainWindow::onScanForNewGamesTriggered);
25102505
connect(m_ui.actionRescanAllGames, &QAction::triggered, this, [this]() { refreshGameList(true); });
2511-
connect(m_ui.actionLoadState, &QAction::triggered, this, [this]() { m_ui.menuLoadState->exec(QCursor::pos()); });
2512-
connect(m_ui.actionSaveState, &QAction::triggered, this, [this]() { m_ui.menuSaveState->exec(QCursor::pos()); });
2506+
connect(m_ui.actionLoadState, &QAction::triggered, this, [this]() { m_ui.menuLoadState->popup(QCursor::pos()); });
2507+
connect(m_ui.actionSaveState, &QAction::triggered, this, [this]() { m_ui.menuSaveState->popup(QCursor::pos()); });
25132508
connect(m_ui.actionExit, &QAction::triggered, this, &MainWindow::close);
25142509
connect(m_ui.actionFullscreen, &QAction::triggered, g_emu_thread, &EmuThread::toggleFullscreen);
25152510
connect(m_ui.actionSettings, &QAction::triggered, [this]() { doSettings(); });
@@ -2886,7 +2881,7 @@ void MainWindow::onViewClearGameListBackgroundTriggered()
28862881
void MainWindow::onSettingsTriggeredFromToolbar()
28872882
{
28882883
if (s_system_valid)
2889-
m_settings_toolbar_menu->exec(QCursor::pos());
2884+
m_settings_toolbar_menu->popup(QCursor::pos());
28902885
else
28912886
doSettings();
28922887
}

src/duckstation-qt/mainwindow.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ class MainWindow final : public QMainWindow
269269
void onChangeDiscMenuAboutToShow();
270270
void onLoadStateMenuAboutToShow();
271271
void onSaveStateMenuAboutToShow();
272-
void onCheatsActionTriggered();
273272
void onCheatsMenuAboutToShow();
274273
void onStartFullscreenUITriggered();
275274
void onCloseGameActionTriggered();

src/duckstation-qt/memorycardeditorwindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ void MemoryCardEditorWindow::onCardContextMenuRequested(const QPoint& pos)
850850
action = menu->addAction(tr("Copy File"), this, &MemoryCardEditorWindow::doCopyFile);
851851
action->setEnabled(fi && !m_card_a.filename.empty() && !m_card_b.filename.empty());
852852

853-
menu->exec(table->mapToGlobal(pos));
853+
menu->popup(table->mapToGlobal(pos));
854854
}
855855

856856
std::tuple<MemoryCardEditorWindow::Card*, const MemoryCardImage::FileInfo*> MemoryCardEditorWindow::getSelectedFile()

src/duckstation-qt/settingwidgetbinder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ struct SettingAccessor<QSpinBox>
525525
updateFont(widget, true);
526526
func();
527527
});
528-
menu->exec(widget->mapToGlobal(pt));
528+
menu->popup(widget->mapToGlobal(pt));
529529
});
530530
widget->connect(widget, &QSpinBox::valueChanged, widget, [widget, func = std::move(func)]() {
531531
if (widget->property(IS_NULL_PROPERTY).toBool())

0 commit comments

Comments
 (0)