mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-05 06:26:49 +00:00
Qt: purge gui settings
This commit is contained in:
parent
a146aabcaf
commit
b7e4de6ea5
9 changed files with 49 additions and 354 deletions
|
|
@ -15,57 +15,7 @@ inline std::string sstr(const QString& _in) { return _in.toStdString(); }
|
|||
|
||||
gui_settings::gui_settings(QObject* parent) : settings(parent)
|
||||
{
|
||||
m_current_name = gui::Settings;
|
||||
m_settings.reset(new QSettings(ComputeSettingsDir() + gui::Settings + ".ini", QSettings::Format::IniFormat, parent));
|
||||
|
||||
const QString settings_name = GetValue(gui::m_currentConfig).toString();
|
||||
|
||||
if (settings_name != m_current_name)
|
||||
{
|
||||
ChangeToConfig(settings_name);
|
||||
}
|
||||
}
|
||||
|
||||
bool gui_settings::ChangeToConfig(const QString& config_name)
|
||||
{
|
||||
if (m_current_name == config_name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Backup current config
|
||||
SaveCurrentConfig(m_current_name);
|
||||
|
||||
// Save new config name to the default config
|
||||
SaveConfigNameToDefault(config_name);
|
||||
|
||||
// Sync file just in case
|
||||
m_settings->sync();
|
||||
|
||||
// Load new config
|
||||
m_settings.reset(new QSettings(m_settings_dir.absoluteFilePath(config_name + ".ini"), QSettings::IniFormat));
|
||||
|
||||
// Save own name to new config
|
||||
SetValue(gui::m_currentConfig, config_name);
|
||||
m_settings->sync();
|
||||
|
||||
m_current_name = config_name;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void gui_settings::Reset(bool remove_meta) const
|
||||
{
|
||||
if (remove_meta)
|
||||
{
|
||||
m_settings->clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_settings->remove(gui::logger);
|
||||
m_settings->remove(gui::main_window);
|
||||
m_settings->remove(gui::game_list);
|
||||
}
|
||||
}
|
||||
|
||||
QStringList gui_settings::GetGameListCategoryFilters() const
|
||||
|
|
@ -245,13 +195,6 @@ void gui_settings::SetCustomColor(int col, const QColor& val) const
|
|||
SetValue(gui_save(gui::meta, "CustomColor" + QString::number(col), gui::gl_icon_color), val);
|
||||
}
|
||||
|
||||
void gui_settings::SaveCurrentConfig(const QString& config_name)
|
||||
{
|
||||
SaveConfigNameToDefault(config_name);
|
||||
BackupSettingsToTarget(config_name);
|
||||
ChangeToConfig(config_name);
|
||||
}
|
||||
|
||||
logs::level gui_settings::GetLogLevel() const
|
||||
{
|
||||
return logs::level(GetValue(gui::l_level).toUInt());
|
||||
|
|
@ -267,53 +210,6 @@ QColor gui_settings::GetCustomColor(int col) const
|
|||
return GetValue(gui_save(gui::meta, "CustomColor" + QString::number(col), gui::gl_icon_color)).value<QColor>();
|
||||
}
|
||||
|
||||
QStringList gui_settings::GetConfigEntries() const
|
||||
{
|
||||
const QStringList name_filter = QStringList("*.ini");
|
||||
const QFileInfoList entries = m_settings_dir.entryInfoList(name_filter, QDir::Files);
|
||||
|
||||
QStringList res;
|
||||
|
||||
for (const QFileInfo &entry : entries)
|
||||
{
|
||||
res.append(entry.baseName());
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
// Save the name of the used config to the default settings file
|
||||
void gui_settings::SaveConfigNameToDefault(const QString& config_name) const
|
||||
{
|
||||
if (m_current_name == gui::Settings)
|
||||
{
|
||||
SetValue(gui::m_currentConfig, config_name);
|
||||
m_settings->sync();
|
||||
}
|
||||
else
|
||||
{
|
||||
QSettings tmp(m_settings_dir.absoluteFilePath(gui::Settings + ".ini"), QSettings::Format::IniFormat, parent());
|
||||
tmp.beginGroup(gui::m_currentConfig.key);
|
||||
tmp.setValue(gui::m_currentConfig.name, config_name);
|
||||
tmp.endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
void gui_settings::BackupSettingsToTarget(const QString& config_name) const
|
||||
{
|
||||
QSettings target(ComputeSettingsDir() + config_name + ".ini", QSettings::Format::IniFormat);
|
||||
|
||||
for (const QString& key : m_settings->allKeys())
|
||||
{
|
||||
if (!key.startsWith(gui::meta))
|
||||
{
|
||||
target.setValue(key, m_settings->value(key));
|
||||
}
|
||||
}
|
||||
|
||||
target.sync();
|
||||
}
|
||||
|
||||
QStringList gui_settings::GetStylesheetEntries() const
|
||||
{
|
||||
const QStringList name_filter = QStringList("*.qss");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue