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:
parent
68d24eec64
commit
ac640bb4bd
|
@ -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};
|
||||||
|
|
|
@ -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();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user