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
commit 1b1ca019a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 1 deletions

View File

@ -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()),

View File

@ -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;
};

View File

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