mirror of
https://gitlab.com/suyu-emu/suyu.git
synced 2024-03-15 23:15:44 +00:00
Merge pull request #1558 from lioncash/ptr
yuzu/configuration/config: Use a std::unique_ptr for qt_config instead of a raw pointer
This commit is contained in:
commit
3a6e76e9b5
|
@ -13,11 +13,16 @@ Config::Config() {
|
|||
// TODO: Don't hardcode the path; let the frontend decide where to put the config files.
|
||||
qt_config_loc = FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) + "qt-config.ini";
|
||||
FileUtil::CreateFullPath(qt_config_loc);
|
||||
qt_config = new QSettings(QString::fromStdString(qt_config_loc), QSettings::IniFormat);
|
||||
qt_config =
|
||||
std::make_unique<QSettings>(QString::fromStdString(qt_config_loc), QSettings::IniFormat);
|
||||
|
||||
Reload();
|
||||
}
|
||||
|
||||
Config::~Config() {
|
||||
Save();
|
||||
}
|
||||
|
||||
const std::array<int, Settings::NativeButton::NumButtons> Config::default_buttons = {
|
||||
Qt::Key_A, Qt::Key_S, Qt::Key_Z, Qt::Key_X, Qt::Key_3, Qt::Key_4, Qt::Key_Q,
|
||||
Qt::Key_W, Qt::Key_1, Qt::Key_2, Qt::Key_N, Qt::Key_M, Qt::Key_F, Qt::Key_T,
|
||||
|
@ -342,9 +347,3 @@ void Config::Reload() {
|
|||
void Config::Save() {
|
||||
SaveValues();
|
||||
}
|
||||
|
||||
Config::~Config() {
|
||||
Save();
|
||||
|
||||
delete qt_config;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <QVariant>
|
||||
#include "core/settings.h"
|
||||
|
@ -12,12 +13,6 @@
|
|||
class QSettings;
|
||||
|
||||
class Config {
|
||||
QSettings* qt_config;
|
||||
std::string qt_config_loc;
|
||||
|
||||
void ReadValues();
|
||||
void SaveValues();
|
||||
|
||||
public:
|
||||
Config();
|
||||
~Config();
|
||||
|
@ -27,4 +22,11 @@ public:
|
|||
|
||||
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 SaveValues();
|
||||
|
||||
std::unique_ptr<QSettings> qt_config;
|
||||
std::string qt_config_loc;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue