mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
DolphinQt2: replace Settings with SConfig where possible
Changes: - `ShowDevelopmentWarning` is now under the '[Interface]' group in Dolphin.ini, with other interface-related settings. So, whoever uses DolphinQt will have to edit that manually again. Sorry! - Game search paths and the last file are now shared properly with DolphinWX - Qt-only preferences like "Preferred View: list/table" are now stored using the platform's native settings storage, rather than in UI.ini
This commit is contained in:
@ -13,12 +13,13 @@
|
||||
#include "DolphinQt2/Settings.h"
|
||||
#include "InputCommon/InputConfig.h"
|
||||
|
||||
static QString GetSettingsPath()
|
||||
{
|
||||
return QString::fromStdString(File::GetUserPath(D_CONFIG_IDX)) + QStringLiteral("/UI.ini");
|
||||
}
|
||||
|
||||
Settings::Settings() : QSettings(GetSettingsPath(), QSettings::IniFormat)
|
||||
Settings::Settings()
|
||||
:
|
||||
#ifdef Q_OS_MAC
|
||||
m_native_settings(QStringLiteral("dolphin-emu.org"), QStringLiteral("dolphin"))
|
||||
#else
|
||||
m_native_settings(QStringLiteral("Dolphin Emulator"), QStringLiteral("Dolphin"))
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
@ -34,17 +35,6 @@ void Settings::SetThemeName(const QString& theme_name)
|
||||
emit ThemeChanged();
|
||||
}
|
||||
|
||||
QString Settings::GetThemeDir() const
|
||||
{
|
||||
return QString::fromStdString(File::GetThemeDir(SConfig::GetInstance().theme_name));
|
||||
}
|
||||
|
||||
QString Settings::GetResourcesDir() const
|
||||
{
|
||||
return QString::fromStdString(File::GetSysDirectory().append("Resources"))
|
||||
.append(QDir::separator());
|
||||
}
|
||||
|
||||
QString Settings::GetProfilesDir() const
|
||||
{
|
||||
return QString::fromStdString(File::GetUserPath(D_CONFIG_IDX) + "Profiles/");
|
||||
@ -56,168 +46,57 @@ QString Settings::GetProfileINIPath(const InputConfig* config, const QString& na
|
||||
name + QStringLiteral(".ini");
|
||||
}
|
||||
|
||||
bool Settings::IsInDevelopmentWarningEnabled() const
|
||||
{
|
||||
// There's intentionally no way to set this from the UI.
|
||||
// Add it to your INI manually instead.
|
||||
return value(QStringLiteral("ShowDevelopmentWarning"), true).toBool();
|
||||
}
|
||||
|
||||
QStringList Settings::GetPaths() const
|
||||
{
|
||||
return value(QStringLiteral("GameList/Paths")).toStringList();
|
||||
QStringList list;
|
||||
for (const auto& path : SConfig::GetInstance().m_ISOFolder)
|
||||
list << QString::fromStdString(path);
|
||||
return list;
|
||||
}
|
||||
|
||||
void Settings::AddPath(const QString& path)
|
||||
void Settings::AddPath(const QString& qpath)
|
||||
{
|
||||
QStringList game_folders = Settings::Instance().GetPaths();
|
||||
if (!game_folders.contains(path))
|
||||
{
|
||||
game_folders << path;
|
||||
Settings::Instance().SetPaths(game_folders);
|
||||
emit PathAdded(path);
|
||||
}
|
||||
}
|
||||
std::string path = qpath.toStdString();
|
||||
|
||||
void Settings::SetPaths(const QStringList& paths)
|
||||
{
|
||||
setValue(QStringLiteral("GameList/Paths"), paths);
|
||||
}
|
||||
|
||||
void Settings::RemovePath(const QString& path)
|
||||
{
|
||||
QStringList paths = GetPaths();
|
||||
int i = paths.indexOf(path);
|
||||
if (i < 0)
|
||||
std::vector<std::string>& paths = SConfig::GetInstance().m_ISOFolder;
|
||||
if (std::find(paths.begin(), paths.end(), path) != paths.end())
|
||||
return;
|
||||
|
||||
paths.removeAt(i);
|
||||
SetPaths(paths);
|
||||
emit PathRemoved(path);
|
||||
paths.emplace_back(path);
|
||||
emit PathAdded(qpath);
|
||||
}
|
||||
|
||||
QString Settings::GetDefaultGame() const
|
||||
void Settings::RemovePath(const QString& qpath)
|
||||
{
|
||||
return QString::fromStdString(SConfig::GetInstance().m_strDefaultISO);
|
||||
}
|
||||
std::string path = qpath.toStdString();
|
||||
std::vector<std::string>& paths = SConfig::GetInstance().m_ISOFolder;
|
||||
|
||||
void Settings::SetDefaultGame(const QString& path)
|
||||
{
|
||||
SConfig::GetInstance().m_strDefaultISO = path.toStdString();
|
||||
SConfig::GetInstance().SaveSettings();
|
||||
}
|
||||
auto new_end = std::remove(paths.begin(), paths.end(), path);
|
||||
if (new_end == paths.end())
|
||||
return;
|
||||
|
||||
QString Settings::GetDVDRoot() const
|
||||
{
|
||||
return QString::fromStdString(SConfig::GetInstance().m_strDVDRoot);
|
||||
}
|
||||
|
||||
void Settings::SetDVDRoot(const QString& path)
|
||||
{
|
||||
SConfig::GetInstance().m_strDVDRoot = path.toStdString();
|
||||
SConfig::GetInstance().SaveSettings();
|
||||
}
|
||||
|
||||
QString Settings::GetApploader() const
|
||||
{
|
||||
return QString::fromStdString(SConfig::GetInstance().m_strApploader);
|
||||
}
|
||||
|
||||
void Settings::SetApploader(const QString& path)
|
||||
{
|
||||
SConfig::GetInstance().m_strApploader = path.toStdString();
|
||||
SConfig::GetInstance().SaveSettings();
|
||||
}
|
||||
|
||||
QString Settings::GetWiiNAND() const
|
||||
{
|
||||
return QString::fromStdString(SConfig::GetInstance().m_NANDPath);
|
||||
}
|
||||
|
||||
void Settings::SetWiiNAND(const QString& path)
|
||||
{
|
||||
SConfig::GetInstance().m_NANDPath = path.toStdString();
|
||||
SConfig::GetInstance().SaveSettings();
|
||||
}
|
||||
|
||||
float Settings::GetEmulationSpeed() const
|
||||
{
|
||||
return SConfig::GetInstance().m_EmulationSpeed;
|
||||
}
|
||||
|
||||
void Settings::SetEmulationSpeed(float val)
|
||||
{
|
||||
SConfig::GetInstance().m_EmulationSpeed = val;
|
||||
}
|
||||
|
||||
bool Settings::GetForceNTSCJ() const
|
||||
{
|
||||
return SConfig::GetInstance().bForceNTSCJ;
|
||||
}
|
||||
|
||||
void Settings::SetForceNTSCJ(bool val)
|
||||
{
|
||||
SConfig::GetInstance().bForceNTSCJ = val;
|
||||
}
|
||||
|
||||
bool Settings::GetAnalyticsEnabled() const
|
||||
{
|
||||
return SConfig::GetInstance().m_analytics_enabled;
|
||||
}
|
||||
|
||||
void Settings::SetAnalyticsEnabled(bool val)
|
||||
{
|
||||
SConfig::GetInstance().m_analytics_enabled = val;
|
||||
}
|
||||
|
||||
DiscIO::Language Settings::GetWiiSystemLanguage() const
|
||||
{
|
||||
return SConfig::GetInstance().GetCurrentLanguage(true);
|
||||
}
|
||||
|
||||
DiscIO::Language Settings::GetGCSystemLanguage() const
|
||||
{
|
||||
return SConfig::GetInstance().GetCurrentLanguage(false);
|
||||
paths.erase(new_end, paths.end());
|
||||
emit PathRemoved(qpath);
|
||||
}
|
||||
|
||||
bool Settings::GetPreferredView() const
|
||||
{
|
||||
return value(QStringLiteral("PreferredView"), true).toBool();
|
||||
return m_native_settings.value(QStringLiteral("PreferredView"), true).toBool();
|
||||
}
|
||||
|
||||
void Settings::SetPreferredView(bool table)
|
||||
{
|
||||
setValue(QStringLiteral("PreferredView"), table);
|
||||
}
|
||||
|
||||
bool Settings::GetConfirmStop() const
|
||||
{
|
||||
return value(QStringLiteral("Emulation/ConfirmStop"), true).toBool();
|
||||
m_native_settings.setValue(QStringLiteral("PreferredView"), table);
|
||||
}
|
||||
|
||||
int Settings::GetStateSlot() const
|
||||
{
|
||||
return value(QStringLiteral("Emulation/StateSlot"), 1).toInt();
|
||||
return m_native_settings.value(QStringLiteral("Emulation/StateSlot"), 1).toInt();
|
||||
}
|
||||
|
||||
void Settings::SetStateSlot(int slot)
|
||||
{
|
||||
setValue(QStringLiteral("Emulation/StateSlot"), slot);
|
||||
}
|
||||
|
||||
bool Settings::GetRenderToMain() const
|
||||
{
|
||||
return value(QStringLiteral("Graphics/RenderToMain"), false).toBool();
|
||||
}
|
||||
|
||||
bool Settings::GetFullScreen() const
|
||||
{
|
||||
return value(QStringLiteral("Graphics/FullScreen"), false).toBool();
|
||||
}
|
||||
|
||||
QSize Settings::GetRenderWindowSize() const
|
||||
{
|
||||
return value(QStringLiteral("Graphics/RenderWindowSize"), QSize(640, 480)).toSize();
|
||||
m_native_settings.setValue(QStringLiteral("Emulation/StateSlot"), slot);
|
||||
}
|
||||
|
||||
void Settings::SetHideCursor(bool hide_cursor)
|
||||
@ -257,136 +136,6 @@ void Settings::DecreaseVolume(int volume)
|
||||
emit VolumeChanged(GetVolume());
|
||||
}
|
||||
|
||||
bool& Settings::BannerVisible() const
|
||||
{
|
||||
return SConfig::GetInstance().m_showBannerColumn;
|
||||
}
|
||||
|
||||
bool& Settings::CountryVisible() const
|
||||
{
|
||||
return SConfig::GetInstance().m_showRegionColumn;
|
||||
}
|
||||
|
||||
bool& Settings::DescriptionVisible() const
|
||||
{
|
||||
return SConfig::GetInstance().m_showDescriptionColumn;
|
||||
}
|
||||
|
||||
bool& Settings::FilenameVisible() const
|
||||
{
|
||||
return SConfig::GetInstance().m_showFileNameColumn;
|
||||
}
|
||||
|
||||
bool& Settings::IDVisible() const
|
||||
{
|
||||
return SConfig::GetInstance().m_showIDColumn;
|
||||
}
|
||||
|
||||
bool& Settings::MakerVisible() const
|
||||
{
|
||||
return SConfig::GetInstance().m_showMakerColumn;
|
||||
}
|
||||
|
||||
bool& Settings::PlatformVisible() const
|
||||
{
|
||||
return SConfig::GetInstance().m_showSystemColumn;
|
||||
}
|
||||
|
||||
bool& Settings::TitleVisible() const
|
||||
{
|
||||
return SConfig::GetInstance().m_showTitleColumn;
|
||||
}
|
||||
|
||||
bool& Settings::SizeVisible() const
|
||||
{
|
||||
return SConfig::GetInstance().m_showSizeColumn;
|
||||
}
|
||||
|
||||
bool& Settings::StateVisible() const
|
||||
{
|
||||
return SConfig::GetInstance().m_showStateColumn;
|
||||
}
|
||||
|
||||
bool Settings::IsBluetoothPassthroughEnabled() const
|
||||
{
|
||||
return SConfig::GetInstance().m_bt_passthrough_enabled;
|
||||
}
|
||||
|
||||
void Settings::SetBluetoothPassthroughEnabled(bool enabled)
|
||||
{
|
||||
SConfig::GetInstance().m_bt_passthrough_enabled = enabled;
|
||||
}
|
||||
|
||||
bool Settings::IsContinuousScanningEnabled() const
|
||||
{
|
||||
return SConfig::GetInstance().m_WiimoteContinuousScanning;
|
||||
}
|
||||
|
||||
void Settings::SetContinuousScanningEnabled(bool enabled)
|
||||
{
|
||||
SConfig::GetInstance().m_WiimoteContinuousScanning = enabled;
|
||||
}
|
||||
|
||||
bool Settings::IsBackgroundInputEnabled() const
|
||||
{
|
||||
return SConfig::GetInstance().m_BackgroundInput;
|
||||
}
|
||||
|
||||
void Settings::SetBackgroundInputEnabled(bool enabled)
|
||||
{
|
||||
SConfig::GetInstance().m_BackgroundInput = enabled;
|
||||
}
|
||||
|
||||
bool Settings::IsWiimoteSpeakerEnabled() const
|
||||
{
|
||||
return SConfig::GetInstance().m_WiimoteEnableSpeaker;
|
||||
}
|
||||
|
||||
void Settings::SetWiimoteSpeakerEnabled(bool enabled)
|
||||
{
|
||||
SConfig::GetInstance().m_WiimoteEnableSpeaker = enabled;
|
||||
}
|
||||
|
||||
SerialInterface::SIDevices Settings::GetSIDevice(size_t i) const
|
||||
{
|
||||
return SConfig::GetInstance().m_SIDevice[i];
|
||||
}
|
||||
|
||||
void Settings::SetSIDevice(size_t i, SerialInterface::SIDevices device)
|
||||
{
|
||||
SConfig::GetInstance().m_SIDevice[i] = device;
|
||||
}
|
||||
|
||||
bool Settings::IsWiiGameRunning() const
|
||||
{
|
||||
return SConfig::GetInstance().bWii;
|
||||
}
|
||||
|
||||
bool Settings::IsGCAdapterRumbleEnabled(int port) const
|
||||
{
|
||||
return SConfig::GetInstance().m_AdapterRumble[port];
|
||||
}
|
||||
|
||||
void Settings::SetGCAdapterRumbleEnabled(int port, bool enabled)
|
||||
{
|
||||
SConfig::GetInstance().m_AdapterRumble[port] = enabled;
|
||||
}
|
||||
|
||||
bool Settings::IsGCAdapterSimulatingDKBongos(int port) const
|
||||
{
|
||||
return SConfig::GetInstance().m_AdapterKonga[port];
|
||||
}
|
||||
|
||||
void Settings::SetGCAdapterSimulatingDKBongos(int port, bool enabled)
|
||||
{
|
||||
SConfig::GetInstance().m_AdapterKonga[port] = enabled;
|
||||
}
|
||||
|
||||
void Settings::Save()
|
||||
{
|
||||
return SConfig::GetInstance().SaveSettings();
|
||||
}
|
||||
|
||||
QVector<QString> Settings::GetProfiles(const InputConfig* config) const
|
||||
{
|
||||
const std::string path = GetProfilesDir().toStdString() + config->GetProfileName();
|
||||
@ -401,13 +150,3 @@ QVector<QString> Settings::GetProfiles(const InputConfig* config) const
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
bool Settings::HasAskedForAnalyticsPermission() const
|
||||
{
|
||||
return SConfig::GetInstance().m_analytics_permission_asked;
|
||||
}
|
||||
|
||||
void Settings::SetAskedForAnalyticsPermission(bool value)
|
||||
{
|
||||
SConfig::GetInstance().m_analytics_permission_asked = value;
|
||||
}
|
||||
|
Reference in New Issue
Block a user