Qt: Fix activation of existing game properties windows

This commit is contained in:
Stenzek 2023-12-28 15:50:01 +10:00
parent 6d3e3f78da
commit b75528272e
No known key found for this signature in database
2 changed files with 14 additions and 13 deletions

View file

@ -477,17 +477,6 @@ void SettingsWindow::removeSettingValue(const char* section, const char* key)
void SettingsWindow::openGamePropertiesDialog(const std::string& path, const std::string& serial, DiscRegion region) void SettingsWindow::openGamePropertiesDialog(const std::string& path, const std::string& serial, DiscRegion region)
{ {
// check for an existing dialog with this crc
for (SettingsWindow* dialog : s_open_game_properties_dialogs)
{
if (dialog->m_game_serial == serial)
{
dialog->show();
dialog->setFocus();
return;
}
}
const GameDatabase::Entry* dentry = nullptr; const GameDatabase::Entry* dentry = nullptr;
if (!System::IsExeFileName(path) && !System::IsPsfFileName(path)) if (!System::IsExeFileName(path) && !System::IsPsfFileName(path))
{ {
@ -508,6 +497,20 @@ void SettingsWindow::openGamePropertiesDialog(const std::string& path, const std
const std::string& real_serial = dentry ? dentry->serial : serial; const std::string& real_serial = dentry ? dentry->serial : serial;
std::string ini_filename = System::GetGameSettingsPath(real_serial); std::string ini_filename = System::GetGameSettingsPath(real_serial);
// check for an existing dialog with this crc
for (SettingsWindow* dialog : s_open_game_properties_dialogs)
{
if (dialog->isPerGameSettings() && static_cast<INISettingsInterface*>(dialog->getSettingsInterface())->GetFileName() == ini_filename)
{
dialog->show();
dialog->raise();
dialog->activateWindow();
dialog->setFocus();
return;
}
}
std::unique_ptr<INISettingsInterface> sif = std::make_unique<INISettingsInterface>(std::move(ini_filename)); std::unique_ptr<INISettingsInterface> sif = std::make_unique<INISettingsInterface>(std::move(ini_filename));
if (FileSystem::FileExists(sif->GetFileName().c_str())) if (FileSystem::FileExists(sif->GetFileName().c_str()))
sif->Load(); sif->Load();

View file

@ -126,6 +126,4 @@ private:
QObject* m_current_help_widget = nullptr; QObject* m_current_help_widget = nullptr;
QMap<QObject*, QString> m_widget_help_text_map; QMap<QObject*, QString> m_widget_help_text_map;
std::string m_game_serial;
}; };