2015-12-20 23:36:39 +00:00
|
|
|
// Copyright 2015 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2017-05-09 16:49:10 +00:00
|
|
|
#include <QDir>
|
2015-12-20 23:36:39 +00:00
|
|
|
#include <QSize>
|
|
|
|
|
2017-05-20 15:53:17 +00:00
|
|
|
#include "Common/FileSearch.h"
|
2015-12-20 23:36:39 +00:00
|
|
|
#include "Common/FileUtil.h"
|
2017-05-20 15:53:17 +00:00
|
|
|
#include "Common/StringUtil.h"
|
2015-12-20 23:36:39 +00:00
|
|
|
#include "Core/ConfigManager.h"
|
|
|
|
#include "DolphinQt2/Settings.h"
|
2017-05-20 15:53:17 +00:00
|
|
|
#include "InputCommon/InputConfig.h"
|
2015-12-20 23:36:39 +00:00
|
|
|
|
|
|
|
static QString GetSettingsPath()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return QString::fromStdString(File::GetUserPath(D_CONFIG_IDX)) + QStringLiteral("/UI.ini");
|
2015-12-20 23:36:39 +00:00
|
|
|
}
|
|
|
|
|
2017-05-31 07:17:39 +00:00
|
|
|
Settings::Settings() : QSettings(GetSettingsPath(), QSettings::IniFormat)
|
2015-12-20 23:36:39 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-05-31 07:17:39 +00:00
|
|
|
Settings& Settings::Instance()
|
|
|
|
{
|
|
|
|
static Settings settings;
|
|
|
|
return settings;
|
|
|
|
}
|
|
|
|
|
2017-05-31 23:15:48 +00:00
|
|
|
void Settings::SetThemeName(const QString& theme_name)
|
|
|
|
{
|
|
|
|
SConfig::GetInstance().theme_name = theme_name.toStdString();
|
|
|
|
emit ThemeChanged();
|
|
|
|
}
|
|
|
|
|
2015-12-20 23:36:39 +00:00
|
|
|
QString Settings::GetThemeDir() const
|
|
|
|
{
|
2017-05-29 11:52:01 +00:00
|
|
|
return QString::fromStdString(File::GetThemeDir(SConfig::GetInstance().theme_name));
|
2015-12-20 23:36:39 +00:00
|
|
|
}
|
|
|
|
|
2017-05-09 16:49:10 +00:00
|
|
|
QString Settings::GetResourcesDir() const
|
|
|
|
{
|
|
|
|
return QString::fromStdString(File::GetSysDirectory().append("Resources"))
|
|
|
|
.append(QDir::separator());
|
|
|
|
}
|
|
|
|
|
2017-05-20 15:53:17 +00:00
|
|
|
QString Settings::GetProfilesDir() const
|
|
|
|
{
|
|
|
|
return QString::fromStdString(File::GetUserPath(D_CONFIG_IDX) + "Profiles/");
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Settings::GetProfileINIPath(const InputConfig* config, const QString& name) const
|
|
|
|
{
|
|
|
|
return GetProfilesDir() + QString::fromStdString(config->GetProfileName()) + QDir::separator() +
|
|
|
|
name + QStringLiteral(".ini");
|
|
|
|
}
|
|
|
|
|
2016-07-13 05:52:45 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2015-12-20 23:36:39 +00:00
|
|
|
QStringList Settings::GetPaths() const
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return value(QStringLiteral("GameList/Paths")).toStringList();
|
2015-12-20 23:36:39 +00:00
|
|
|
}
|
|
|
|
|
2017-05-31 07:42:15 +00:00
|
|
|
void Settings::AddPath(const QString& path)
|
|
|
|
{
|
|
|
|
QStringList game_folders = Settings::Instance().GetPaths();
|
|
|
|
if (!game_folders.contains(path))
|
|
|
|
{
|
|
|
|
game_folders << path;
|
|
|
|
Settings::Instance().SetPaths(game_folders);
|
|
|
|
emit PathAdded(path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-22 03:46:03 +00:00
|
|
|
void Settings::SetPaths(const QStringList& paths)
|
2015-12-20 23:36:39 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
setValue(QStringLiteral("GameList/Paths"), paths);
|
2015-12-20 23:36:39 +00:00
|
|
|
}
|
|
|
|
|
2017-05-31 07:42:15 +00:00
|
|
|
void Settings::RemovePath(const QString& path)
|
2015-12-31 03:03:13 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
QStringList paths = GetPaths();
|
2017-05-31 07:42:15 +00:00
|
|
|
int i = paths.indexOf(path);
|
|
|
|
if (i < 0)
|
|
|
|
return;
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
paths.removeAt(i);
|
|
|
|
SetPaths(paths);
|
2017-05-31 07:42:15 +00:00
|
|
|
emit PathRemoved(path);
|
2015-12-31 03:03:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString Settings::GetDefaultGame() const
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return QString::fromStdString(SConfig::GetInstance().m_strDefaultISO);
|
2015-12-31 03:03:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::SetDefaultGame(const QString& path)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
SConfig::GetInstance().m_strDefaultISO = path.toStdString();
|
|
|
|
SConfig::GetInstance().SaveSettings();
|
2015-12-31 03:03:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString Settings::GetDVDRoot() const
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return QString::fromStdString(SConfig::GetInstance().m_strDVDRoot);
|
2015-12-31 03:03:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::SetDVDRoot(const QString& path)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
SConfig::GetInstance().m_strDVDRoot = path.toStdString();
|
|
|
|
SConfig::GetInstance().SaveSettings();
|
2015-12-31 03:03:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString Settings::GetApploader() const
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return QString::fromStdString(SConfig::GetInstance().m_strApploader);
|
2015-12-31 03:03:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::SetApploader(const QString& path)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
SConfig::GetInstance().m_strApploader = path.toStdString();
|
|
|
|
SConfig::GetInstance().SaveSettings();
|
2015-12-31 03:03:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString Settings::GetWiiNAND() const
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return QString::fromStdString(SConfig::GetInstance().m_NANDPath);
|
2015-12-31 03:03:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::SetWiiNAND(const QString& path)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
SConfig::GetInstance().m_NANDPath = path.toStdString();
|
|
|
|
SConfig::GetInstance().SaveSettings();
|
2015-12-31 03:03:13 +00:00
|
|
|
}
|
|
|
|
|
2017-05-04 04:19:51 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-07-06 18:33:05 +00:00
|
|
|
DiscIO::Language Settings::GetWiiSystemLanguage() const
|
2015-12-20 23:36:39 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return SConfig::GetInstance().GetCurrentLanguage(true);
|
2015-12-20 23:36:39 +00:00
|
|
|
}
|
|
|
|
|
2016-07-06 18:33:05 +00:00
|
|
|
DiscIO::Language Settings::GetGCSystemLanguage() const
|
2015-12-20 23:36:39 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return SConfig::GetInstance().GetCurrentLanguage(false);
|
2015-12-20 23:36:39 +00:00
|
|
|
}
|
|
|
|
|
2016-01-01 10:29:39 +00:00
|
|
|
bool Settings::GetPreferredView() const
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return value(QStringLiteral("PreferredView"), true).toBool();
|
2016-01-01 10:29:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::SetPreferredView(bool table)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
setValue(QStringLiteral("PreferredView"), table);
|
2016-01-01 10:29:39 +00:00
|
|
|
}
|
|
|
|
|
2015-12-20 23:36:39 +00:00
|
|
|
bool Settings::GetConfirmStop() const
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return value(QStringLiteral("Emulation/ConfirmStop"), true).toBool();
|
2015-12-20 23:36:39 +00:00
|
|
|
}
|
|
|
|
|
2016-02-15 01:56:40 +00:00
|
|
|
int Settings::GetStateSlot() const
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return value(QStringLiteral("Emulation/StateSlot"), 1).toInt();
|
2016-02-15 01:56:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::SetStateSlot(int slot)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
setValue(QStringLiteral("Emulation/StateSlot"), slot);
|
2016-02-15 01:56:40 +00:00
|
|
|
}
|
|
|
|
|
2015-12-20 23:36:39 +00:00
|
|
|
bool Settings::GetRenderToMain() const
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return value(QStringLiteral("Graphics/RenderToMain"), false).toBool();
|
2015-12-20 23:36:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Settings::GetFullScreen() const
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return value(QStringLiteral("Graphics/FullScreen"), false).toBool();
|
2015-12-20 23:36:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QSize Settings::GetRenderWindowSize() const
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return value(QStringLiteral("Graphics/RenderWindowSize"), QSize(640, 480)).toSize();
|
2015-12-20 23:36:39 +00:00
|
|
|
}
|
2017-05-08 17:03:59 +00:00
|
|
|
|
2017-06-01 06:49:06 +00:00
|
|
|
void Settings::SetHideCursor(bool hide_cursor)
|
|
|
|
{
|
|
|
|
SConfig::GetInstance().bHideCursor = hide_cursor;
|
|
|
|
emit HideCursorChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Settings::GetHideCursor() const
|
|
|
|
{
|
|
|
|
return SConfig::GetInstance().bHideCursor;
|
|
|
|
}
|
|
|
|
|
2017-05-08 17:03:59 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-05-09 16:49:10 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-05-20 15:53:17 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-05-08 17:03:59 +00:00
|
|
|
void Settings::Save()
|
|
|
|
{
|
|
|
|
return SConfig::GetInstance().SaveSettings();
|
|
|
|
}
|
2017-05-20 15:53:17 +00:00
|
|
|
|
|
|
|
QVector<QString> Settings::GetProfiles(const InputConfig* config) const
|
|
|
|
{
|
|
|
|
const std::string path = GetProfilesDir().toStdString() + config->GetProfileName();
|
|
|
|
QVector<QString> vec;
|
|
|
|
|
|
|
|
for (const auto& file : Common::DoFileSearch({".ini"}, {path}))
|
|
|
|
{
|
|
|
|
std::string basename;
|
|
|
|
SplitPath(file, nullptr, &basename, nullptr);
|
|
|
|
vec.push_back(QString::fromStdString(basename));
|
|
|
|
}
|
|
|
|
|
|
|
|
return vec;
|
|
|
|
}
|
2017-05-20 21:41:02 +00:00
|
|
|
|
|
|
|
bool Settings::HasAskedForAnalyticsPermission() const
|
|
|
|
{
|
|
|
|
return SConfig::GetInstance().m_analytics_permission_asked;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::SetAskedForAnalyticsPermission(bool value)
|
|
|
|
{
|
|
|
|
SConfig::GetInstance().m_analytics_permission_asked = value;
|
|
|
|
}
|