Qt: Make ConfigController::configDir static

This commit is contained in:
Vicki Pfau 2017-01-18 01:36:06 -08:00
parent 22a36e0af9
commit c11551a1f7
3 changed files with 16 additions and 8 deletions

View File

@ -88,14 +88,13 @@ void ConfigOption::setValue(const QVariant& value) {
}
}
QString ConfigController::s_configDir;
ConfigController::ConfigController(QObject* parent)
: QObject(parent)
, m_opts()
{
char path[PATH_MAX];
mCoreConfigDirectory(path, sizeof(path));
m_configDir = QString::fromUtf8(path);
QString fileName = (m_configDir);
QString fileName = configDir();
fileName.append(QDir::separator());
fileName.append("qt.ini");
m_settings = new QSettings(fileName, QSettings::IniFormat, this);
@ -270,7 +269,7 @@ void ConfigController::write() {
void ConfigController::makePortable() {
mCoreConfigMakePortable(&m_config);
QString fileName(m_configDir);
QString fileName(configDir());
fileName.append(QDir::separator());
fileName.append("qt.ini");
QSettings* settings2 = new QSettings(fileName, QSettings::IniFormat, this);
@ -280,3 +279,12 @@ void ConfigController::makePortable() {
delete m_settings;
m_settings = settings2;
}
const QString& ConfigController::configDir() {
if (s_configDir.isNull()) {
char path[PATH_MAX];
mCoreConfigDirectory(path, sizeof(path));
s_configDir = QString::fromUtf8(path);
}
return s_configDir;
}

View File

@ -84,7 +84,7 @@ public:
const mCoreConfig* config() { return &m_config; }
const QString& configDir() { return m_configDir; }
static const QString& configDir();
public slots:
void setOption(const char* key, bool value);
@ -105,7 +105,7 @@ private:
QMap<QString, ConfigOption*> m_optionSet;
QSettings* m_settings;
QString m_configDir;
static QString s_configDir;
};
}

View File

@ -218,7 +218,7 @@ QString GBAApp::dataDir() {
#ifdef USE_SQLITE3
bool GBAApp::reloadGameDB() {
NoIntroDB* db = nullptr;
db = NoIntroDBLoad((m_configController.configDir() + "/nointro.sqlite3").toLocal8Bit().constData());
db = NoIntroDBLoad((ConfigController::configDir() + "/nointro.sqlite3").toUtf8().constData());
if (db && m_db) {
NoIntroDBDestroy(m_db);
}