1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

refactor(startup): extract startup makeToxPortable logic

This facilitates later use without instantiating Settings object during startup
This commit is contained in:
jenli669 2019-06-24 01:23:18 +02:00
parent 68d24eec64
commit ac640bb4bd
No known key found for this signature in database
GPG Key ID: 8267F9F7C2BF7E5E
2 changed files with 18 additions and 11 deletions

View File

@ -109,17 +109,7 @@ void Settings::loadGlobal()
createSettingsDir(); createSettingsDir();
QString localSettingsPath = qApp->applicationDirPath() + QDir::separator() + globalSettingsFile; makeToxPortable = Settings::isToxPortable();
if (QFile(localSettingsPath).exists()) {
QSettings ps(localSettingsPath, QSettings::IniFormat);
ps.setIniCodec("UTF-8");
ps.beginGroup("Advanced");
makeToxPortable = ps.value("makeToxPortable", false).toBool();
ps.endGroup();
} else {
makeToxPortable = false;
}
QDir dir(getSettingsDirPath()); QDir dir(getSettingsDirPath());
QString filePath = dir.filePath(globalSettingsFile); QString filePath = dir.filePath(globalSettingsFile);
@ -273,6 +263,22 @@ void Settings::loadGlobal()
loaded = true; loaded = true;
} }
bool Settings::isToxPortable()
{
QString localSettingsPath = qApp->applicationDirPath() + QDir::separator() + globalSettingsFile;
bool result;
if (QFile(localSettingsPath).exists()) {
QSettings ps(localSettingsPath, QSettings::IniFormat);
ps.setIniCodec("UTF-8");
ps.beginGroup("Advanced");
result = ps.value("makeToxPortable", false).toBool();
ps.endGroup();
return result;
}
return false;
}
void Settings::updateProfileData(Profile *profile) void Settings::updateProfileData(Profile *profile)
{ {
QMutexLocker locker{&bigLock}; QMutexLocker locker{&bigLock};

View File

@ -154,6 +154,7 @@ public:
void savePersonal(); void savePersonal();
void loadGlobal(); void loadGlobal();
bool isToxPortable();
void loadPersonal(QString profileName, const ToxEncrypt* passKey); void loadPersonal(QString profileName, const ToxEncrypt* passKey);
void resetToDefault(); void resetToDefault();