From 6a0d8ca3f8a4a4c98d60473f34bd8e35d0ee9728 Mon Sep 17 00:00:00 2001 From: Dentomologist Date: Mon, 16 Jun 2025 21:06:55 -0700 Subject: [PATCH 1/3] MenuBar: Rename menu variable The Tools menu has a number of submenus, so rename menu to connect_wii_remotes_menu for clarity. --- Source/Core/DolphinQt/MenuBar.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Source/Core/DolphinQt/MenuBar.cpp b/Source/Core/DolphinQt/MenuBar.cpp index 2f3245fe62..7119af1d70 100644 --- a/Source/Core/DolphinQt/MenuBar.cpp +++ b/Source/Core/DolphinQt/MenuBar.cpp @@ -352,22 +352,22 @@ void MenuBar::AddToolsMenu() m_export_wii_saves = tools_menu->addAction(tr("Export All Wii Saves"), this, &MenuBar::ExportWiiSaves); - QMenu* menu = new QMenu(tr("Connect Wii Remotes"), tools_menu); + QMenu* connect_wii_remotes_menu = new QMenu(tr("Connect Wii Remotes"), tools_menu); tools_menu->addSeparator(); - tools_menu->addMenu(menu); + tools_menu->addMenu(connect_wii_remotes_menu); for (int i = 0; i < 4; i++) { - m_wii_remotes[i] = menu->addAction(tr("Connect Wii Remote %1").arg(i + 1), this, - [this, i] { emit ConnectWiiRemote(i); }); + m_wii_remotes[i] = connect_wii_remotes_menu->addAction( + tr("Connect Wii Remote %1").arg(i + 1), this, [this, i] { emit ConnectWiiRemote(i); }); m_wii_remotes[i]->setCheckable(true); } - menu->addSeparator(); + connect_wii_remotes_menu->addSeparator(); - m_wii_remotes[4] = - menu->addAction(tr("Connect Balance Board"), this, [this] { emit ConnectWiiRemote(4); }); + m_wii_remotes[4] = connect_wii_remotes_menu->addAction(tr("Connect Balance Board"), this, + [this] { emit ConnectWiiRemote(4); }); m_wii_remotes[4]->setCheckable(true); } From 2fd74990b7b10c12a5b338aa7d95e5cc8463ca7e Mon Sep 17 00:00:00 2001 From: Dentomologist Date: Mon, 16 Jun 2025 21:13:16 -0700 Subject: [PATCH 2/3] Qt: Use NonAutodismissibleMenu in more places Use NonAutodismissibleMenu for MenuBar's Options, JIT, and Tools->"Connect Wii Remotes" menus, as well as for the Tags menu in GameList's context menu. NonAutodismissibleMenu allows users to check or uncheck multiple checkable menu items without closing the menu between selections. --- Source/Core/DolphinQt/GameList/GameList.cpp | 4 +++- Source/Core/DolphinQt/MenuBar.cpp | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Source/Core/DolphinQt/GameList/GameList.cpp b/Source/Core/DolphinQt/GameList/GameList.cpp index b2392e2f2e..c09ca07f52 100644 --- a/Source/Core/DolphinQt/GameList/GameList.cpp +++ b/Source/Core/DolphinQt/GameList/GameList.cpp @@ -66,6 +66,7 @@ #include "DolphinQt/QtUtils/DolphinFileDialog.h" #include "DolphinQt/QtUtils/DoubleClickEventFilter.h" #include "DolphinQt/QtUtils/ModalMessageBox.h" +#include "DolphinQt/QtUtils/NonAutodismissibleMenu.h" #include "DolphinQt/QtUtils/ParallelProgressDialog.h" #include "DolphinQt/Resources.h" #include "DolphinQt/Settings.h" @@ -519,7 +520,8 @@ void GameList::ShowContextMenu(const QPoint&) menu->addSeparator(); - auto* tags_menu = menu->addMenu(tr("Tags")); + auto* const tags_menu{new QtUtils::NonAutodismissibleMenu(tr("Tags"), menu)}; + menu->addMenu(tags_menu); auto path = game->GetFilePath(); auto game_tags = m_model.GetGameTags(path); diff --git a/Source/Core/DolphinQt/MenuBar.cpp b/Source/Core/DolphinQt/MenuBar.cpp index 7119af1d70..ead86839cb 100644 --- a/Source/Core/DolphinQt/MenuBar.cpp +++ b/Source/Core/DolphinQt/MenuBar.cpp @@ -352,7 +352,8 @@ void MenuBar::AddToolsMenu() m_export_wii_saves = tools_menu->addAction(tr("Export All Wii Saves"), this, &MenuBar::ExportWiiSaves); - QMenu* connect_wii_remotes_menu = new QMenu(tr("Connect Wii Remotes"), tools_menu); + auto* const connect_wii_remotes_menu{ + new QtUtils::NonAutodismissibleMenu(tr("Connect Wii Remotes"), tools_menu)}; tools_menu->addSeparator(); tools_menu->addMenu(connect_wii_remotes_menu); @@ -601,7 +602,8 @@ void MenuBar::AddViewMenu() void MenuBar::AddOptionsMenu() { - QMenu* options_menu = addMenu(tr("&Options")); + auto* const options_menu{new QtUtils::NonAutodismissibleMenu(tr("&Options"), this)}; + addMenu(options_menu); #if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0) options_menu->addAction(tr("Co&nfiguration"), QKeySequence::Preferences, this, &MenuBar::Configure); @@ -892,7 +894,8 @@ void MenuBar::AddMovieMenu() void MenuBar::AddJITMenu() { - m_jit = addMenu(tr("JIT")); + m_jit = new QtUtils::NonAutodismissibleMenu(tr("JIT"), this); + addMenu(m_jit); m_jit_interpreter_core = m_jit->addAction(tr("Interpreter Core")); m_jit_interpreter_core->setCheckable(true); From c488545091bf0cdd57252af4c88fe49e22caf253 Mon Sep 17 00:00:00 2001 From: Dentomologist Date: Mon, 16 Jun 2025 22:11:09 -0700 Subject: [PATCH 3/3] GameListModel: Update tag list and sorting immediately Emit the dataChanged signal when adding or removing tags from a game. This both updates the contents of the game's Tags column immediately (instead of having to wait for the context menu to be closed), and updates the sorting if games are being sorted by the Tags column. --- Source/Core/DolphinQt/GameList/GameListModel.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Source/Core/DolphinQt/GameList/GameListModel.cpp b/Source/Core/DolphinQt/GameList/GameListModel.cpp index 42a911ce49..34b8c8570f 100644 --- a/Source/Core/DolphinQt/GameList/GameListModel.cpp +++ b/Source/Core/DolphinQt/GameList/GameListModel.cpp @@ -470,6 +470,13 @@ void GameListModel::AddGameTag(const std::string& path, const QString& name) m_game_tags[QString::fromStdString(path)] = tags; Settings::GetQSettings().setValue(QStringLiteral("gamelist/game_tags"), m_game_tags); + + const int row = FindGameIndex(path); + if (row >= 0) + { + const QModelIndex index = createIndex(row, static_cast(Column::Tags)); + emit dataChanged(index, index); + } } void GameListModel::RemoveGameTag(const std::string& path, const QString& name) @@ -481,6 +488,13 @@ void GameListModel::RemoveGameTag(const std::string& path, const QString& name) m_game_tags[QString::fromStdString(path)] = tags; Settings::GetQSettings().setValue(QStringLiteral("gamelist/game_tags"), m_game_tags); + + const int row = FindGameIndex(path); + if (row >= 0) + { + const QModelIndex index = createIndex(row, static_cast(Column::Tags)); + emit dataChanged(index, index); + } } void GameListModel::NewTag(const QString& name)