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

feat(settings): Moved proxy to personal settings

Fix #2465
This commit is contained in:
Diadlo 2016-07-14 00:01:50 +03:00
parent 9499bdd458
commit 4dfe3ec226
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727

View File

@ -136,10 +136,13 @@ void Settings::loadGlobal()
QSettings s(filePath, QSettings::IniFormat); QSettings s(filePath, QSettings::IniFormat);
s.setIniCodec("UTF-8"); s.setIniCodec("UTF-8");
s.beginGroup("Login"); s.beginGroup("Login");
{
autoLogin = s.value("autoLogin", false).toBool(); autoLogin = s.value("autoLogin", false).toBool();
}
s.endGroup(); s.endGroup();
s.beginGroup("DHT Server"); s.beginGroup("DHT Server");
{
if (s.value("useCustomList").toBool()) if (s.value("useCustomList").toBool())
{ {
useCustomDhtList = true; useCustomDhtList = true;
@ -159,21 +162,17 @@ void Settings::loadGlobal()
} }
else else
{ {
useCustomDhtList=false; useCustomDhtList = false;
}
} }
s.endGroup(); s.endGroup();
s.beginGroup("General"); s.beginGroup("General");
enableIPv6 = s.value("enableIPv6", true).toBool(); {
translation = s.value("translation", "en").toString(); translation = s.value("translation", "en").toString();
showSystemTray = s.value("showSystemTray", true).toBool(); showSystemTray = s.value("showSystemTray", true).toBool();
makeToxPortable = s.value("makeToxPortable", false).toBool();
autostartInTray = s.value("autostartInTray", false).toBool(); autostartInTray = s.value("autostartInTray", false).toBool();
closeToTray = s.value("closeToTray", false).toBool(); closeToTray = s.value("closeToTray", false).toBool();
forceTCP = s.value("forceTCP", false).toBool();
proxyType = static_cast<ProxyType>(s.value("proxyType", 0).toInt());
proxyAddr = s.value("proxyAddr", "").toString();
proxyPort = static_cast<quint16>(s.value("proxyPort", 0).toUInt());
if (currentProfile.isEmpty()) if (currentProfile.isEmpty())
{ {
currentProfile = s.value("currentProfile", "").toString(); currentProfile = s.value("currentProfile", "").toString();
@ -181,41 +180,51 @@ void Settings::loadGlobal()
} }
autoAwayTime = s.value("autoAwayTime", 10).toInt(); autoAwayTime = s.value("autoAwayTime", 10).toInt();
checkUpdates = s.value("checkUpdates", true).toBool(); checkUpdates = s.value("checkUpdates", true).toBool();
showWindow = s.value("showWindow", true).toBool();
showInFront = s.value("showInFront", false).toBool();
notifySound = s.value("notifySound", true).toBool(); notifySound = s.value("notifySound", true).toBool();
busySound = s.value("busySound", false).toBool(); busySound = s.value("busySound", false).toBool();
groupAlwaysNotify = s.value("groupAlwaysNotify", false).toBool();
fauxOfflineMessaging = s.value("fauxOfflineMessaging", true).toBool(); fauxOfflineMessaging = s.value("fauxOfflineMessaging", true).toBool();
autoSaveEnabled = s.value("autoSaveEnabled", false).toBool(); autoSaveEnabled = s.value("autoSaveEnabled", false).toBool();
globalAutoAcceptDir = s.value("globalAutoAcceptDir", globalAutoAcceptDir = s.value("globalAutoAcceptDir", QStandardPaths::locate(
QStandardPaths::locate(QStandardPaths::HomeLocation, QString(), QStandardPaths::LocateDirectory) QStandardPaths::HomeLocation,
).toString(); QString(),
separateWindow = s.value("separateWindow", false).toBool(); QStandardPaths::LocateDirectory)).toString();
dontGroupWindows = s.value("dontGroupWindows", true).toBool();
groupchatPosition = s.value("groupchatPosition", true).toBool();
stylePreference = static_cast<StyleType>(s.value("stylePreference", 1).toInt()); stylePreference = static_cast<StyleType>(s.value("stylePreference", 1).toInt());
}
s.endGroup(); s.endGroup();
s.beginGroup("Advanced"); s.beginGroup("Advanced");
Db::syncType sType = static_cast<Db::syncType>(s.value("dbSyncType", 2).toInt()); {
makeToxPortable = s.value("makeToxPortable", false).toBool();
enableIPv6 = s.value("enableIPv6", true).toBool();
forceTCP = s.value("forceTCP", false).toBool();
int type = s.value("dbSyncType", static_cast<int>(Db::syncType::stFull)).toInt();
Db::syncType sType = static_cast<Db::syncType>(type);
setDbSyncType(sType); setDbSyncType(sType);
}
s.endGroup(); s.endGroup();
s.beginGroup("Widgets"); s.beginGroup("Widgets");
{
QList<QString> objectNames = s.childKeys(); QList<QString> objectNames = s.childKeys();
for (const QString& name : objectNames) for (const QString& name : objectNames)
widgetSettings[name] = s.value(name).toByteArray(); widgetSettings[name] = s.value(name).toByteArray();
}
s.endGroup(); s.endGroup();
s.beginGroup("GUI"); s.beginGroup("GUI");
{
showWindow = s.value("showWindow", true).toBool();
showInFront = s.value("showInFront", false).toBool();
groupAlwaysNotify = s.value("groupAlwaysNotify", false).toBool();
groupchatPosition = s.value("groupchatPosition", true).toBool();
separateWindow = s.value("separateWindow", false).toBool();
dontGroupWindows = s.value("dontGroupWindows", true).toBool();
const QString DEFAULT_SMILEYS = ":/smileys/emojione/emoticons.xml"; const QString DEFAULT_SMILEYS = ":/smileys/emojione/emoticons.xml";
smileyPack = s.value("smileyPack", DEFAULT_SMILEYS).toString(); smileyPack = s.value("smileyPack", DEFAULT_SMILEYS).toString();
if (!SmileyPack::isValid(smileyPack)) if (!SmileyPack::isValid(smileyPack))
{
smileyPack = DEFAULT_SMILEYS; smileyPack = DEFAULT_SMILEYS;
}
emojiFontPointSize = s.value("emojiFontPointSize", 16).toInt(); emojiFontPointSize = s.value("emojiFontPointSize", 16).toInt();
firstColumnHandlePos = s.value("firstColumnHandlePos", 50).toInt(); firstColumnHandlePos = s.value("firstColumnHandlePos", 50).toInt();
secondColumnHandlePosFromRight = s.value("secondColumnHandlePosFromRight", 50).toInt(); secondColumnHandlePosFromRight = s.value("secondColumnHandlePosFromRight", 50).toInt();
@ -235,6 +244,7 @@ void Settings::loadGlobal()
else else
style = "None"; style = "None";
} }
}
s.endGroup(); s.endGroup();
s.beginGroup("Chat"); s.beginGroup("Chat");
@ -244,29 +254,35 @@ void Settings::loadGlobal()
s.endGroup(); s.endGroup();
s.beginGroup("State"); s.beginGroup("State");
{
windowGeometry = s.value("windowGeometry", QByteArray()).toByteArray(); windowGeometry = s.value("windowGeometry", QByteArray()).toByteArray();
windowState = s.value("windowState", QByteArray()).toByteArray(); windowState = s.value("windowState", QByteArray()).toByteArray();
splitterState = s.value("splitterState", QByteArray()).toByteArray(); splitterState = s.value("splitterState", QByteArray()).toByteArray();
dialogGeometry = s.value("dialogGeometry", QByteArray()).toByteArray(); dialogGeometry = s.value("dialogGeometry", QByteArray()).toByteArray();
dialogSplitterState = s.value("dialogSplitterState", QByteArray()).toByteArray(); dialogSplitterState = s.value("dialogSplitterState", QByteArray()).toByteArray();
dialogSettingsGeometry = s.value("dialogSettingsGeometry", QByteArray()).toByteArray(); dialogSettingsGeometry = s.value("dialogSettingsGeometry", QByteArray()).toByteArray();
}
s.endGroup(); s.endGroup();
s.beginGroup("Audio"); s.beginGroup("Audio");
{
inDev = s.value("inDev", "").toString(); inDev = s.value("inDev", "").toString();
audioInDevEnabled = s.value("audioInDevEnabled", true).toBool(); audioInDevEnabled = s.value("audioInDevEnabled", true).toBool();
outDev = s.value("outDev", "").toString(); outDev = s.value("outDev", "").toString();
audioOutDevEnabled = s.value("audioOutDevEnabled", true).toBool(); audioOutDevEnabled = s.value("audioOutDevEnabled", true).toBool();
audioInGainDecibel = s.value("inGain", 0).toReal(); audioInGainDecibel = s.value("inGain", 0).toReal();
outVolume = s.value("outVolume", 100).toInt(); outVolume = s.value("outVolume", 100).toInt();
}
s.endGroup(); s.endGroup();
s.beginGroup("Video"); s.beginGroup("Video");
{
videoDev = s.value("videoDev", "").toString(); videoDev = s.value("videoDev", "").toString();
camVideoRes = s.value("camVideoRes", QRect()).toRect(); camVideoRes = s.value("camVideoRes", QRect()).toRect();
screenRegion = s.value("screenRegion", QRect()).toRect(); screenRegion = s.value("screenRegion", QRect()).toRect();
screenGrabbed = s.value("screenGrabbed", false).toBool(); screenGrabbed = s.value("screenGrabbed", false).toBool();
camVideoFPS = static_cast<quint16>(s.value("camVideoFPS", 0).toUInt()); camVideoFPS = static_cast<quint16>(s.value("camVideoFPS", 0).toUInt());
}
s.endGroup(); s.endGroup();
// Read the embedded DHT bootstrap nodes list if needed // Read the embedded DHT bootstrap nodes list if needed
@ -323,11 +339,14 @@ void Settings::loadPersonal(Profile* profile)
friendLst.clear(); friendLst.clear();
ps.beginGroup("Privacy"); ps.beginGroup("Privacy");
{
typingNotification = ps.value("typingNotification", true).toBool(); typingNotification = ps.value("typingNotification", true).toBool();
enableLogging = ps.value("enableLogging", true).toBool(); enableLogging = ps.value("enableLogging", true).toBool();
}
ps.endGroup(); ps.endGroup();
ps.beginGroup("Friends"); ps.beginGroup("Friends");
{
int size = ps.beginReadArray("Friend"); int size = ps.beginReadArray("Friend");
friendLst.reserve(size); friendLst.reserve(size);
for (int i = 0; i < size; i ++) for (int i = 0; i < size; i ++)
@ -346,10 +365,12 @@ void Settings::loadPersonal(Profile* profile)
friendLst[ToxId(fp.addr).publicKey] = fp; friendLst[ToxId(fp.addr).publicKey] = fp;
} }
ps.endArray(); ps.endArray();
}
ps.endGroup(); ps.endGroup();
ps.beginGroup("Requests"); ps.beginGroup("Requests");
size = ps.beginReadArray("Request"); {
int size = ps.beginReadArray("Request");
friendRequests.clear(); friendRequests.clear();
friendRequests.reserve(size); friendRequests.reserve(size);
for (int i = 0; i < size; i ++) for (int i = 0; i < size; i ++)
@ -362,14 +383,26 @@ void Settings::loadPersonal(Profile* profile)
friendRequests.push_back(request); friendRequests.push_back(request);
} }
ps.endArray(); ps.endArray();
}
ps.endGroup(); ps.endGroup();
ps.beginGroup("General"); ps.beginGroup("GUI");
{
compactLayout = ps.value("compactLayout", true).toBool(); compactLayout = ps.value("compactLayout", true).toBool();
}
ps.endGroup();
ps.beginGroup("Proxy");
{
setProxyType(ps.value("proxyType", static_cast<int>(ProxyType::ptNone)).toInt());
proxyAddr = ps.value("proxyAddr", "").toString();
proxyPort = static_cast<quint16>(ps.value("proxyPort", 0).toUInt());
}
ps.endGroup(); ps.endGroup();
ps.beginGroup("Circles"); ps.beginGroup("Circles");
size = ps.beginReadArray("Circle"); {
int size = ps.beginReadArray("Circle");
circleLst.clear(); circleLst.clear();
circleLst.reserve(size); circleLst.reserve(size);
for (int i = 0; i < size; i ++) for (int i = 0; i < size; i ++)
@ -381,13 +414,16 @@ void Settings::loadPersonal(Profile* profile)
circleLst.push_back(cp); circleLst.push_back(cp);
} }
ps.endArray(); ps.endArray();
}
ps.endGroup(); ps.endGroup();
ps.beginGroup("Toxme"); ps.beginGroup("Toxme");
{
toxmeInfo = ps.value("info", "").toString(); toxmeInfo = ps.value("info", "").toString();
toxmeBio = ps.value("bio", "").toString(); toxmeBio = ps.value("bio", "").toString();
toxmePriv = ps.value("priv", false).toBool(); toxmePriv = ps.value("priv", false).toBool();
toxmePass = ps.value("pass", "").toString(); toxmePass = ps.value("pass", "").toString();
}
ps.endGroup(); ps.endGroup();
} }
@ -426,10 +462,13 @@ void Settings::saveGlobal()
s.clear(); s.clear();
s.beginGroup("Login"); s.beginGroup("Login");
{
s.setValue("autoLogin", autoLogin); s.setValue("autoLogin", autoLogin);
}
s.endGroup(); s.endGroup();
s.beginGroup("DHT Server"); s.beginGroup("DHT Server");
{
s.setValue("useCustomList", useCustomDhtList); s.setValue("useCustomList", useCustomDhtList);
s.beginWriteArray("dhtServerList", dhtServerList.size()); s.beginWriteArray("dhtServerList", dhtServerList.size());
for (int i = 0; i < dhtServerList.size(); i ++) for (int i = 0; i < dhtServerList.size(); i ++)
@ -441,47 +480,53 @@ void Settings::saveGlobal()
s.setValue("port", dhtServerList[i].port); s.setValue("port", dhtServerList[i].port);
} }
s.endArray(); s.endArray();
}
s.endGroup(); s.endGroup();
s.beginGroup("General"); s.beginGroup("General");
s.setValue("enableIPv6", enableIPv6); {
s.setValue("translation",translation); s.setValue("translation",translation);
s.setValue("makeToxPortable",makeToxPortable);
s.setValue("showSystemTray", showSystemTray); s.setValue("showSystemTray", showSystemTray);
s.setValue("autostartInTray",autostartInTray); s.setValue("autostartInTray",autostartInTray);
s.setValue("closeToTray", closeToTray); s.setValue("closeToTray", closeToTray);
s.setValue("proxyType", static_cast<int>(proxyType));
s.setValue("forceTCP", forceTCP);
s.setValue("proxyAddr", proxyAddr);
s.setValue("proxyPort", proxyPort);
s.setValue("currentProfile", currentProfile); s.setValue("currentProfile", currentProfile);
s.setValue("autoAwayTime", autoAwayTime); s.setValue("autoAwayTime", autoAwayTime);
s.setValue("checkUpdates", checkUpdates); s.setValue("checkUpdates", checkUpdates);
s.setValue("showWindow", showWindow);
s.setValue("showInFront", showInFront);
s.setValue("notifySound", notifySound); s.setValue("notifySound", notifySound);
s.setValue("busySound", busySound); s.setValue("busySound", busySound);
s.setValue("groupAlwaysNotify", groupAlwaysNotify);
s.setValue("fauxOfflineMessaging", fauxOfflineMessaging); s.setValue("fauxOfflineMessaging", fauxOfflineMessaging);
s.setValue("separateWindow", separateWindow);
s.setValue("dontGroupWindows", dontGroupWindows);
s.setValue("groupchatPosition", groupchatPosition);
s.setValue("autoSaveEnabled", autoSaveEnabled); s.setValue("autoSaveEnabled", autoSaveEnabled);
s.setValue("globalAutoAcceptDir", globalAutoAcceptDir); s.setValue("globalAutoAcceptDir", globalAutoAcceptDir);
s.setValue("stylePreference", static_cast<int>(stylePreference)); s.setValue("stylePreference", static_cast<int>(stylePreference));
}
s.endGroup(); s.endGroup();
s.beginGroup("Advanced"); s.beginGroup("Advanced");
{
s.setValue("makeToxPortable",makeToxPortable);
s.setValue("enableIPv6", enableIPv6);
s.setValue("forceTCP", forceTCP);
s.setValue("dbSyncType", static_cast<int>(dbSyncType)); s.setValue("dbSyncType", static_cast<int>(dbSyncType));
}
s.endGroup(); s.endGroup();
s.beginGroup("Widgets"); s.beginGroup("Widgets");
{
const QList<QString> widgetNames = widgetSettings.keys(); const QList<QString> widgetNames = widgetSettings.keys();
for (const QString& name : widgetNames) for (const QString& name : widgetNames)
s.setValue(name, widgetSettings.value(name)); s.setValue(name, widgetSettings.value(name));
}
s.endGroup(); s.endGroup();
s.beginGroup("GUI"); s.beginGroup("GUI");
{
s.setValue("showWindow", showWindow);
s.setValue("showInFront", showInFront);
s.setValue("groupAlwaysNotify", groupAlwaysNotify);
s.setValue("separateWindow", separateWindow);
s.setValue("dontGroupWindows", dontGroupWindows);
s.setValue("groupchatPosition", groupchatPosition);
s.setValue("smileyPack", smileyPack); s.setValue("smileyPack", smileyPack);
s.setValue("emojiFontPointSize", emojiFontPointSize); s.setValue("emojiFontPointSize", emojiFontPointSize);
s.setValue("firstColumnHandlePos", firstColumnHandlePos); s.setValue("firstColumnHandlePos", firstColumnHandlePos);
@ -495,6 +540,7 @@ void Settings::saveGlobal()
s.setValue("themeColor", themeColor); s.setValue("themeColor", themeColor);
s.setValue("style", style); s.setValue("style", style);
s.setValue("statusChangeNotificationEnabled", statusChangeNotificationEnabled); s.setValue("statusChangeNotificationEnabled", statusChangeNotificationEnabled);
}
s.endGroup(); s.endGroup();
s.beginGroup("Chat"); s.beginGroup("Chat");
@ -504,29 +550,35 @@ void Settings::saveGlobal()
s.endGroup(); s.endGroup();
s.beginGroup("State"); s.beginGroup("State");
{
s.setValue("windowGeometry", windowGeometry); s.setValue("windowGeometry", windowGeometry);
s.setValue("windowState", windowState); s.setValue("windowState", windowState);
s.setValue("splitterState", splitterState); s.setValue("splitterState", splitterState);
s.setValue("dialogGeometry", dialogGeometry); s.setValue("dialogGeometry", dialogGeometry);
s.setValue("dialogSplitterState", dialogSplitterState); s.setValue("dialogSplitterState", dialogSplitterState);
s.setValue("dialogSettingsGeometry", dialogSettingsGeometry); s.setValue("dialogSettingsGeometry", dialogSettingsGeometry);
}
s.endGroup(); s.endGroup();
s.beginGroup("Audio"); s.beginGroup("Audio");
{
s.setValue("inDev", inDev); s.setValue("inDev", inDev);
s.setValue("audioInDevEnabled", audioInDevEnabled); s.setValue("audioInDevEnabled", audioInDevEnabled);
s.setValue("outDev", outDev); s.setValue("outDev", outDev);
s.setValue("audioOutDevEnabled", audioOutDevEnabled); s.setValue("audioOutDevEnabled", audioOutDevEnabled);
s.setValue("inGain", audioInGainDecibel); s.setValue("inGain", audioInGainDecibel);
s.setValue("outVolume", outVolume); s.setValue("outVolume", outVolume);
}
s.endGroup(); s.endGroup();
s.beginGroup("Video"); s.beginGroup("Video");
{
s.setValue("videoDev", videoDev); s.setValue("videoDev", videoDev);
s.setValue("camVideoRes", camVideoRes); s.setValue("camVideoRes", camVideoRes);
s.setValue("camVideoFPS", camVideoFPS); s.setValue("camVideoFPS", camVideoFPS);
s.setValue("screenRegion", screenRegion); s.setValue("screenRegion", screenRegion);
s.setValue("screenGrabbed", screenGrabbed); s.setValue("screenGrabbed", screenGrabbed);
}
s.endGroup(); s.endGroup();
} }
@ -568,6 +620,7 @@ void Settings::savePersonal(QString profileName, const QString &password)
SettingsSerializer ps(path, password); SettingsSerializer ps(path, password);
ps.beginGroup("Friends"); ps.beginGroup("Friends");
{
ps.beginWriteArray("Friend", friendLst.size()); ps.beginWriteArray("Friend", friendLst.size());
int index = 0; int index = 0;
for (auto& frnd : friendLst) for (auto& frnd : friendLst)
@ -585,11 +638,13 @@ void Settings::savePersonal(QString profileName, const QString &password)
++index; ++index;
} }
ps.endArray(); ps.endArray();
}
ps.endGroup(); ps.endGroup();
ps.beginGroup("Requests"); ps.beginGroup("Requests");
{
ps.beginWriteArray("Request", friendRequests.size()); ps.beginWriteArray("Request", friendRequests.size());
index = 0; int index = 0;
for (auto& request : friendRequests) for (auto& request : friendRequests)
{ {
ps.setArrayIndex(index); ps.setArrayIndex(index);
@ -600,15 +655,27 @@ void Settings::savePersonal(QString profileName, const QString &password)
++index; ++index;
} }
ps.endArray(); ps.endArray();
}
ps.endGroup(); ps.endGroup();
ps.beginGroup("General"); ps.beginGroup("GUI");
{
ps.setValue("compactLayout", compactLayout); ps.setValue("compactLayout", compactLayout);
}
ps.endGroup();
ps.beginGroup("Proxy");
{
ps.setValue("proxyType", static_cast<int>(proxyType));
ps.setValue("proxyAddr", proxyAddr);
ps.setValue("proxyPort", proxyPort);
}
ps.endGroup(); ps.endGroup();
ps.beginGroup("Circles"); ps.beginGroup("Circles");
{
ps.beginWriteArray("Circle", circleLst.size()); ps.beginWriteArray("Circle", circleLst.size());
index = 0; int index = 0;
for (auto& circle : circleLst) for (auto& circle : circleLst)
{ {
ps.setArrayIndex(index); ps.setArrayIndex(index);
@ -617,18 +684,23 @@ void Settings::savePersonal(QString profileName, const QString &password)
index++; index++;
} }
ps.endArray(); ps.endArray();
}
ps.endGroup(); ps.endGroup();
ps.beginGroup("Privacy"); ps.beginGroup("Privacy");
{
ps.setValue("typingNotification", typingNotification); ps.setValue("typingNotification", typingNotification);
ps.setValue("enableLogging", enableLogging); ps.setValue("enableLogging", enableLogging);
}
ps.endGroup(); ps.endGroup();
ps.beginGroup("Toxme"); ps.beginGroup("Toxme");
{
ps.setValue("info", toxmeInfo); ps.setValue("info", toxmeInfo);
ps.setValue("bio", toxmeBio); ps.setValue("bio", toxmeBio);
ps.setValue("priv", toxmePriv); ps.setValue("priv", toxmePriv);
ps.setValue("pass", toxmePass); ps.setValue("pass", toxmePass);
}
ps.endGroup(); ps.endGroup();
ps.save(); ps.save();