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

refactor(Paths): Remove portable state from Settings

It now duplicates the state in Paths where it is needed, creating the
chance for desync
This commit is contained in:
Anthony Bilinski 2022-02-09 20:20:32 -08:00
parent 557af80428
commit a828b54be4
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
2 changed files with 8 additions and 12 deletions

View File

@ -65,7 +65,6 @@ QThread* Settings::settingsThread{nullptr};
Settings::Settings() Settings::Settings()
: loaded(false) : loaded(false)
, useCustomDhtList{false} , useCustomDhtList{false}
, makeToxPortable{false}
, currentProfileId(0) , currentProfileId(0)
{ {
settingsThread = new QThread(); settingsThread = new QThread();
@ -159,7 +158,7 @@ void Settings::loadGlobal()
s.beginGroup("Advanced"); s.beginGroup("Advanced");
{ {
makeToxPortable = s.value("makeToxPortable", false).toBool(); paths.setPortable(s.value("makeToxPortable", false).toBool());
enableIPv6 = s.value("enableIPv6", true).toBool(); enableIPv6 = s.value("enableIPv6", true).toBool();
forceTCP = s.value("forceTCP", false).toBool(); forceTCP = s.value("forceTCP", false).toBool();
enableLanDiscovery = s.value("enableLanDiscovery", true).toBool(); enableLanDiscovery = s.value("enableLanDiscovery", true).toBool();
@ -623,7 +622,7 @@ void Settings::saveGlobal()
s.beginGroup("Advanced"); s.beginGroup("Advanced");
{ {
s.setValue("makeToxPortable", makeToxPortable); s.setValue("makeToxPortable", paths.isPortable());
s.setValue("enableIPv6", enableIPv6); s.setValue("enableIPv6", enableIPv6);
s.setValue("forceTCP", forceTCP); s.setValue("forceTCP", forceTCP);
s.setValue("enableLanDiscovery", enableLanDiscovery); s.setValue("enableLanDiscovery", enableLanDiscovery);
@ -864,7 +863,7 @@ void Settings::setEnableIPv6(bool enabled)
bool Settings::getMakeToxPortable() const bool Settings::getMakeToxPortable() const
{ {
QMutexLocker locker{&bigLock}; QMutexLocker locker{&bigLock};
return makeToxPortable; return paths.isPortable();
} }
void Settings::setMakeToxPortable(bool newValue) void Settings::setMakeToxPortable(bool newValue)
@ -872,16 +871,14 @@ void Settings::setMakeToxPortable(bool newValue)
bool changed = false; bool changed = false;
{ {
QMutexLocker locker{&bigLock}; QMutexLocker locker{&bigLock};
if (newValue != makeToxPortable) { auto const oldSettingsPath = paths.getSettingsDirPath() + globalSettingsFile;
QFile(paths.getSettingsDirPath() + globalSettingsFile).remove(); changed = paths.setPortable(newValue);
makeToxPortable = newValue; if (changed) {
changed = paths.setPortable(newValue); QFile(oldSettingsPath).remove();
saveGlobal(); saveGlobal();
emit makeToxPortableChanged(newValue);
} }
} }
if (changed) {
emit makeToxPortableChanged(newValue);
}
} }
bool Settings::getAutorun() const bool Settings::getAutorun() const

View File

@ -595,7 +595,6 @@ private:
bool showIdenticons; bool showIdenticons;
bool enableIPv6; bool enableIPv6;
QString translation; QString translation;
bool makeToxPortable;
bool autostartInTray; bool autostartInTray;
bool closeToTray; bool closeToTray;
bool minimizeToTray; bool minimizeToTray;