mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-18 06:25:37 +00:00
Qt: Fix directory setting changes
This commit is contained in:
parent
78bddd7fe9
commit
a5f5be1a60
|
@ -66,8 +66,5 @@ void SetGameSettingsLayer(SettingsInterface* sif);
|
||||||
|
|
||||||
/// Sets the input profile settings layer. Called by VMManager when the game changes.
|
/// Sets the input profile settings layer. Called by VMManager when the game changes.
|
||||||
void SetInputSettingsLayer(SettingsInterface* sif);
|
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 Internal
|
||||||
} // namespace Host
|
} // namespace Host
|
|
@ -9,6 +9,8 @@
|
||||||
#include "controller.h"
|
#include "controller.h"
|
||||||
#include "host.h"
|
#include "host.h"
|
||||||
#include "host_display.h"
|
#include "host_display.h"
|
||||||
|
#include "host_settings.h"
|
||||||
|
#include "system.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
@ -1230,6 +1232,26 @@ void EmuFolders::Save(SettingsInterface& si)
|
||||||
si.SetStringValue("Folders", "Textures", Path::MakeRelative(Textures, DataRoot).c_str());
|
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 EmuFolders::EnsureFoldersExist()
|
||||||
{
|
{
|
||||||
bool result = FileSystem::EnsureDirectoryExists(Bios.c_str(), false);
|
bool result = FileSystem::EnsureDirectoryExists(Bios.c_str(), false);
|
||||||
|
|
|
@ -445,4 +445,7 @@ void SetDefaults();
|
||||||
bool EnsureFoldersExist();
|
bool EnsureFoldersExist();
|
||||||
void LoadConfig(SettingsInterface& si);
|
void LoadConfig(SettingsInterface& si);
|
||||||
void Save(SettingsInterface& si);
|
void Save(SettingsInterface& si);
|
||||||
|
|
||||||
|
/// Updates the variables in the EmuFolders namespace, reloading subsystems if needed.
|
||||||
|
void Update();
|
||||||
} // namespace EmuFolders
|
} // namespace EmuFolders
|
||||||
|
|
|
@ -12,13 +12,15 @@ FolderSettingsWidget::FolderSettingsWidget(SettingsDialog* dialog, QWidget* pare
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
|
|
||||||
SettingWidgetBinder::BindWidgetToFolderSetting(sif, m_ui.cache, m_ui.cacheBrowse, m_ui.cacheOpen, m_ui.cacheReset,
|
SettingWidgetBinder::BindWidgetToFolderSetting(sif, m_ui.cache, m_ui.cacheBrowse, m_ui.cacheOpen, m_ui.cacheReset,
|
||||||
"Folders", "Cache", "cache");
|
"Folders", "Cache", Path::Combine(EmuFolders::DataRoot, "cache"));
|
||||||
SettingWidgetBinder::BindWidgetToFolderSetting(sif, m_ui.covers, m_ui.coversBrowse, m_ui.coversOpen, m_ui.coversReset,
|
SettingWidgetBinder::BindWidgetToFolderSetting(sif, m_ui.covers, m_ui.coversBrowse, m_ui.coversOpen, m_ui.coversReset,
|
||||||
"Folders", "Covers", "covers");
|
"Folders", "Covers", Path::Combine(EmuFolders::DataRoot, "covers"));
|
||||||
SettingWidgetBinder::BindWidgetToFolderSetting(sif, m_ui.screenshots, m_ui.screenshotsBrowse, m_ui.screenshotsOpen,
|
SettingWidgetBinder::BindWidgetToFolderSetting(sif, m_ui.screenshots, m_ui.screenshotsBrowse, m_ui.screenshotsOpen,
|
||||||
m_ui.screenshotsReset, "Folders", "Screenshots", "screenshots");
|
m_ui.screenshotsReset, "Folders", "Screenshots",
|
||||||
|
Path::Combine(EmuFolders::DataRoot, "screenshots"));
|
||||||
SettingWidgetBinder::BindWidgetToFolderSetting(sif, m_ui.saveStates, m_ui.saveStatesBrowse, m_ui.saveStatesOpen,
|
SettingWidgetBinder::BindWidgetToFolderSetting(sif, m_ui.saveStates, m_ui.saveStatesBrowse, m_ui.saveStatesOpen,
|
||||||
m_ui.saveStatesReset, "Folders", "SaveStates", "savestates");
|
m_ui.saveStatesReset, "Folders", "SaveStates",
|
||||||
|
Path::Combine(EmuFolders::DataRoot, "savestates"));
|
||||||
}
|
}
|
||||||
|
|
||||||
FolderSettingsWidget::~FolderSettingsWidget() = default;
|
FolderSettingsWidget::~FolderSettingsWidget() = default;
|
||||||
|
|
|
@ -529,6 +529,17 @@ void EmuThread::reloadGameSettings(bool display_osd_messages /* = false */)
|
||||||
System::ReloadGameSettings(display_osd_messages);
|
System::ReloadGameSettings(display_osd_messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EmuThread::updateEmuFolders()
|
||||||
|
{
|
||||||
|
if (!isOnThread())
|
||||||
|
{
|
||||||
|
QMetaObject::invokeMethod(this, &EmuThread::updateEmuFolders, Qt::QueuedConnection);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
EmuFolders::Update();
|
||||||
|
}
|
||||||
|
|
||||||
void EmuThread::startFullscreenUI()
|
void EmuThread::startFullscreenUI()
|
||||||
{
|
{
|
||||||
if (!isOnThread())
|
if (!isOnThread())
|
||||||
|
|
|
@ -145,6 +145,7 @@ public Q_SLOTS:
|
||||||
void setDefaultSettings(bool system = true, bool controller = true);
|
void setDefaultSettings(bool system = true, bool controller = true);
|
||||||
void applySettings(bool display_osd_messages = false);
|
void applySettings(bool display_osd_messages = false);
|
||||||
void reloadGameSettings(bool display_osd_messages = false);
|
void reloadGameSettings(bool display_osd_messages = false);
|
||||||
|
void updateEmuFolders();
|
||||||
void reloadInputSources();
|
void reloadInputSources();
|
||||||
void reloadInputBindings();
|
void reloadInputBindings();
|
||||||
void enumerateInputDevices();
|
void enumerateInputDevices();
|
||||||
|
|
|
@ -880,10 +880,7 @@ static void BindWidgetToFolderSetting(SettingsInterface* sif, WidgetType* widget
|
||||||
Host::DeleteBaseSettingValue(section.c_str(), key.c_str());
|
Host::DeleteBaseSettingValue(section.c_str(), key.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
Panic("Fixme");
|
|
||||||
#if 0
|
|
||||||
g_emu_thread->updateEmuFolders();
|
g_emu_thread->updateEmuFolders();
|
||||||
#endif
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (browse_button)
|
if (browse_button)
|
||||||
|
@ -910,7 +907,7 @@ static void BindWidgetToFolderSetting(SettingsInterface* sif, WidgetType* widget
|
||||||
{
|
{
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
reset_button, &QAbstractButton::clicked, reset_button, [widget, default_value = std::move(default_value)]() {
|
reset_button, &QAbstractButton::clicked, reset_button, [widget, default_value = std::move(default_value)]() {
|
||||||
Accessor::setStringValue(widget, QString::fromStdString(Path::Combine(EmuFolders::AppRoot, default_value)));
|
Accessor::setStringValue(widget, QString::fromStdString(default_value));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1644,7 +1644,7 @@ void FullscreenUI::DrawFolderSetting(const char* title, const char* section, con
|
||||||
GetEditingSettingsInterface()->SetStringValue(section.c_str(), key.c_str(), relative_path.c_str());
|
GetEditingSettingsInterface()->SetStringValue(section.c_str(), key.c_str(), relative_path.c_str());
|
||||||
SetSettingsChanged();
|
SetSettingsChanged();
|
||||||
|
|
||||||
Host::RunOnCPUThread(&Host::Internal::UpdateEmuFolders);
|
Host::RunOnCPUThread(EmuFolders::Update);
|
||||||
|
|
||||||
CloseFileSelector();
|
CloseFileSelector();
|
||||||
});
|
});
|
||||||
|
|
|
@ -138,7 +138,3 @@ void Host::Internal::SetInputSettingsLayer(SettingsInterface* sif)
|
||||||
std::unique_lock lock(s_settings_mutex);
|
std::unique_lock lock(s_settings_mutex);
|
||||||
s_layered_settings_interface.SetLayer(LayeredSettingsInterface::LAYER_INPUT, sif);
|
s_layered_settings_interface.SetLayer(LayeredSettingsInterface::LAYER_INPUT, sif);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Host::Internal::UpdateEmuFolders()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue