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();
|
||||
|
||||
QString localSettingsPath = qApp->applicationDirPath() + QDir::separator() + globalSettingsFile;
|
||||
|
||||
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;
|
||||
}
|
||||
makeToxPortable = Settings::isToxPortable();
|
||||
|
||||
QDir dir(getSettingsDirPath());
|
||||
QString filePath = dir.filePath(globalSettingsFile);
|
||||
|
@ -273,6 +263,22 @@ void Settings::loadGlobal()
|
|||
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)
|
||||
{
|
||||
QMutexLocker locker{&bigLock};
|
||||
|
|
|
@ -154,6 +154,7 @@ public:
|
|||
void savePersonal();
|
||||
|
||||
void loadGlobal();
|
||||
bool isToxPortable();
|
||||
void loadPersonal(QString profileName, const ToxEncrypt* passKey);
|
||||
|
||||
void resetToDefault();
|
||||
|
|
Loading…
Reference in New Issue
Block a user