Qt: Fix directory setting changes

This commit is contained in:
Connor McLaughlin
2022-07-23 01:28:19 +10:00
parent 78bddd7fe9
commit a5f5be1a60
9 changed files with 45 additions and 16 deletions

View File

@ -66,8 +66,5 @@ void SetGameSettingsLayer(SettingsInterface* sif);
/// Sets the input profile settings layer. Called by VMManager when the game changes.
void SetInputSettingsLayer(SettingsInterface* sif);
/// Updates the variables in the EmuFolders namespace, reloading subsystems if needed. Must call with the lock held.
void UpdateEmuFolders();
} // namespace Internal
} // namespace Host

View File

@ -9,6 +9,8 @@
#include "controller.h"
#include "host.h"
#include "host_display.h"
#include "host_settings.h"
#include "system.h"
#include <algorithm>
#include <array>
#include <cctype>
@ -1230,6 +1232,26 @@ void EmuFolders::Save(SettingsInterface& si)
si.SetStringValue("Folders", "Textures", Path::MakeRelative(Textures, DataRoot).c_str());
}
void EmuFolders::Update()
{
const std::string old_gamesettings(EmuFolders::GameSettings);
const std::string old_inputprofiles(EmuFolders::InputProfiles);
const std::string old_memorycards(EmuFolders::MemoryCards);
// have to manually grab the lock here, because of the ReloadGameSettings() below.
{
auto lock = Host::GetSettingsLock();
LoadConfig(*Host::Internal::GetBaseSettingsLayer());
EnsureFoldersExist();
}
if (old_gamesettings != EmuFolders::GameSettings || old_inputprofiles != EmuFolders::InputProfiles)
System::ReloadGameSettings(false);
if (System::IsValid() && old_memorycards != EmuFolders::MemoryCards)
System::UpdateMemoryCardTypes();
}
bool EmuFolders::EnsureFoldersExist()
{
bool result = FileSystem::EnsureDirectoryExists(Bios.c_str(), false);

View File

@ -445,4 +445,7 @@ void SetDefaults();
bool EnsureFoldersExist();
void LoadConfig(SettingsInterface& si);
void Save(SettingsInterface& si);
/// Updates the variables in the EmuFolders namespace, reloading subsystems if needed.
void Update();
} // namespace EmuFolders