Merge pull request #13724 from SuperSamus/gamelist-properties-noduplicates

GameList: Prevent opening Properties multiple times for the same game
This commit is contained in:
Admiral H. Curtiss
2025-06-07 17:24:50 +02:00
committed by GitHub
3 changed files with 14 additions and 1 deletions

View File

@ -25,7 +25,7 @@
#include "UICommon/GameFile.h" #include "UICommon/GameFile.h"
PropertiesDialog::PropertiesDialog(QWidget* parent, const UICommon::GameFile& game) PropertiesDialog::PropertiesDialog(QWidget* parent, const UICommon::GameFile& game)
: StackedSettingsWindow{parent} : StackedSettingsWindow{parent}, m_filepath(game.GetFilePath())
{ {
setWindowTitle(QStringLiteral("%1: %2 - %3") setWindowTitle(QStringLiteral("%1: %2 - %3")
.arg(QString::fromStdString(game.GetFileName()), .arg(QString::fromStdString(game.GetFileName()),

View File

@ -17,6 +17,7 @@ class PropertiesDialog final : public StackedSettingsWindow
Q_OBJECT Q_OBJECT
public: public:
explicit PropertiesDialog(QWidget* parent, const UICommon::GameFile& game); explicit PropertiesDialog(QWidget* parent, const UICommon::GameFile& game);
const std::string& GetFilePath() const { return m_filepath; }
signals: signals:
void OpenGeneralSettings(); void OpenGeneralSettings();
@ -24,4 +25,7 @@ signals:
#ifdef USE_RETRO_ACHIEVEMENTS #ifdef USE_RETRO_ACHIEVEMENTS
void OpenAchievementSettings(); void OpenAchievementSettings();
#endif // USE_RETRO_ACHIEVEMENTS #endif // USE_RETRO_ACHIEVEMENTS
private:
const std::string m_filepath;
}; };

View File

@ -566,6 +566,15 @@ void GameList::OpenProperties()
if (!game) if (!game)
return; return;
auto property_windows = this->findChildren<PropertiesDialog*>();
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); PropertiesDialog* properties = new PropertiesDialog(this, *game);
connect(properties, &PropertiesDialog::OpenGeneralSettings, this, &GameList::OpenGeneralSettings); connect(properties, &PropertiesDialog::OpenGeneralSettings, this, &GameList::OpenGeneralSettings);