mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-12-04 23:34:17 +01:00
ff931590b0
Over time our config values have grown quite numerous in size. Unfortunately it also makes the single functions we have for loading and saving values more error prone. For example, we were loading the core settings twice when they only should have been loaded once. In another section, a variable was shadowing another variable used to load settings from a completely different section. Finally, in one other case, there was an extraneous endGroup() call used that didn't need to be done. This was essentially dead code and also a bug waiting to happen. This separates the section loading code into its own separate functions. This keeps variables only visible to the code that actually needs it, and makes it much easier to visually see the end of each individual configuration group. It also makes it much easier to visually catch bugs during code review. While we're at it, this also uses QStringLiteral instead of raw string literals, which both avoids constructing a lot of QString instances, but also makes it much easier to disable implicit ASCII to QString and vice-versa in the future via setting QT_NO_CAST_FROM_ASCII and QT_NO_CAST_TO_ASCII as compilation flags.
75 lines
2.0 KiB
C++
75 lines
2.0 KiB
C++
// Copyright 2014 Citra Emulator Project
|
|
// Licensed under GPLv2 or any later version
|
|
// Refer to the license.txt file included.
|
|
|
|
#pragma once
|
|
|
|
#include <array>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <QVariant>
|
|
#include "core/settings.h"
|
|
|
|
class QSettings;
|
|
|
|
class Config {
|
|
public:
|
|
Config();
|
|
~Config();
|
|
|
|
void Reload();
|
|
void Save();
|
|
|
|
static const std::array<int, Settings::NativeButton::NumButtons> default_buttons;
|
|
static const std::array<std::array<int, 5>, Settings::NativeAnalog::NumAnalogs> default_analogs;
|
|
|
|
private:
|
|
void ReadValues();
|
|
void ReadAudioValues();
|
|
void ReadCameraValues();
|
|
void ReadControlValues();
|
|
void ReadCoreValues();
|
|
void ReadDataStorageValues();
|
|
void ReadDebuggingValues();
|
|
void ReadLayoutValues();
|
|
void ReadMiscellaneousValues();
|
|
void ReadMultiplayerValues();
|
|
void ReadPathValues();
|
|
void ReadRendererValues();
|
|
void ReadShortcutValues();
|
|
void ReadSystemValues();
|
|
void ReadUIValues();
|
|
void ReadUIGameListValues();
|
|
void ReadUILayoutValues();
|
|
void ReadUpdaterValues();
|
|
void ReadWebServiceValues();
|
|
|
|
void SaveValues();
|
|
void SaveAudioValues();
|
|
void SaveCameraValues();
|
|
void SaveControlValues();
|
|
void SaveCoreValues();
|
|
void SaveDataStorageValues();
|
|
void SaveDebuggingValues();
|
|
void SaveLayoutValues();
|
|
void SaveMiscellaneousValues();
|
|
void SaveMultiplayerValues();
|
|
void SavePathValues();
|
|
void SaveRendererValues();
|
|
void SaveShortcutValues();
|
|
void SaveSystemValues();
|
|
void SaveUIValues();
|
|
void SaveUIGameListValues();
|
|
void SaveUILayoutValues();
|
|
void SaveUpdaterValues();
|
|
void SaveWebServiceValues();
|
|
|
|
QVariant ReadSetting(const QString& name) const;
|
|
QVariant ReadSetting(const QString& name, const QVariant& default_value) const;
|
|
void WriteSetting(const QString& name, const QVariant& value);
|
|
void WriteSetting(const QString& name, const QVariant& value, const QVariant& default_value);
|
|
|
|
std::unique_ptr<QSettings> qt_config;
|
|
std::string qt_config_loc;
|
|
};
|