2014-06-25 04:11:11 +08:00
|
|
|
/*
|
|
|
|
Copyright (C) 2013 by Maxim Biro <nurupo.contributions@gmail.com>
|
2015-06-06 09:40:08 +08:00
|
|
|
Copyright © 2014-2015 by The qTox Project
|
2014-10-08 22:17:05 +08:00
|
|
|
|
2015-06-06 09:40:08 +08:00
|
|
|
This file is part of qTox, a Qt-based graphical interface for Tox.
|
2014-10-08 22:17:05 +08:00
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
2015-06-06 09:40:08 +08:00
|
|
|
|
|
|
|
qTox is distributed in the hope that it will be useful,
|
2014-06-25 04:11:11 +08:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2015-06-06 09:40:08 +08:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2014-10-08 22:17:05 +08:00
|
|
|
|
2015-06-06 09:40:08 +08:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with qTox. If not, see <http://www.gnu.org/licenses/>.
|
2014-06-25 04:11:11 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "settings.h"
|
2015-06-06 07:44:47 +08:00
|
|
|
#include "src/persistence/smileypack.h"
|
|
|
|
#include "src/persistence/db/plaindb.h"
|
2015-04-24 08:32:09 +08:00
|
|
|
#include "src/core/corestructs.h"
|
|
|
|
#include "src/core/core.h"
|
2015-02-06 19:28:49 +08:00
|
|
|
#include "src/widget/gui.h"
|
2015-06-06 07:44:47 +08:00
|
|
|
#include "src/persistence/profilelocker.h"
|
2015-06-06 21:54:58 +08:00
|
|
|
#include "src/persistence/settingsserializer.h"
|
|
|
|
#include "src/nexus.h"
|
|
|
|
#include "src/persistence/profile.h"
|
2014-12-17 21:44:23 +08:00
|
|
|
#ifdef QTOX_PLATFORM_EXT
|
|
|
|
#include "src/platform/autorun.h"
|
|
|
|
#endif
|
2015-02-21 20:49:27 +08:00
|
|
|
#include "src/ipc.h"
|
2014-06-25 04:11:11 +08:00
|
|
|
|
2014-09-11 21:44:34 +08:00
|
|
|
#include <QFont>
|
2014-06-25 04:11:11 +08:00
|
|
|
#include <QApplication>
|
|
|
|
#include <QDir>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QStandardPaths>
|
2014-06-26 19:09:08 +08:00
|
|
|
#include <QDebug>
|
2014-08-01 20:46:28 +08:00
|
|
|
#include <QList>
|
2014-11-09 08:10:06 +08:00
|
|
|
#include <QStyleFactory>
|
2015-02-20 20:26:41 +08:00
|
|
|
#include <QCryptographicHash>
|
2015-06-05 22:27:15 +08:00
|
|
|
#include <QMutexLocker>
|
2015-06-06 00:01:50 +08:00
|
|
|
#include <QThread>
|
2014-06-25 04:11:11 +08:00
|
|
|
|
2014-11-17 23:35:30 +08:00
|
|
|
#define SHOW_SYSTEM_TRAY_DEFAULT (bool) true
|
|
|
|
|
2015-06-04 20:19:18 +08:00
|
|
|
const QString Settings::globalSettingsFile = "qtox.ini";
|
2014-12-03 08:26:17 +08:00
|
|
|
Settings* Settings::settings{nullptr};
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutex Settings::bigLock{QMutex::Recursive};
|
2015-06-06 00:01:50 +08:00
|
|
|
QThread* Settings::settingsThread{nullptr};
|
2014-06-25 04:11:11 +08:00
|
|
|
|
|
|
|
Settings::Settings() :
|
2015-06-05 22:24:47 +08:00
|
|
|
loaded(false), useCustomDhtList{false},
|
|
|
|
makeToxPortable{false}, currentProfileId(0)
|
2014-06-25 04:11:11 +08:00
|
|
|
{
|
2015-06-06 00:01:50 +08:00
|
|
|
settingsThread = new QThread();
|
|
|
|
settingsThread->setObjectName("qTox Settings");
|
|
|
|
settingsThread->start(QThread::LowPriority);
|
|
|
|
moveToThread(settingsThread);
|
2015-06-06 21:54:58 +08:00
|
|
|
loadGlobal();
|
2014-06-25 04:11:11 +08:00
|
|
|
}
|
|
|
|
|
2015-06-06 00:01:50 +08:00
|
|
|
Settings::~Settings()
|
|
|
|
{
|
|
|
|
sync();
|
|
|
|
settingsThread->exit(0);
|
|
|
|
settingsThread->wait();
|
|
|
|
delete settingsThread;
|
|
|
|
}
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
Settings& Settings::getInstance()
|
|
|
|
{
|
2014-11-12 06:21:16 +08:00
|
|
|
if (!settings)
|
|
|
|
settings = new Settings();
|
2015-04-24 19:01:50 +08:00
|
|
|
|
2014-11-12 06:21:16 +08:00
|
|
|
return *settings;
|
2014-06-25 04:11:11 +08:00
|
|
|
}
|
|
|
|
|
2015-06-06 00:01:50 +08:00
|
|
|
void Settings::destroyInstance()
|
|
|
|
{
|
|
|
|
delete settings;
|
|
|
|
settings = nullptr;
|
|
|
|
}
|
|
|
|
|
2015-06-06 21:54:58 +08:00
|
|
|
void Settings::loadGlobal()
|
2014-06-25 04:11:11 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
|
2014-12-03 06:47:55 +08:00
|
|
|
if (loaded)
|
2014-06-25 04:11:11 +08:00
|
|
|
return;
|
|
|
|
|
2015-06-04 20:19:18 +08:00
|
|
|
createSettingsDir();
|
2015-04-27 08:48:16 +08:00
|
|
|
|
2015-06-04 20:19:18 +08:00
|
|
|
if (QFile(globalSettingsFile).exists())
|
2014-09-05 05:11:46 +08:00
|
|
|
{
|
2015-06-04 20:19:18 +08:00
|
|
|
QSettings ps(globalSettingsFile, QSettings::IniFormat);
|
2014-12-03 06:47:55 +08:00
|
|
|
ps.beginGroup("General");
|
|
|
|
makeToxPortable = ps.value("makeToxPortable", false).toBool();
|
|
|
|
ps.endGroup();
|
|
|
|
}
|
2014-09-05 05:11:46 +08:00
|
|
|
else
|
2015-04-24 19:01:50 +08:00
|
|
|
{
|
2014-09-05 05:11:46 +08:00
|
|
|
makeToxPortable = false;
|
2015-04-24 19:01:50 +08:00
|
|
|
}
|
2014-07-13 04:58:58 +08:00
|
|
|
|
2015-09-06 01:20:09 +08:00
|
|
|
QDir dir(getSettingsDirPath());
|
2015-06-04 20:19:18 +08:00
|
|
|
QString filePath = dir.filePath(globalSettingsFile);
|
2014-06-25 04:11:11 +08:00
|
|
|
|
2015-06-04 20:19:18 +08:00
|
|
|
// If no settings file exist -- use the default one
|
2014-12-03 06:47:55 +08:00
|
|
|
if (!QFile(filePath).exists())
|
|
|
|
{
|
2015-06-04 20:19:18 +08:00
|
|
|
qDebug() << "No settings file found, using defaults";
|
|
|
|
filePath = ":/conf/" + globalSettingsFile;
|
2014-06-25 04:11:11 +08:00
|
|
|
}
|
|
|
|
|
2015-05-11 20:54:03 +08:00
|
|
|
qDebug() << "Loading settings from " + filePath;
|
2014-09-05 05:13:59 +08:00
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
QSettings s(filePath, QSettings::IniFormat);
|
2015-06-05 21:24:02 +08:00
|
|
|
s.beginGroup("Login");
|
|
|
|
autoLogin = s.value("autoLogin", false).toBool();
|
|
|
|
s.endGroup();
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
s.beginGroup("DHT Server");
|
2014-09-05 05:13:59 +08:00
|
|
|
if (s.value("useCustomList").toBool())
|
|
|
|
{
|
|
|
|
useCustomDhtList = true;
|
|
|
|
qDebug() << "Using custom bootstrap nodes list";
|
|
|
|
int serverListSize = s.beginReadArray("dhtServerList");
|
2015-04-24 19:01:50 +08:00
|
|
|
for (int i = 0; i < serverListSize; i ++)
|
|
|
|
{
|
2014-09-05 05:13:59 +08:00
|
|
|
s.setArrayIndex(i);
|
|
|
|
DhtServer server;
|
|
|
|
server.name = s.value("name").toString();
|
|
|
|
server.userId = s.value("userId").toString();
|
|
|
|
server.address = s.value("address").toString();
|
|
|
|
server.port = s.value("port").toInt();
|
|
|
|
dhtServerList << server;
|
|
|
|
}
|
|
|
|
s.endArray();
|
2014-06-25 04:11:11 +08:00
|
|
|
}
|
2014-09-05 05:13:59 +08:00
|
|
|
else
|
2015-04-24 19:01:50 +08:00
|
|
|
{
|
2014-09-05 05:13:59 +08:00
|
|
|
useCustomDhtList=false;
|
2015-04-24 19:01:50 +08:00
|
|
|
}
|
2014-06-25 04:11:11 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
|
|
|
s.beginGroup("General");
|
2014-07-02 06:47:06 +08:00
|
|
|
enableIPv6 = s.value("enableIPv6", true).toBool();
|
2014-11-06 06:34:28 +08:00
|
|
|
translation = s.value("translation", "en").toString();
|
2014-11-17 23:35:30 +08:00
|
|
|
showSystemTray = s.value("showSystemTray", SHOW_SYSTEM_TRAY_DEFAULT).toBool();
|
2014-07-13 04:58:58 +08:00
|
|
|
makeToxPortable = s.value("makeToxPortable", false).toBool();
|
2014-10-08 22:17:05 +08:00
|
|
|
autostartInTray = s.value("autostartInTray", false).toBool();
|
2015-06-05 22:27:15 +08:00
|
|
|
closeToTray = s.value("closeToTray", false).toBool();
|
2014-10-07 10:16:06 +08:00
|
|
|
forceTCP = s.value("forceTCP", false).toBool();
|
2014-12-28 21:04:32 +08:00
|
|
|
setProxyType(s.value("proxyType", static_cast<int>(ProxyType::ptNone)).toInt());
|
2014-10-07 10:16:06 +08:00
|
|
|
proxyAddr = s.value("proxyAddr", "").toString();
|
|
|
|
proxyPort = s.value("proxyPort", 0).toInt();
|
2015-04-25 01:35:06 +08:00
|
|
|
if (currentProfile.isEmpty())
|
|
|
|
{
|
|
|
|
currentProfile = s.value("currentProfile", "").toString();
|
|
|
|
currentProfileId = makeProfileId(currentProfile);
|
|
|
|
}
|
2014-11-12 20:56:24 +08:00
|
|
|
autoAwayTime = s.value("autoAwayTime", 10).toInt();
|
2014-11-10 07:31:29 +08:00
|
|
|
checkUpdates = s.value("checkUpdates", false).toBool();
|
2015-01-21 19:10:41 +08:00
|
|
|
showWindow = s.value("showWindow", true).toBool();
|
2014-11-10 08:23:41 +08:00
|
|
|
showInFront = s.value("showInFront", false).toBool();
|
2015-03-22 08:57:28 +08:00
|
|
|
notifySound = s.value("notifySound", true).toBool();
|
2015-01-21 19:10:41 +08:00
|
|
|
groupAlwaysNotify = s.value("groupAlwaysNotify", false).toBool();
|
2014-11-11 06:45:09 +08:00
|
|
|
fauxOfflineMessaging = s.value("fauxOfflineMessaging", true).toBool();
|
2014-11-17 18:10:38 +08:00
|
|
|
autoSaveEnabled = s.value("autoSaveEnabled", false).toBool();
|
|
|
|
globalAutoAcceptDir = s.value("globalAutoAcceptDir",
|
|
|
|
QStandardPaths::locate(QStandardPaths::HomeLocation, QString(), QStandardPaths::LocateDirectory)
|
|
|
|
).toString();
|
2015-06-17 02:25:19 +08:00
|
|
|
separateWindow = s.value("separateWindow", false).toBool();
|
2015-07-01 00:29:09 +08:00
|
|
|
dontGroupWindows = s.value("dontGroupWindows", true).toBool();
|
2015-03-12 08:41:18 +08:00
|
|
|
groupchatPosition = s.value("groupchatPosition", true).toBool();
|
2014-06-25 04:11:11 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
2014-11-12 20:56:24 +08:00
|
|
|
s.beginGroup("Advanced");
|
|
|
|
int sType = s.value("dbSyncType", static_cast<int>(Db::syncType::stFull)).toInt();
|
|
|
|
setDbSyncType(sType);
|
|
|
|
s.endGroup();
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
s.beginGroup("Widgets");
|
|
|
|
QList<QString> objectNames = s.childKeys();
|
2015-04-24 19:01:50 +08:00
|
|
|
for (const QString& name : objectNames)
|
2014-06-25 04:11:11 +08:00
|
|
|
widgetSettings[name] = s.value(name).toByteArray();
|
2015-04-24 19:01:50 +08:00
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
|
|
|
s.beginGroup("GUI");
|
2015-02-08 06:22:45 +08:00
|
|
|
smileyPack = s.value("smileyPack", ":/smileys/TwitterEmojiSVG/emoticons.xml").toString();
|
|
|
|
emojiFontPointSize = s.value("emojiFontPointSize", 16).toInt();
|
2014-06-25 04:11:11 +08:00
|
|
|
firstColumnHandlePos = s.value("firstColumnHandlePos", 50).toInt();
|
|
|
|
secondColumnHandlePosFromRight = s.value("secondColumnHandlePosFromRight", 50).toInt();
|
2015-03-26 00:45:28 +08:00
|
|
|
timestampFormat = s.value("timestampFormat", "hh:mm:ss").toString();
|
|
|
|
dateFormat = s.value("dateFormat", "dddd, MMMM d, yyyy").toString();
|
2014-06-25 04:11:11 +08:00
|
|
|
minimizeOnClose = s.value("minimizeOnClose", false).toBool();
|
2014-10-20 19:50:12 +08:00
|
|
|
minimizeToTray = s.value("minimizeToTray", false).toBool();
|
2014-12-12 03:34:12 +08:00
|
|
|
lightTrayIcon = s.value("lightTrayIcon", false).toBool();
|
2014-11-05 23:20:32 +08:00
|
|
|
useEmoticons = s.value("useEmoticons", true).toBool();
|
2014-10-11 07:18:32 +08:00
|
|
|
statusChangeNotificationEnabled = s.value("statusChangeNotificationEnabled", false).toBool();
|
2014-11-16 04:30:20 +08:00
|
|
|
themeColor = s.value("themeColor", 0).toInt();
|
2014-11-09 08:10:06 +08:00
|
|
|
style = s.value("style", "").toString();
|
|
|
|
if (style == "") // Default to Fusion if available, otherwise no style
|
|
|
|
{
|
|
|
|
if (QStyleFactory::keys().contains("Fusion"))
|
|
|
|
style = "Fusion";
|
|
|
|
else
|
|
|
|
style = "None";
|
|
|
|
}
|
2014-08-11 23:33:32 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
|
|
|
s.beginGroup("State");
|
2014-08-11 16:00:08 +08:00
|
|
|
windowGeometry = s.value("windowGeometry", QByteArray()).toByteArray();
|
|
|
|
windowState = s.value("windowState", QByteArray()).toByteArray();
|
2014-08-11 20:07:27 +08:00
|
|
|
splitterState = s.value("splitterState", QByteArray()).toByteArray();
|
2015-06-19 22:58:48 +08:00
|
|
|
dialogGeometry = s.value("dialogGeometry", QByteArray()).toByteArray();
|
|
|
|
dialogSplitterState = s.value("dialogSplitterState", QByteArray()).toByteArray();
|
2014-06-25 04:11:11 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
2014-10-29 04:21:37 +08:00
|
|
|
s.beginGroup("Audio");
|
|
|
|
inDev = s.value("inDev", "").toString();
|
|
|
|
outDev = s.value("outDev", "").toString();
|
2014-12-14 16:50:18 +08:00
|
|
|
filterAudio = s.value("filterAudio", false).toBool();
|
2014-10-29 04:21:37 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
2015-01-24 09:03:26 +08:00
|
|
|
s.beginGroup("Video");
|
2015-05-14 10:46:28 +08:00
|
|
|
videoDev = s.value("videoDev", "").toString();
|
2015-01-24 09:03:26 +08:00
|
|
|
camVideoRes = s.value("camVideoRes",QSize()).toSize();
|
|
|
|
s.endGroup();
|
|
|
|
|
2014-09-05 05:13:59 +08:00
|
|
|
// Read the embedded DHT bootsrap nodes list if needed
|
|
|
|
if (dhtServerList.isEmpty())
|
|
|
|
{
|
|
|
|
QSettings rcs(":/conf/settings.ini", QSettings::IniFormat);
|
|
|
|
rcs.beginGroup("DHT Server");
|
|
|
|
int serverListSize = rcs.beginReadArray("dhtServerList");
|
2015-04-24 19:01:50 +08:00
|
|
|
for (int i = 0; i < serverListSize; i ++)
|
|
|
|
{
|
2014-09-05 05:13:59 +08:00
|
|
|
rcs.setArrayIndex(i);
|
|
|
|
DhtServer server;
|
|
|
|
server.name = rcs.value("name").toString();
|
|
|
|
server.userId = rcs.value("userId").toString();
|
|
|
|
server.address = rcs.value("address").toString();
|
|
|
|
server.port = rcs.value("port").toInt();
|
|
|
|
dhtServerList << server;
|
|
|
|
}
|
|
|
|
rcs.endArray();
|
|
|
|
rcs.endGroup();
|
|
|
|
}
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
loaded = true;
|
2015-06-06 21:54:58 +08:00
|
|
|
}
|
2014-12-03 08:26:17 +08:00
|
|
|
|
2015-06-06 21:54:58 +08:00
|
|
|
void Settings::loadPersonnal()
|
|
|
|
{
|
|
|
|
Profile* profile = Nexus::getProfile();
|
|
|
|
if (!profile)
|
2014-12-06 11:13:04 +08:00
|
|
|
{
|
2015-06-06 21:54:58 +08:00
|
|
|
qCritical() << "No active profile, couldn't load personnal settings";
|
|
|
|
return;
|
2014-12-06 11:13:04 +08:00
|
|
|
}
|
2015-06-06 21:54:58 +08:00
|
|
|
loadPersonnal(profile);
|
2014-06-25 04:11:11 +08:00
|
|
|
}
|
|
|
|
|
2015-06-06 21:54:58 +08:00
|
|
|
void Settings::loadPersonnal(Profile* profile)
|
2014-06-25 04:11:11 +08:00
|
|
|
{
|
2015-06-06 21:54:58 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2015-06-06 00:01:50 +08:00
|
|
|
|
2015-06-06 21:54:58 +08:00
|
|
|
QDir dir(getSettingsDirPath());
|
|
|
|
QString filePath = dir.filePath(globalSettingsFile);
|
2014-06-25 04:11:11 +08:00
|
|
|
|
2015-06-06 21:54:58 +08:00
|
|
|
// load from a profile specific friend data list if possible
|
|
|
|
QString tmp = dir.filePath(profile->getName() + ".ini");
|
|
|
|
if (QFile(tmp).exists()) // otherwise, filePath remains the global file
|
|
|
|
filePath = tmp;
|
2015-06-06 00:01:50 +08:00
|
|
|
|
2015-06-06 21:54:58 +08:00
|
|
|
qDebug()<<"Loading personnal settings from"<<filePath;
|
|
|
|
|
|
|
|
SettingsSerializer ps(filePath, profile->getPassword());
|
2015-06-07 07:13:07 +08:00
|
|
|
ps.load();
|
2015-06-06 21:54:58 +08:00
|
|
|
friendLst.clear();
|
|
|
|
ps.beginGroup("Friends");
|
|
|
|
int size = ps.beginReadArray("Friend");
|
2015-05-31 03:10:43 +08:00
|
|
|
friendLst.reserve(size);
|
2015-06-06 21:54:58 +08:00
|
|
|
for (int i = 0; i < size; i ++)
|
|
|
|
{
|
|
|
|
ps.setArrayIndex(i);
|
|
|
|
friendProp fp;
|
|
|
|
fp.addr = ps.value("addr").toString();
|
|
|
|
fp.alias = ps.value("alias").toString();
|
|
|
|
fp.autoAcceptDir = ps.value("autoAcceptDir").toString();
|
2015-06-06 03:34:32 +08:00
|
|
|
fp.circleID = ps.value("circle", -1).toInt();
|
2015-06-25 23:55:06 +08:00
|
|
|
|
|
|
|
if (getEnableLogging())
|
|
|
|
fp.activity = ps.value("activity", QDate()).toDate();
|
2015-06-18 23:27:50 +08:00
|
|
|
|
2015-06-06 21:54:58 +08:00
|
|
|
friendLst[ToxId(fp.addr).publicKey] = fp;
|
|
|
|
}
|
|
|
|
ps.endArray();
|
|
|
|
ps.endGroup();
|
2015-02-21 20:49:27 +08:00
|
|
|
|
2015-06-07 07:00:24 +08:00
|
|
|
ps.beginGroup("General");
|
2015-08-31 18:47:09 +08:00
|
|
|
compactLayout = ps.value("compactLayout", true).toBool();
|
2015-06-07 07:00:24 +08:00
|
|
|
ps.endGroup();
|
|
|
|
|
2015-05-31 03:10:43 +08:00
|
|
|
ps.beginGroup("Circles");
|
|
|
|
size = ps.beginReadArray("Circle");
|
2015-06-28 03:32:11 +08:00
|
|
|
circleLst.clear();
|
2015-05-31 03:10:43 +08:00
|
|
|
circleLst.reserve(size);
|
|
|
|
for (int i = 0; i < size; i ++)
|
|
|
|
{
|
|
|
|
ps.setArrayIndex(i);
|
2015-06-04 04:18:40 +08:00
|
|
|
circleProp cp;
|
|
|
|
cp.name = ps.value("name").toString();
|
|
|
|
cp.expanded = ps.value("expanded", true).toBool();
|
|
|
|
circleLst.push_back(cp);
|
2015-05-31 03:10:43 +08:00
|
|
|
}
|
|
|
|
ps.endArray();
|
|
|
|
ps.endGroup();
|
|
|
|
|
2015-06-06 21:54:58 +08:00
|
|
|
ps.beginGroup("Privacy");
|
2015-08-31 18:47:09 +08:00
|
|
|
typingNotification = ps.value("typingNotification", true).toBool();
|
|
|
|
enableLogging = ps.value("enableLogging", true).toBool();
|
2015-06-06 21:54:58 +08:00
|
|
|
ps.endGroup();
|
2015-02-21 20:49:27 +08:00
|
|
|
}
|
|
|
|
|
2015-06-06 21:54:58 +08:00
|
|
|
void Settings::saveGlobal()
|
2015-02-21 20:49:27 +08:00
|
|
|
{
|
2015-06-06 21:54:58 +08:00
|
|
|
if (QThread::currentThread() != settingsThread)
|
|
|
|
return (void) QMetaObject::invokeMethod(&getInstance(), "saveGlobal");
|
|
|
|
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2015-06-06 21:54:58 +08:00
|
|
|
QString path = getSettingsDirPath() + globalSettingsFile;
|
|
|
|
qDebug() << "Saving global settings at " + path;
|
2014-09-05 05:13:59 +08:00
|
|
|
|
2014-07-13 04:58:58 +08:00
|
|
|
QSettings s(path, QSettings::IniFormat);
|
2014-06-25 04:11:11 +08:00
|
|
|
|
|
|
|
s.clear();
|
|
|
|
|
2015-06-05 21:24:02 +08:00
|
|
|
s.beginGroup("Login");
|
|
|
|
s.setValue("autoLogin", autoLogin);
|
|
|
|
s.endGroup();
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
s.beginGroup("DHT Server");
|
2014-09-05 05:13:59 +08:00
|
|
|
s.setValue("useCustomList", useCustomDhtList);
|
2014-06-25 04:11:11 +08:00
|
|
|
s.beginWriteArray("dhtServerList", dhtServerList.size());
|
2015-04-24 19:01:50 +08:00
|
|
|
for (int i = 0; i < dhtServerList.size(); i ++)
|
|
|
|
{
|
2014-06-25 04:11:11 +08:00
|
|
|
s.setArrayIndex(i);
|
|
|
|
s.setValue("name", dhtServerList[i].name);
|
|
|
|
s.setValue("userId", dhtServerList[i].userId);
|
|
|
|
s.setValue("address", dhtServerList[i].address);
|
|
|
|
s.setValue("port", dhtServerList[i].port);
|
|
|
|
}
|
|
|
|
s.endArray();
|
|
|
|
s.endGroup();
|
|
|
|
|
|
|
|
s.beginGroup("General");
|
2014-07-02 06:47:06 +08:00
|
|
|
s.setValue("enableIPv6", enableIPv6);
|
2014-10-18 07:06:30 +08:00
|
|
|
s.setValue("translation",translation);
|
2014-07-13 04:58:58 +08:00
|
|
|
s.setValue("makeToxPortable",makeToxPortable);
|
2014-11-14 04:33:11 +08:00
|
|
|
s.setValue("showSystemTray", showSystemTray);
|
2014-10-08 22:17:05 +08:00
|
|
|
s.setValue("autostartInTray",autostartInTray);
|
2014-10-20 03:47:06 +08:00
|
|
|
s.setValue("closeToTray", closeToTray);
|
2014-12-28 20:32:25 +08:00
|
|
|
s.setValue("proxyType", static_cast<int>(proxyType));
|
2014-10-07 10:16:06 +08:00
|
|
|
s.setValue("forceTCP", forceTCP);
|
|
|
|
s.setValue("proxyAddr", proxyAddr);
|
|
|
|
s.setValue("proxyPort", proxyPort);
|
2014-07-17 06:43:30 +08:00
|
|
|
s.setValue("currentProfile", currentProfile);
|
2014-10-16 17:47:58 +08:00
|
|
|
s.setValue("autoAwayTime", autoAwayTime);
|
2014-11-10 07:31:29 +08:00
|
|
|
s.setValue("checkUpdates", checkUpdates);
|
2015-01-21 19:10:41 +08:00
|
|
|
s.setValue("showWindow", showWindow);
|
2014-11-10 08:23:41 +08:00
|
|
|
s.setValue("showInFront", showInFront);
|
2015-03-22 08:57:28 +08:00
|
|
|
s.setValue("notifySound", notifySound);
|
2015-01-21 19:10:41 +08:00
|
|
|
s.setValue("groupAlwaysNotify", groupAlwaysNotify);
|
2014-11-10 21:06:35 +08:00
|
|
|
s.setValue("fauxOfflineMessaging", fauxOfflineMessaging);
|
2015-06-17 02:25:19 +08:00
|
|
|
s.setValue("separateWindow", separateWindow);
|
2015-06-19 22:58:48 +08:00
|
|
|
s.setValue("dontGroupWindows", dontGroupWindows);
|
2015-03-12 08:41:18 +08:00
|
|
|
s.setValue("groupchatPosition", groupchatPosition);
|
2014-11-17 18:10:38 +08:00
|
|
|
s.setValue("autoSaveEnabled", autoSaveEnabled);
|
|
|
|
s.setValue("globalAutoAcceptDir", globalAutoAcceptDir);
|
2014-06-25 04:11:11 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
2014-11-12 20:56:24 +08:00
|
|
|
s.beginGroup("Advanced");
|
|
|
|
s.setValue("dbSyncType", static_cast<int>(dbSyncType));
|
|
|
|
s.endGroup();
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
s.beginGroup("Widgets");
|
|
|
|
const QList<QString> widgetNames = widgetSettings.keys();
|
2015-04-24 19:01:50 +08:00
|
|
|
for (const QString& name : widgetNames)
|
2014-06-25 04:11:11 +08:00
|
|
|
s.setValue(name, widgetSettings.value(name));
|
|
|
|
s.endGroup();
|
|
|
|
|
|
|
|
s.beginGroup("GUI");
|
|
|
|
s.setValue("smileyPack", smileyPack);
|
|
|
|
s.setValue("emojiFontPointSize", emojiFontPointSize);
|
|
|
|
s.setValue("firstColumnHandlePos", firstColumnHandlePos);
|
|
|
|
s.setValue("secondColumnHandlePosFromRight", secondColumnHandlePosFromRight);
|
|
|
|
s.setValue("timestampFormat", timestampFormat);
|
2015-03-15 04:15:56 +08:00
|
|
|
s.setValue("dateFormat", dateFormat);
|
2014-06-25 04:11:11 +08:00
|
|
|
s.setValue("minimizeOnClose", minimizeOnClose);
|
2014-10-20 19:50:12 +08:00
|
|
|
s.setValue("minimizeToTray", minimizeToTray);
|
2014-12-12 03:34:12 +08:00
|
|
|
s.setValue("lightTrayIcon", lightTrayIcon);
|
2014-11-05 23:20:32 +08:00
|
|
|
s.setValue("useEmoticons", useEmoticons);
|
2014-11-16 04:30:20 +08:00
|
|
|
s.setValue("themeColor", themeColor);
|
2014-11-05 23:20:32 +08:00
|
|
|
s.setValue("style", style);
|
2014-10-11 07:18:32 +08:00
|
|
|
s.setValue("statusChangeNotificationEnabled", statusChangeNotificationEnabled);
|
2014-08-11 23:33:32 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
|
|
|
s.beginGroup("State");
|
2014-08-11 16:00:08 +08:00
|
|
|
s.setValue("windowGeometry", windowGeometry);
|
|
|
|
s.setValue("windowState", windowState);
|
2014-08-11 20:07:27 +08:00
|
|
|
s.setValue("splitterState", splitterState);
|
2014-06-25 04:11:11 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
2014-10-29 04:21:37 +08:00
|
|
|
s.beginGroup("Audio");
|
|
|
|
s.setValue("inDev", inDev);
|
|
|
|
s.setValue("outDev", outDev);
|
2014-12-14 16:50:18 +08:00
|
|
|
s.setValue("filterAudio", filterAudio);
|
2014-10-29 04:21:37 +08:00
|
|
|
s.endGroup();
|
2014-12-03 08:26:17 +08:00
|
|
|
|
2015-01-24 09:03:26 +08:00
|
|
|
s.beginGroup("Video");
|
2015-05-14 10:46:28 +08:00
|
|
|
s.setValue("videoDev", videoDev);
|
2015-01-24 09:03:26 +08:00
|
|
|
s.setValue("camVideoRes",camVideoRes);
|
|
|
|
s.endGroup();
|
2015-02-21 20:49:27 +08:00
|
|
|
}
|
2015-01-24 09:03:26 +08:00
|
|
|
|
2015-06-06 21:54:58 +08:00
|
|
|
void Settings::savePersonal()
|
2015-02-21 20:49:27 +08:00
|
|
|
{
|
2015-06-06 21:54:58 +08:00
|
|
|
savePersonal(Nexus::getProfile());
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::savePersonal(Profile* profile)
|
|
|
|
{
|
|
|
|
if (!profile)
|
2014-12-06 11:13:04 +08:00
|
|
|
{
|
2015-06-06 21:54:58 +08:00
|
|
|
qDebug() << "Could not save personal settings because there is no active profile";
|
2015-02-21 20:49:27 +08:00
|
|
|
return;
|
2014-12-06 11:13:04 +08:00
|
|
|
}
|
2015-06-06 21:54:58 +08:00
|
|
|
savePersonal(profile->getName(), profile->getPassword());
|
|
|
|
}
|
2015-02-21 20:49:27 +08:00
|
|
|
|
2015-06-06 21:54:58 +08:00
|
|
|
void Settings::savePersonal(QString profileName, QString password)
|
|
|
|
{
|
|
|
|
if (QThread::currentThread() != settingsThread)
|
|
|
|
return (void) QMetaObject::invokeMethod(&getInstance(), "savePersonal",
|
|
|
|
Q_ARG(QString, profileName), Q_ARG(QString, password));
|
2015-02-21 20:49:27 +08:00
|
|
|
|
2015-06-06 21:54:58 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
|
|
|
|
QString path = getSettingsDirPath() + profileName + ".ini";
|
|
|
|
|
|
|
|
qDebug() << "Saving personal settings at " << path;
|
|
|
|
|
|
|
|
SettingsSerializer ps(path, password);
|
2015-02-21 20:49:27 +08:00
|
|
|
ps.beginGroup("Friends");
|
|
|
|
ps.beginWriteArray("Friend", friendLst.size());
|
|
|
|
int index = 0;
|
|
|
|
for (auto& frnd : friendLst)
|
|
|
|
{
|
|
|
|
ps.setArrayIndex(index);
|
|
|
|
ps.setValue("addr", frnd.addr);
|
|
|
|
ps.setValue("alias", frnd.alias);
|
|
|
|
ps.setValue("autoAcceptDir", frnd.autoAcceptDir);
|
2015-06-06 03:34:32 +08:00
|
|
|
ps.setValue("circle", frnd.circleID);
|
2015-06-24 02:58:30 +08:00
|
|
|
|
|
|
|
if (getEnableLogging())
|
|
|
|
ps.setValue("activity", frnd.activity);
|
|
|
|
|
2015-08-31 04:23:05 +08:00
|
|
|
index++;
|
2015-02-21 20:49:27 +08:00
|
|
|
}
|
|
|
|
ps.endArray();
|
|
|
|
ps.endGroup();
|
|
|
|
|
2015-06-07 07:00:24 +08:00
|
|
|
ps.beginGroup("General");
|
|
|
|
ps.setValue("compactLayout", compactLayout);
|
|
|
|
ps.endGroup();
|
|
|
|
|
2015-05-31 03:10:43 +08:00
|
|
|
ps.beginGroup("Circles");
|
|
|
|
ps.beginWriteArray("Circle", circleLst.size());
|
|
|
|
index = 0;
|
|
|
|
for (auto& circle : circleLst)
|
|
|
|
{
|
|
|
|
ps.setArrayIndex(index);
|
2015-06-04 04:18:40 +08:00
|
|
|
ps.setValue("name", circle.name);
|
|
|
|
ps.setValue("expanded", circle.expanded);
|
2015-05-31 03:10:43 +08:00
|
|
|
index++;
|
|
|
|
}
|
|
|
|
ps.endArray();
|
|
|
|
ps.endGroup();
|
|
|
|
|
2015-02-21 20:49:27 +08:00
|
|
|
ps.beginGroup("Privacy");
|
|
|
|
ps.setValue("typingNotification", typingNotification);
|
|
|
|
ps.setValue("enableLogging", enableLogging);
|
|
|
|
ps.endGroup();
|
2015-06-06 21:54:58 +08:00
|
|
|
|
2015-06-07 07:13:07 +08:00
|
|
|
ps.save();
|
2014-06-25 04:11:11 +08:00
|
|
|
}
|
|
|
|
|
2015-02-20 20:26:41 +08:00
|
|
|
uint32_t Settings::makeProfileId(const QString& profile)
|
|
|
|
{
|
|
|
|
QByteArray data = QCryptographicHash::hash(profile.toUtf8(), QCryptographicHash::Md5);
|
|
|
|
const uint32_t* dwords = (uint32_t*)data.constData();
|
|
|
|
return dwords[0] ^ dwords[1] ^ dwords[2] ^ dwords[3];
|
2014-06-25 04:11:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
QString Settings::getSettingsDirPath()
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-07-13 04:58:58 +08:00
|
|
|
if (makeToxPortable)
|
2015-06-05 18:44:22 +08:00
|
|
|
return QString(".")+QDir::separator();
|
2014-07-13 04:58:58 +08:00
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
// workaround for https://bugreports.qt-project.org/browse/QTBUG-38845
|
|
|
|
#ifdef Q_OS_WIN
|
2015-06-05 18:44:22 +08:00
|
|
|
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator()
|
2015-06-05 22:24:47 +08:00
|
|
|
+ "AppData" + QDir::separator() + "Roaming" + QDir::separator() + "tox")+QDir::separator();
|
2014-06-25 04:11:11 +08:00
|
|
|
#else
|
2015-06-05 18:44:22 +08:00
|
|
|
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)
|
2015-06-05 22:24:47 +08:00
|
|
|
+ QDir::separator() + "tox")+QDir::separator();
|
2014-06-25 04:11:11 +08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-09-24 23:55:54 +08:00
|
|
|
QPixmap Settings::getSavedAvatar(const QString &ownerId)
|
2014-09-24 22:51:16 +08:00
|
|
|
{
|
2014-09-28 05:37:39 +08:00
|
|
|
QDir dir(getSettingsDirPath());
|
2014-09-28 06:19:30 +08:00
|
|
|
QString filePath = dir.filePath("avatars/"+ownerId.left(64)+".png");
|
2014-09-28 05:37:39 +08:00
|
|
|
QFileInfo info(filePath);
|
2014-09-24 22:51:16 +08:00
|
|
|
QPixmap pic;
|
2014-09-28 05:37:39 +08:00
|
|
|
if (!info.exists())
|
|
|
|
{
|
2014-09-28 06:19:30 +08:00
|
|
|
QString filePath = dir.filePath("avatar_"+ownerId.left(64));
|
|
|
|
if (!QFileInfo(filePath).exists()) // try without truncation, for old self avatars
|
2014-09-28 06:36:19 +08:00
|
|
|
filePath = dir.filePath("avatar_"+ownerId);
|
2015-04-24 19:01:50 +08:00
|
|
|
|
2014-09-28 05:37:39 +08:00
|
|
|
pic.load(filePath);
|
|
|
|
saveAvatar(pic, ownerId);
|
|
|
|
QFile::remove(filePath);
|
|
|
|
}
|
|
|
|
else
|
2015-04-24 19:01:50 +08:00
|
|
|
{
|
2014-09-28 05:37:39 +08:00
|
|
|
pic.load(filePath);
|
2015-04-24 19:01:50 +08:00
|
|
|
}
|
2014-09-24 22:51:16 +08:00
|
|
|
return pic;
|
|
|
|
}
|
|
|
|
|
2014-09-24 23:55:54 +08:00
|
|
|
void Settings::saveAvatar(QPixmap& pic, const QString& ownerId)
|
2014-09-24 22:51:16 +08:00
|
|
|
{
|
2014-09-28 05:37:39 +08:00
|
|
|
QDir dir(getSettingsDirPath());
|
2014-09-29 09:54:28 +08:00
|
|
|
dir.mkdir("avatars/");
|
2014-09-28 06:19:30 +08:00
|
|
|
// ignore nospam (good idea, and also the addFriend funcs which call getAvatar don't have it)
|
|
|
|
QString filePath = dir.filePath("avatars/"+ownerId.left(64)+".png");
|
2014-09-24 22:51:16 +08:00
|
|
|
pic.save(filePath, "png");
|
|
|
|
}
|
|
|
|
|
2014-09-29 09:54:28 +08:00
|
|
|
void Settings::saveAvatarHash(const QByteArray& hash, const QString& ownerId)
|
|
|
|
{
|
|
|
|
QDir dir(getSettingsDirPath());
|
|
|
|
dir.mkdir("avatars/");
|
|
|
|
QFile file(dir.filePath("avatars/"+ownerId.left(64)+".hash"));
|
|
|
|
if (!file.open(QIODevice::WriteOnly))
|
|
|
|
return;
|
2015-04-24 19:01:50 +08:00
|
|
|
|
2014-09-29 09:54:28 +08:00
|
|
|
file.write(hash);
|
|
|
|
file.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray Settings::getAvatarHash(const QString& ownerId)
|
|
|
|
{
|
|
|
|
QDir dir(getSettingsDirPath());
|
|
|
|
dir.mkdir("avatars/");
|
|
|
|
QFile file(dir.filePath("avatars/"+ownerId.left(64)+".hash"));
|
|
|
|
if (!file.open(QIODevice::ReadOnly))
|
|
|
|
return QByteArray();
|
2015-04-24 19:01:50 +08:00
|
|
|
|
2014-09-29 09:54:28 +08:00
|
|
|
QByteArray out = file.readAll();
|
|
|
|
file.close();
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2015-06-05 22:24:47 +08:00
|
|
|
const QList<DhtServer>& Settings::getDhtServerList() const
|
2014-06-25 04:11:11 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-06-25 04:11:11 +08:00
|
|
|
return dhtServerList;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setDhtServerList(const QList<DhtServer>& newDhtServerList)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-06-25 04:11:11 +08:00
|
|
|
dhtServerList = newDhtServerList;
|
|
|
|
emit dhtServerListChanged();
|
|
|
|
}
|
|
|
|
|
2014-07-02 06:47:06 +08:00
|
|
|
bool Settings::getEnableIPv6() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-07-02 06:47:06 +08:00
|
|
|
return enableIPv6;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setEnableIPv6(bool newValue)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-07-02 06:47:06 +08:00
|
|
|
enableIPv6 = newValue;
|
|
|
|
}
|
|
|
|
|
2014-07-13 04:58:58 +08:00
|
|
|
bool Settings::getMakeToxPortable() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-07-13 04:58:58 +08:00
|
|
|
return makeToxPortable;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setMakeToxPortable(bool newValue)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2015-06-06 00:53:27 +08:00
|
|
|
QFile(getSettingsDirPath()+globalSettingsFile).remove();
|
2014-07-13 04:58:58 +08:00
|
|
|
makeToxPortable = newValue;
|
2015-06-06 21:54:58 +08:00
|
|
|
saveGlobal();
|
2014-07-13 04:58:58 +08:00
|
|
|
}
|
|
|
|
|
2014-12-17 21:44:23 +08:00
|
|
|
bool Settings::getAutorun() const
|
|
|
|
{
|
|
|
|
#ifdef QTOX_PLATFORM_EXT
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-12-17 21:44:23 +08:00
|
|
|
return Platform::getAutorun();
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setAutorun(bool newValue)
|
|
|
|
{
|
|
|
|
#ifdef QTOX_PLATFORM_EXT
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-12-17 21:44:23 +08:00
|
|
|
Platform::setAutorun(newValue);
|
2015-02-23 00:24:01 +08:00
|
|
|
#else
|
|
|
|
Q_UNUSED(newValue);
|
2014-12-17 21:44:23 +08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-10-08 22:17:05 +08:00
|
|
|
bool Settings::getAutostartInTray() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-08 22:17:05 +08:00
|
|
|
return autostartInTray;
|
|
|
|
}
|
|
|
|
|
2014-10-09 06:31:20 +08:00
|
|
|
QString Settings::getStyle() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-09 06:31:20 +08:00
|
|
|
return style;
|
|
|
|
}
|
|
|
|
|
2015-03-26 00:45:28 +08:00
|
|
|
void Settings::setStyle(const QString& newStyle)
|
2014-10-09 06:31:20 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-09 06:31:20 +08:00
|
|
|
style = newStyle;
|
|
|
|
}
|
|
|
|
|
2014-11-14 04:33:11 +08:00
|
|
|
bool Settings::getShowSystemTray() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-11-14 04:33:11 +08:00
|
|
|
return showSystemTray;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setShowSystemTray(const bool& newValue)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-11-14 04:33:11 +08:00
|
|
|
showSystemTray = newValue;
|
|
|
|
}
|
|
|
|
|
2014-11-05 23:20:32 +08:00
|
|
|
void Settings::setUseEmoticons(bool newValue)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-11-05 23:20:32 +08:00
|
|
|
useEmoticons = newValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Settings::getUseEmoticons() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-11-05 23:20:32 +08:00
|
|
|
return useEmoticons;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setAutoSaveEnabled(bool newValue)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-11-05 23:20:32 +08:00
|
|
|
autoSaveEnabled = newValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Settings::getAutoSaveEnabled() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-11-05 23:20:32 +08:00
|
|
|
return autoSaveEnabled;
|
|
|
|
}
|
|
|
|
|
2014-10-08 22:17:05 +08:00
|
|
|
void Settings::setAutostartInTray(bool newValue)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-08 22:17:05 +08:00
|
|
|
autostartInTray = newValue;
|
|
|
|
}
|
|
|
|
|
2014-10-20 03:47:06 +08:00
|
|
|
bool Settings::getCloseToTray() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-20 03:47:06 +08:00
|
|
|
return closeToTray;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setCloseToTray(bool newValue)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-20 03:47:06 +08:00
|
|
|
closeToTray = newValue;
|
|
|
|
}
|
|
|
|
|
2014-10-20 19:50:12 +08:00
|
|
|
bool Settings::getMinimizeToTray() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-20 19:50:12 +08:00
|
|
|
return minimizeToTray;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setMinimizeToTray(bool newValue)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-20 19:50:12 +08:00
|
|
|
minimizeToTray = newValue;
|
|
|
|
}
|
|
|
|
|
2014-12-12 03:34:12 +08:00
|
|
|
bool Settings::getLightTrayIcon() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-12-12 03:34:12 +08:00
|
|
|
return lightTrayIcon;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setLightTrayIcon(bool newValue)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-12-12 03:34:12 +08:00
|
|
|
lightTrayIcon = newValue;
|
|
|
|
}
|
|
|
|
|
2014-10-11 07:18:32 +08:00
|
|
|
bool Settings::getStatusChangeNotificationEnabled() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-11 07:18:32 +08:00
|
|
|
return statusChangeNotificationEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setStatusChangeNotificationEnabled(bool newValue)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-11 07:18:32 +08:00
|
|
|
statusChangeNotificationEnabled = newValue;
|
|
|
|
}
|
|
|
|
|
2014-11-10 08:23:41 +08:00
|
|
|
bool Settings::getShowInFront() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2015-06-24 00:54:00 +08:00
|
|
|
return showInFront;
|
2014-11-10 08:23:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setShowInFront(bool newValue)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2015-01-21 19:10:41 +08:00
|
|
|
showInFront = newValue;
|
|
|
|
}
|
|
|
|
|
2015-03-22 08:57:28 +08:00
|
|
|
bool Settings::getNotifySound() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
return notifySound;
|
2015-03-22 08:57:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setNotifySound(bool newValue)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2015-03-22 08:57:28 +08:00
|
|
|
notifySound = newValue;
|
|
|
|
}
|
|
|
|
|
2015-01-21 19:10:41 +08:00
|
|
|
bool Settings::getGroupAlwaysNotify() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2015-01-21 19:10:41 +08:00
|
|
|
return groupAlwaysNotify;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setGroupAlwaysNotify(bool newValue)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2015-01-21 19:10:41 +08:00
|
|
|
groupAlwaysNotify = newValue;
|
2014-11-10 08:23:41 +08:00
|
|
|
}
|
|
|
|
|
2014-10-18 07:06:30 +08:00
|
|
|
QString Settings::getTranslation() const
|
2014-07-05 01:22:43 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-18 07:06:30 +08:00
|
|
|
return translation;
|
2014-07-05 01:22:43 +08:00
|
|
|
}
|
|
|
|
|
2014-10-18 07:06:30 +08:00
|
|
|
void Settings::setTranslation(QString newValue)
|
2014-07-05 01:22:43 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-18 07:06:30 +08:00
|
|
|
translation = newValue;
|
2014-10-06 04:49:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Settings::getForceTCP() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-06 04:49:44 +08:00
|
|
|
return forceTCP;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setForceTCP(bool newValue)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-06 04:49:44 +08:00
|
|
|
forceTCP = newValue;
|
|
|
|
}
|
|
|
|
|
2014-12-28 20:32:25 +08:00
|
|
|
ProxyType Settings::getProxyType() const
|
2014-10-07 10:09:15 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-12-28 20:32:25 +08:00
|
|
|
return proxyType;
|
2014-10-07 10:09:15 +08:00
|
|
|
}
|
2014-12-28 20:32:25 +08:00
|
|
|
|
|
|
|
void Settings::setProxyType(int newValue)
|
2014-10-07 10:09:15 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-12-28 21:04:32 +08:00
|
|
|
if (newValue >= 0 && newValue <= 2)
|
2014-12-28 20:32:25 +08:00
|
|
|
proxyType = static_cast<ProxyType>(newValue);
|
|
|
|
else
|
|
|
|
proxyType = ProxyType::ptNone;
|
2014-10-07 10:09:15 +08:00
|
|
|
}
|
|
|
|
|
2014-10-06 04:49:44 +08:00
|
|
|
QString Settings::getProxyAddr() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-06 04:49:44 +08:00
|
|
|
return proxyAddr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setProxyAddr(const QString& newValue)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-06 04:49:44 +08:00
|
|
|
proxyAddr = newValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Settings::getProxyPort() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-06 04:49:44 +08:00
|
|
|
return proxyPort;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setProxyPort(int newValue)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-06 04:49:44 +08:00
|
|
|
proxyPort = newValue;
|
2014-07-05 01:22:43 +08:00
|
|
|
}
|
|
|
|
|
2014-10-11 06:43:15 +08:00
|
|
|
QString Settings::getCurrentProfile() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-11 06:43:15 +08:00
|
|
|
return currentProfile;
|
|
|
|
}
|
|
|
|
|
2015-02-20 20:26:41 +08:00
|
|
|
uint32_t Settings::getCurrentProfileId() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2015-02-20 20:26:41 +08:00
|
|
|
return currentProfileId;
|
|
|
|
}
|
|
|
|
|
2014-10-11 06:43:15 +08:00
|
|
|
void Settings::setCurrentProfile(QString profile)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-11 06:43:15 +08:00
|
|
|
currentProfile = profile;
|
2015-02-20 20:26:41 +08:00
|
|
|
currentProfileId = makeProfileId(currentProfile);
|
2014-10-11 06:43:15 +08:00
|
|
|
}
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
bool Settings::getEnableLogging() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-06-25 04:11:11 +08:00
|
|
|
return enableLogging;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setEnableLogging(bool newValue)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-06-25 04:11:11 +08:00
|
|
|
enableLogging = newValue;
|
|
|
|
}
|
|
|
|
|
2014-11-12 20:56:24 +08:00
|
|
|
Db::syncType Settings::getDbSyncType() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-11-12 20:56:24 +08:00
|
|
|
return dbSyncType;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setDbSyncType(int newValue)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-11-12 20:56:24 +08:00
|
|
|
if (newValue >= 0 && newValue <= 2)
|
|
|
|
dbSyncType = static_cast<Db::syncType>(newValue);
|
|
|
|
else
|
|
|
|
dbSyncType = Db::syncType::stFull;
|
|
|
|
}
|
|
|
|
|
2014-10-16 17:47:58 +08:00
|
|
|
int Settings::getAutoAwayTime() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-16 17:47:58 +08:00
|
|
|
return autoAwayTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setAutoAwayTime(int newValue)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-16 17:47:58 +08:00
|
|
|
if (newValue < 0)
|
|
|
|
newValue = 10;
|
2015-04-24 19:01:50 +08:00
|
|
|
|
2014-10-16 17:47:58 +08:00
|
|
|
autoAwayTime = newValue;
|
|
|
|
}
|
|
|
|
|
2015-05-18 04:55:50 +08:00
|
|
|
QString Settings::getAutoAcceptDir(const ToxId& id) const
|
2014-10-18 11:02:13 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-11-17 18:10:38 +08:00
|
|
|
QString key = id.publicKey;
|
|
|
|
|
|
|
|
auto it = friendLst.find(key);
|
|
|
|
if (it != friendLst.end())
|
|
|
|
return it->autoAcceptDir;
|
|
|
|
|
|
|
|
return QString();
|
2014-10-18 11:02:13 +08:00
|
|
|
}
|
|
|
|
|
2015-05-18 04:55:50 +08:00
|
|
|
void Settings::setAutoAcceptDir(const ToxId &id, const QString& dir)
|
2014-10-18 11:02:13 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-11-17 18:10:38 +08:00
|
|
|
QString key = id.publicKey;
|
|
|
|
|
|
|
|
auto it = friendLst.find(key);
|
|
|
|
if (it != friendLst.end())
|
|
|
|
{
|
|
|
|
it->autoAcceptDir = dir;
|
2015-03-21 16:59:28 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-11-17 18:10:38 +08:00
|
|
|
updateFriendAdress(id.toString());
|
|
|
|
setAutoAcceptDir(id, dir);
|
|
|
|
}
|
2014-10-18 11:02:13 +08:00
|
|
|
}
|
|
|
|
|
2014-10-20 12:25:52 +08:00
|
|
|
QString Settings::getGlobalAutoAcceptDir() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-20 12:25:52 +08:00
|
|
|
return globalAutoAcceptDir;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setGlobalAutoAcceptDir(const QString& newValue)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-20 12:25:52 +08:00
|
|
|
globalAutoAcceptDir = newValue;
|
|
|
|
}
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
void Settings::setWidgetData(const QString& uniqueName, const QByteArray& data)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-06-25 04:11:11 +08:00
|
|
|
widgetSettings[uniqueName] = data;
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray Settings::getWidgetData(const QString& uniqueName) const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-06-25 04:11:11 +08:00
|
|
|
return widgetSettings.value(uniqueName);
|
|
|
|
}
|
|
|
|
|
2014-07-25 20:52:14 +08:00
|
|
|
QString Settings::getSmileyPack() const
|
2014-06-25 04:11:11 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-06-25 04:11:11 +08:00
|
|
|
return smileyPack;
|
|
|
|
}
|
|
|
|
|
2014-07-25 20:52:14 +08:00
|
|
|
void Settings::setSmileyPack(const QString &value)
|
2014-06-25 04:11:11 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-06-25 04:11:11 +08:00
|
|
|
smileyPack = value;
|
|
|
|
emit smileyPackChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
int Settings::getEmojiFontPointSize() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-06-25 04:11:11 +08:00
|
|
|
return emojiFontPointSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setEmojiFontPointSize(int value)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-06-25 04:11:11 +08:00
|
|
|
emojiFontPointSize = value;
|
|
|
|
emit emojiFontChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
int Settings::getFirstColumnHandlePos() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-06-25 04:11:11 +08:00
|
|
|
return firstColumnHandlePos;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setFirstColumnHandlePos(const int pos)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-06-25 04:11:11 +08:00
|
|
|
firstColumnHandlePos = pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Settings::getSecondColumnHandlePosFromRight() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-06-25 04:11:11 +08:00
|
|
|
return secondColumnHandlePosFromRight;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setSecondColumnHandlePosFromRight(const int pos)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-06-25 04:11:11 +08:00
|
|
|
secondColumnHandlePosFromRight = pos;
|
|
|
|
}
|
|
|
|
|
2015-03-26 00:45:28 +08:00
|
|
|
const QString& Settings::getTimestampFormat() const
|
2014-06-25 04:11:11 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-06-25 04:11:11 +08:00
|
|
|
return timestampFormat;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setTimestampFormat(const QString &format)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-06-25 04:11:11 +08:00
|
|
|
timestampFormat = format;
|
|
|
|
}
|
|
|
|
|
2015-03-26 00:45:28 +08:00
|
|
|
const QString& Settings::getDateFormat() const
|
2015-03-15 04:15:56 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2015-03-15 04:15:56 +08:00
|
|
|
return dateFormat;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setDateFormat(const QString &format)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2015-03-15 04:15:56 +08:00
|
|
|
dateFormat = format;
|
|
|
|
}
|
|
|
|
|
2014-08-11 16:00:08 +08:00
|
|
|
QByteArray Settings::getWindowGeometry() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-08-11 16:00:08 +08:00
|
|
|
return windowGeometry;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setWindowGeometry(const QByteArray &value)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-08-11 16:00:08 +08:00
|
|
|
windowGeometry = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray Settings::getWindowState() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-08-11 16:00:08 +08:00
|
|
|
return windowState;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setWindowState(const QByteArray &value)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-08-11 16:00:08 +08:00
|
|
|
windowState = value;
|
|
|
|
}
|
|
|
|
|
2014-11-10 07:31:29 +08:00
|
|
|
bool Settings::getCheckUpdates() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-11-10 07:31:29 +08:00
|
|
|
return checkUpdates;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setCheckUpdates(bool newValue)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-11-10 07:31:29 +08:00
|
|
|
checkUpdates = newValue;
|
|
|
|
}
|
|
|
|
|
2015-01-21 19:10:41 +08:00
|
|
|
bool Settings::getShowWindow() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2015-01-21 19:10:41 +08:00
|
|
|
return showWindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setShowWindow(bool newValue)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2015-01-21 19:10:41 +08:00
|
|
|
showWindow = newValue;
|
|
|
|
}
|
|
|
|
|
2014-08-11 20:07:27 +08:00
|
|
|
QByteArray Settings::getSplitterState() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-08-11 20:07:27 +08:00
|
|
|
return splitterState;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setSplitterState(const QByteArray &value)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-08-11 20:07:27 +08:00
|
|
|
splitterState = value;
|
|
|
|
}
|
|
|
|
|
2015-06-19 22:58:48 +08:00
|
|
|
QByteArray Settings::getDialogGeometry() const
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
return dialogGeometry;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setDialogGeometry(const QByteArray &value)
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
dialogGeometry = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray Settings::getDialogSplitterState() const
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
return dialogSplitterState;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setDialogSplitterState(const QByteArray &value)
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
dialogSplitterState = value;
|
|
|
|
}
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
bool Settings::isMinimizeOnCloseEnabled() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-06-25 04:11:11 +08:00
|
|
|
return minimizeOnClose;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setMinimizeOnClose(bool newValue)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-06-25 04:11:11 +08:00
|
|
|
minimizeOnClose = newValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Settings::isTypingNotificationEnabled() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-06-25 04:11:11 +08:00
|
|
|
return typingNotification;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setTypingNotification(bool enabled)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-06-25 04:11:11 +08:00
|
|
|
typingNotification = enabled;
|
|
|
|
}
|
2014-10-29 04:21:37 +08:00
|
|
|
|
|
|
|
QString Settings::getInDev() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-29 04:21:37 +08:00
|
|
|
return inDev;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setInDev(const QString& deviceSpecifier)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-29 04:21:37 +08:00
|
|
|
inDev = deviceSpecifier;
|
|
|
|
}
|
|
|
|
|
2015-05-14 10:46:28 +08:00
|
|
|
QString Settings::getVideoDev() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2015-05-14 10:46:28 +08:00
|
|
|
return videoDev;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setVideoDev(const QString& deviceSpecifier)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2015-05-14 10:46:28 +08:00
|
|
|
videoDev = deviceSpecifier;
|
|
|
|
}
|
|
|
|
|
2014-10-29 04:21:37 +08:00
|
|
|
QString Settings::getOutDev() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-29 04:21:37 +08:00
|
|
|
return outDev;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setOutDev(const QString& deviceSpecifier)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-29 04:21:37 +08:00
|
|
|
outDev = deviceSpecifier;
|
|
|
|
}
|
2014-11-08 00:02:10 +08:00
|
|
|
|
2014-12-17 08:05:13 +08:00
|
|
|
bool Settings::getFilterAudio() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-12-14 16:50:18 +08:00
|
|
|
return filterAudio;
|
|
|
|
}
|
|
|
|
|
2014-12-17 08:05:13 +08:00
|
|
|
void Settings::setFilterAudio(bool newValue)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-12-14 16:50:18 +08:00
|
|
|
filterAudio = newValue;
|
|
|
|
}
|
|
|
|
|
2015-01-24 09:03:26 +08:00
|
|
|
QSize Settings::getCamVideoRes() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2015-01-24 09:03:26 +08:00
|
|
|
return camVideoRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setCamVideoRes(QSize newValue)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2015-01-24 09:03:26 +08:00
|
|
|
camVideoRes = newValue;
|
|
|
|
}
|
|
|
|
|
2014-11-08 00:02:10 +08:00
|
|
|
QString Settings::getFriendAdress(const QString &publicKey) const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2015-05-18 04:55:50 +08:00
|
|
|
QString key = ToxId(publicKey).publicKey;
|
2014-11-08 00:02:10 +08:00
|
|
|
auto it = friendLst.find(key);
|
|
|
|
if (it != friendLst.end())
|
|
|
|
return it->addr;
|
|
|
|
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::updateFriendAdress(const QString &newAddr)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2015-05-18 04:55:50 +08:00
|
|
|
QString key = ToxId(newAddr).publicKey;
|
2014-11-08 00:02:10 +08:00
|
|
|
auto it = friendLst.find(key);
|
|
|
|
if (it != friendLst.end())
|
|
|
|
{
|
|
|
|
it->addr = newAddr;
|
2015-04-24 19:01:50 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-11-08 00:02:10 +08:00
|
|
|
friendProp fp;
|
|
|
|
fp.addr = newAddr;
|
|
|
|
fp.alias = "";
|
2014-11-17 18:10:38 +08:00
|
|
|
fp.autoAcceptDir = "";
|
2014-11-08 00:02:10 +08:00
|
|
|
friendLst[newAddr] = fp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-18 04:55:50 +08:00
|
|
|
QString Settings::getFriendAlias(const ToxId &id) const
|
2014-11-08 00:02:10 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-11-08 00:02:10 +08:00
|
|
|
QString key = id.publicKey;
|
|
|
|
auto it = friendLst.find(key);
|
|
|
|
if (it != friendLst.end())
|
|
|
|
return it->alias;
|
|
|
|
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
2015-05-18 04:55:50 +08:00
|
|
|
void Settings::setFriendAlias(const ToxId &id, const QString &alias)
|
2014-11-08 00:02:10 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-11-08 00:02:10 +08:00
|
|
|
QString key = id.publicKey;
|
|
|
|
auto it = friendLst.find(key);
|
|
|
|
if (it != friendLst.end())
|
|
|
|
{
|
|
|
|
it->alias = alias;
|
2015-04-24 19:01:50 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-11-12 00:29:00 +08:00
|
|
|
friendProp fp;
|
|
|
|
fp.addr = key;
|
|
|
|
fp.alias = alias;
|
2014-11-17 18:10:38 +08:00
|
|
|
fp.autoAcceptDir = "";
|
2014-11-12 00:29:00 +08:00
|
|
|
friendLst[key] = fp;
|
2014-11-08 00:02:10 +08:00
|
|
|
}
|
|
|
|
}
|
2014-11-10 21:06:35 +08:00
|
|
|
|
2015-06-06 03:34:32 +08:00
|
|
|
int Settings::getFriendCircleID(const ToxId &id) const
|
2015-05-31 03:10:43 +08:00
|
|
|
{
|
|
|
|
QString key = id.publicKey;
|
|
|
|
auto it = friendLst.find(key);
|
|
|
|
if (it != friendLst.end())
|
2015-06-06 03:34:32 +08:00
|
|
|
return it->circleID;
|
2015-05-31 03:10:43 +08:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2015-06-06 03:34:32 +08:00
|
|
|
void Settings::setFriendCircleID(const ToxId &id, int circleID)
|
2015-06-04 04:18:40 +08:00
|
|
|
{
|
|
|
|
QString key = id.publicKey;
|
|
|
|
auto it = friendLst.find(key);
|
|
|
|
if (it != friendLst.end())
|
2015-06-18 03:45:03 +08:00
|
|
|
{
|
2015-06-06 03:34:32 +08:00
|
|
|
it->circleID = circleID;
|
2015-06-18 03:45:03 +08:00
|
|
|
}
|
2015-06-06 01:38:07 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
friendProp fp;
|
|
|
|
fp.addr = key;
|
|
|
|
fp.alias = "";
|
|
|
|
fp.autoAcceptDir = "";
|
2015-06-06 03:34:32 +08:00
|
|
|
fp.circleID = circleID;
|
2015-06-06 01:38:07 +08:00
|
|
|
friendLst[key] = fp;
|
|
|
|
}
|
2015-06-04 04:18:40 +08:00
|
|
|
}
|
|
|
|
|
2015-06-12 03:27:54 +08:00
|
|
|
QDate Settings::getFriendActivity(const ToxId &id) const
|
|
|
|
{
|
|
|
|
QString key = id.publicKey;
|
|
|
|
auto it = friendLst.find(key);
|
|
|
|
if (it != friendLst.end())
|
|
|
|
return it->activity;
|
|
|
|
|
|
|
|
return QDate();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setFriendActivity(const ToxId &id, const QDate &activity)
|
|
|
|
{
|
|
|
|
QString key = id.publicKey;
|
|
|
|
auto it = friendLst.find(key);
|
|
|
|
if (it != friendLst.end())
|
2015-06-18 03:45:03 +08:00
|
|
|
{
|
2015-06-12 03:27:54 +08:00
|
|
|
it->activity = activity;
|
2015-06-18 03:45:03 +08:00
|
|
|
}
|
2015-06-12 03:27:54 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
friendProp fp;
|
|
|
|
fp.addr = key;
|
|
|
|
fp.alias = "";
|
|
|
|
fp.autoAcceptDir = "";
|
|
|
|
fp.circleID = -1;
|
|
|
|
fp.activity = activity;
|
|
|
|
friendLst[key] = fp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-18 04:55:50 +08:00
|
|
|
void Settings::removeFriendSettings(const ToxId &id)
|
2014-11-12 00:52:19 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-11-12 00:52:19 +08:00
|
|
|
QString key = id.publicKey;
|
|
|
|
friendLst.remove(key);
|
|
|
|
}
|
|
|
|
|
2014-11-10 21:06:35 +08:00
|
|
|
bool Settings::getFauxOfflineMessaging() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-11-10 21:06:35 +08:00
|
|
|
return fauxOfflineMessaging;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setFauxOfflineMessaging(bool value)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-11-10 21:06:35 +08:00
|
|
|
fauxOfflineMessaging = value;
|
|
|
|
}
|
2014-11-16 04:30:20 +08:00
|
|
|
|
2014-12-11 22:31:01 +08:00
|
|
|
bool Settings::getCompactLayout() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-12-11 20:02:45 +08:00
|
|
|
return compactLayout;
|
|
|
|
}
|
|
|
|
|
2014-12-11 22:31:01 +08:00
|
|
|
void Settings::setCompactLayout(bool value)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-12-11 20:02:45 +08:00
|
|
|
compactLayout = value;
|
|
|
|
}
|
|
|
|
|
2015-06-17 02:25:19 +08:00
|
|
|
bool Settings::getSeparateWindow() const
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
return separateWindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setSeparateWindow(bool value)
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
separateWindow = value;
|
|
|
|
}
|
|
|
|
|
2015-06-19 22:58:48 +08:00
|
|
|
bool Settings::getDontGroupWindows() const
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
return dontGroupWindows;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setDontGroupWindows(bool value)
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
dontGroupWindows = value;
|
|
|
|
}
|
|
|
|
|
2015-03-12 08:41:18 +08:00
|
|
|
bool Settings::getGroupchatPosition() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2015-03-12 08:41:18 +08:00
|
|
|
return groupchatPosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setGroupchatPosition(bool value)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2015-03-12 08:41:18 +08:00
|
|
|
groupchatPosition = value;
|
|
|
|
}
|
|
|
|
|
2015-05-31 03:10:43 +08:00
|
|
|
int Settings::getCircleCount() const
|
|
|
|
{
|
|
|
|
return circleLst.size();
|
|
|
|
}
|
|
|
|
|
2015-06-06 03:34:32 +08:00
|
|
|
QString Settings::getCircleName(int id) const
|
2015-05-31 03:10:43 +08:00
|
|
|
{
|
2015-06-06 03:34:32 +08:00
|
|
|
return circleLst[id].name;
|
2015-06-04 04:18:40 +08:00
|
|
|
}
|
|
|
|
|
2015-06-06 03:34:32 +08:00
|
|
|
void Settings::setCircleName(int id, const QString &name)
|
2015-06-04 04:18:40 +08:00
|
|
|
{
|
2015-06-06 03:34:32 +08:00
|
|
|
circleLst[id].name = name;
|
2015-06-10 07:42:51 +08:00
|
|
|
savePersonal();
|
2015-06-04 04:18:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int Settings::addCircle(const QString &name)
|
|
|
|
{
|
|
|
|
circleProp cp;
|
|
|
|
cp.expanded = false;
|
2015-06-13 02:52:05 +08:00
|
|
|
|
|
|
|
if (name.isEmpty())
|
|
|
|
cp.name = tr("Circle #%1").arg(circleLst.count() + 1);
|
|
|
|
else
|
|
|
|
cp.name = name;
|
|
|
|
|
2015-06-04 04:18:40 +08:00
|
|
|
circleLst.append(cp);
|
2015-06-06 03:34:32 +08:00
|
|
|
savePersonal();
|
2015-06-04 04:18:40 +08:00
|
|
|
return circleLst.count() - 1;
|
|
|
|
}
|
|
|
|
|
2015-06-06 03:34:32 +08:00
|
|
|
bool Settings::getCircleExpanded(int id) const
|
2015-06-04 04:18:40 +08:00
|
|
|
{
|
2015-06-06 03:34:32 +08:00
|
|
|
return circleLst[id].expanded;
|
2015-06-04 04:18:40 +08:00
|
|
|
}
|
|
|
|
|
2015-06-06 03:34:32 +08:00
|
|
|
void Settings::setCircleExpanded(int id, bool expanded)
|
2015-06-04 04:18:40 +08:00
|
|
|
{
|
2015-06-06 03:34:32 +08:00
|
|
|
circleLst[id].expanded = expanded;
|
2015-06-04 04:18:40 +08:00
|
|
|
}
|
|
|
|
|
2015-06-06 03:34:32 +08:00
|
|
|
int Settings::removeCircle(int id)
|
2015-06-04 04:18:40 +08:00
|
|
|
{
|
|
|
|
// Replace index with last one and remove last one instead.
|
|
|
|
// This gives you contiguous ids all the time.
|
2015-06-06 03:34:32 +08:00
|
|
|
circleLst[id] = circleLst.last();
|
2015-06-04 04:18:40 +08:00
|
|
|
circleLst.pop_back();
|
2015-06-06 03:34:32 +08:00
|
|
|
savePersonal();
|
2015-06-04 04:18:40 +08:00
|
|
|
return circleLst.count();
|
2015-05-31 03:10:43 +08:00
|
|
|
}
|
|
|
|
|
2014-11-16 04:30:20 +08:00
|
|
|
int Settings::getThemeColor() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-11-16 04:30:20 +08:00
|
|
|
return themeColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setThemeColor(const int &value)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-11-16 04:30:20 +08:00
|
|
|
themeColor = value;
|
|
|
|
}
|
2015-06-04 05:20:47 +08:00
|
|
|
|
2015-06-05 22:27:15 +08:00
|
|
|
bool Settings::getAutoLogin() const
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
return autoLogin;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setAutoLogin(bool state)
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
autoLogin = state;
|
|
|
|
}
|
|
|
|
|
2015-06-04 05:20:47 +08:00
|
|
|
void Settings::createPersonal(QString basename)
|
|
|
|
{
|
|
|
|
QString path = getSettingsDirPath() + QDir::separator() + basename + ".ini";
|
|
|
|
qDebug() << "Creating new profile settings in " << path;
|
|
|
|
|
|
|
|
QSettings ps(path, QSettings::IniFormat);
|
|
|
|
ps.beginGroup("Friends");
|
|
|
|
ps.beginWriteArray("Friend", 0);
|
|
|
|
ps.endArray();
|
|
|
|
ps.endGroup();
|
|
|
|
|
|
|
|
ps.beginGroup("Privacy");
|
|
|
|
ps.endGroup();
|
|
|
|
}
|
2015-06-04 17:37:54 +08:00
|
|
|
|
|
|
|
void Settings::createSettingsDir()
|
|
|
|
{
|
|
|
|
QString dir = Settings::getSettingsDirPath();
|
|
|
|
QDir directory(dir);
|
|
|
|
if (!directory.exists() && !directory.mkpath(directory.absolutePath()))
|
|
|
|
qCritical() << "Error while creating directory " << dir;
|
|
|
|
}
|
2015-06-06 00:01:50 +08:00
|
|
|
|
|
|
|
void Settings::sync()
|
|
|
|
{
|
|
|
|
if (QThread::currentThread() != settingsThread)
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(&getInstance(), "sync", Qt::BlockingQueuedConnection);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
qApp->processEvents();
|
|
|
|
}
|