From 2de9122b5f19e8f0c25762e431a7254999a07177 Mon Sep 17 00:00:00 2001 From: Martino Fontana Date: Mon, 2 Jun 2025 14:00:06 +0200 Subject: [PATCH] GameList: Prevent opening Properties multiple times for the same game --- Source/Core/DolphinQt/Config/PropertiesDialog.cpp | 2 +- Source/Core/DolphinQt/Config/PropertiesDialog.h | 4 ++++ Source/Core/DolphinQt/GameList/GameList.cpp | 9 +++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Source/Core/DolphinQt/Config/PropertiesDialog.cpp b/Source/Core/DolphinQt/Config/PropertiesDialog.cpp index f95edf40c6..7957380bbe 100644 --- a/Source/Core/DolphinQt/Config/PropertiesDialog.cpp +++ b/Source/Core/DolphinQt/Config/PropertiesDialog.cpp @@ -25,7 +25,7 @@ #include "UICommon/GameFile.h" PropertiesDialog::PropertiesDialog(QWidget* parent, const UICommon::GameFile& game) - : StackedSettingsWindow{parent} + : StackedSettingsWindow{parent}, m_filepath(game.GetFilePath()) { setWindowTitle(QStringLiteral("%1: %2 - %3") .arg(QString::fromStdString(game.GetFileName()), diff --git a/Source/Core/DolphinQt/Config/PropertiesDialog.h b/Source/Core/DolphinQt/Config/PropertiesDialog.h index 9079ed925a..3d8236bbe4 100644 --- a/Source/Core/DolphinQt/Config/PropertiesDialog.h +++ b/Source/Core/DolphinQt/Config/PropertiesDialog.h @@ -17,6 +17,7 @@ class PropertiesDialog final : public StackedSettingsWindow Q_OBJECT public: explicit PropertiesDialog(QWidget* parent, const UICommon::GameFile& game); + const std::string& GetFilePath() const { return m_filepath; } signals: void OpenGeneralSettings(); @@ -24,4 +25,7 @@ signals: #ifdef USE_RETRO_ACHIEVEMENTS void OpenAchievementSettings(); #endif // USE_RETRO_ACHIEVEMENTS + +private: + const std::string m_filepath; }; diff --git a/Source/Core/DolphinQt/GameList/GameList.cpp b/Source/Core/DolphinQt/GameList/GameList.cpp index 81805c219d..7ec2f1f263 100644 --- a/Source/Core/DolphinQt/GameList/GameList.cpp +++ b/Source/Core/DolphinQt/GameList/GameList.cpp @@ -566,6 +566,15 @@ void GameList::OpenProperties() if (!game) return; + auto property_windows = this->findChildren(); + auto it = + std::ranges::find(property_windows, game->GetFilePath(), &PropertiesDialog::GetFilePath); + if (it != property_windows.end()) + { + (*it)->raise(); + return; + } + PropertiesDialog* properties = new PropertiesDialog(this, *game); connect(properties, &PropertiesDialog::OpenGeneralSettings, this, &GameList::OpenGeneralSettings);