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"
|
2016-06-28 19:03:58 +08:00
|
|
|
#include "src/widget/style.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>
|
2016-01-19 07:19:07 +08:00
|
|
|
#include <QNetworkProxy>
|
2014-06-25 04:11:11 +08:00
|
|
|
|
2016-07-27 06:20:54 +08:00
|
|
|
/**
|
2016-08-01 16:21:23 +08:00
|
|
|
* @var QHash<QString, QByteArray> Settings::widgetSettings
|
|
|
|
* @brief Assume all widgets have unique names
|
|
|
|
* @warning Don't use it to save every single thing you want to save, use it
|
|
|
|
* for some general purpose widgets, such as MainWindows or Splitters,
|
|
|
|
* which have widget->saveX() and widget->loadX() methods.
|
|
|
|
*
|
|
|
|
* @var QString Settings::toxmeInfo
|
|
|
|
* @brief Toxme info like name@server
|
|
|
|
*/
|
2016-07-27 06:20:54 +08:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-07-27 06:20:54 +08:00
|
|
|
/**
|
2016-08-01 16:21:23 +08:00
|
|
|
* @brief Returns the singleton instance.
|
|
|
|
*/
|
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
|
|
|
|
2016-09-06 20:15:21 +08:00
|
|
|
QString localSettingsPath = qApp->applicationDirPath() + QDir::separator()
|
|
|
|
+ globalSettingsFile;
|
|
|
|
|
|
|
|
if (QFile(localSettingsPath).exists())
|
2014-09-05 05:11:46 +08:00
|
|
|
{
|
2016-09-06 20:15:21 +08:00
|
|
|
QSettings ps(localSettingsPath, QSettings::IniFormat);
|
2016-01-21 11:59:20 +08:00
|
|
|
ps.setIniCodec("UTF-8");
|
2016-09-06 20:15:21 +08:00
|
|
|
ps.beginGroup("Advanced");
|
2014-12-03 06:47:55 +08:00
|
|
|
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);
|
2016-01-21 11:59:20 +08:00
|
|
|
s.setIniCodec("UTF-8");
|
2016-08-21 06:16:39 +08:00
|
|
|
|
2015-06-05 21:24:02 +08:00
|
|
|
s.beginGroup("Login");
|
2016-07-14 05:01:50 +08:00
|
|
|
{
|
2015-06-05 21:24:02 +08:00
|
|
|
autoLogin = s.value("autoLogin", false).toBool();
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
2015-06-05 21:24:02 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
s.beginGroup("DHT Server");
|
2016-07-14 05:01:50 +08:00
|
|
|
{
|
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();
|
2016-08-01 03:24:48 +08:00
|
|
|
server.port = static_cast<quint16>(s.value("port").toUInt());
|
2014-09-05 05:13:59 +08:00
|
|
|
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
|
|
|
{
|
2016-07-14 05:01:50 +08:00
|
|
|
useCustomDhtList = false;
|
2015-04-24 19:01:50 +08:00
|
|
|
}
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
2014-06-25 04:11:11 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
|
|
|
s.beginGroup("General");
|
2016-07-14 05:01:50 +08:00
|
|
|
{
|
2016-08-21 06:16:39 +08:00
|
|
|
{
|
2016-09-13 16:38:42 +08:00
|
|
|
// TODO: values in this block are moved -> remove @ v1.8
|
2016-08-21 06:16:39 +08:00
|
|
|
enableIPv6 = s.value("enableIPv6", true).toBool();
|
|
|
|
makeToxPortable = s.value("makeToxPortable", 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());
|
|
|
|
showWindow = s.value("showWindow", true).toBool();
|
|
|
|
showInFront = s.value("showInFront", false).toBool();
|
|
|
|
groupAlwaysNotify = s.value("groupAlwaysNotify", false).toBool();
|
|
|
|
separateWindow = s.value("separateWindow", false).toBool();
|
|
|
|
dontGroupWindows = s.value("dontGroupWindows", true).toBool();
|
|
|
|
groupchatPosition = s.value("groupchatPosition", true).toBool();
|
|
|
|
}
|
|
|
|
|
2014-11-06 06:34:28 +08:00
|
|
|
translation = s.value("translation", "en").toString();
|
2016-08-01 03:24:48 +08:00
|
|
|
showSystemTray = s.value("showSystemTray", true).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();
|
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();
|
2015-12-13 01:37:37 +08:00
|
|
|
checkUpdates = s.value("checkUpdates", true).toBool();
|
2015-03-22 08:57:28 +08:00
|
|
|
notifySound = s.value("notifySound", true).toBool();
|
2016-05-13 03:15:22 +08:00
|
|
|
busySound = s.value("busySound", 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();
|
2016-07-14 05:01:50 +08:00
|
|
|
globalAutoAcceptDir = s.value("globalAutoAcceptDir", QStandardPaths::locate(
|
|
|
|
QStandardPaths::HomeLocation,
|
|
|
|
QString(),
|
|
|
|
QStandardPaths::LocateDirectory)).toString();
|
2016-07-08 11:07:22 +08:00
|
|
|
stylePreference = static_cast<StyleType>(s.value("stylePreference", 1).toInt());
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
2014-06-25 04:11:11 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
2014-11-12 20:56:24 +08:00
|
|
|
s.beginGroup("Advanced");
|
2016-07-14 05:01:50 +08:00
|
|
|
{
|
2016-09-13 16:38:42 +08:00
|
|
|
// TODO: Default values in this block should be changed @ v1.8
|
|
|
|
makeToxPortable = s.value("makeToxPortable", makeToxPortable).toBool();
|
|
|
|
enableIPv6 = s.value("enableIPv6", enableIPv6).toBool();
|
|
|
|
forceTCP = s.value("forceTCP", forceTCP).toBool();
|
|
|
|
|
2016-07-14 05:01:50 +08:00
|
|
|
int type = s.value("dbSyncType", static_cast<int>(Db::syncType::stFull)).toInt();
|
|
|
|
Db::syncType sType = static_cast<Db::syncType>(type);
|
2014-11-12 20:56:24 +08:00
|
|
|
setDbSyncType(sType);
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
2014-11-12 20:56:24 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
s.beginGroup("Widgets");
|
2016-07-14 05:01:50 +08:00
|
|
|
{
|
2014-06-25 04:11:11 +08:00
|
|
|
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();
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
2014-06-25 04:11:11 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
|
|
|
s.beginGroup("GUI");
|
2016-07-14 05:01:50 +08:00
|
|
|
{
|
2016-09-13 16:38:42 +08:00
|
|
|
// TODO: Default values in this block should be changed @ v1.8
|
|
|
|
showWindow = s.value("showWindow", showWindow).toBool();
|
|
|
|
showInFront = s.value("showInFront", showInFront).toBool();
|
|
|
|
groupAlwaysNotify = s.value("groupAlwaysNotify", groupAlwaysNotify).toBool();
|
|
|
|
groupchatPosition = s.value("groupchatPosition", groupchatPosition).toBool();
|
|
|
|
separateWindow = s.value("separateWindow", separateWindow).toBool();
|
|
|
|
dontGroupWindows = s.value("dontGroupWindows", dontGroupWindows).toBool();
|
2016-07-14 05:01:50 +08:00
|
|
|
|
2016-06-08 04:21:58 +08:00
|
|
|
const QString DEFAULT_SMILEYS = ":/smileys/emojione/emoticons.xml";
|
2016-01-09 10:02:48 +08:00
|
|
|
smileyPack = s.value("smileyPack", DEFAULT_SMILEYS).toString();
|
|
|
|
if (!SmileyPack::isValid(smileyPack))
|
|
|
|
smileyPack = DEFAULT_SMILEYS;
|
2016-07-14 05:01:50 +08:00
|
|
|
|
2016-10-03 14:39:00 +08:00
|
|
|
emojiFontPointSize = s.value("emojiFontPointSize", 24).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();
|
2016-09-13 19:35:47 +08:00
|
|
|
dateFormat = s.value("dateFormat", "yyyy-MM-dd").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";
|
|
|
|
}
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
2014-08-11 23:33:32 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
2016-06-28 19:03:58 +08:00
|
|
|
s.beginGroup("Chat");
|
|
|
|
{
|
|
|
|
chatMessageFont = s.value("chatMessageFont", Style::getFont(Style::Big)).value<QFont>();
|
|
|
|
}
|
|
|
|
s.endGroup();
|
|
|
|
|
2014-08-11 23:33:32 +08:00
|
|
|
s.beginGroup("State");
|
2016-07-14 05:01:50 +08:00
|
|
|
{
|
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();
|
2015-07-03 01:16:11 +08:00
|
|
|
dialogSettingsGeometry = s.value("dialogSettingsGeometry", QByteArray()).toByteArray();
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
2014-06-25 04:11:11 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
2014-10-29 04:21:37 +08:00
|
|
|
s.beginGroup("Audio");
|
2016-07-14 05:01:50 +08:00
|
|
|
{
|
2014-10-29 04:21:37 +08:00
|
|
|
inDev = s.value("inDev", "").toString();
|
2016-06-27 06:04:19 +08:00
|
|
|
audioInDevEnabled = s.value("audioInDevEnabled", true).toBool();
|
2014-10-29 04:21:37 +08:00
|
|
|
outDev = s.value("outDev", "").toString();
|
2016-06-27 06:04:19 +08:00
|
|
|
audioOutDevEnabled = s.value("audioOutDevEnabled", true).toBool();
|
2016-05-30 03:40:05 +08:00
|
|
|
audioInGainDecibel = s.value("inGain", 0).toReal();
|
2015-10-18 16:15:02 +08:00
|
|
|
outVolume = s.value("outVolume", 100).toInt();
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
2014-10-29 04:21:37 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
2015-01-24 09:03:26 +08:00
|
|
|
s.beginGroup("Video");
|
2016-07-14 05:01:50 +08:00
|
|
|
{
|
2015-05-14 10:46:28 +08:00
|
|
|
videoDev = s.value("videoDev", "").toString();
|
2016-06-19 03:44:31 +08:00
|
|
|
camVideoRes = s.value("camVideoRes", QRect()).toRect();
|
2016-06-20 07:06:55 +08:00
|
|
|
screenRegion = s.value("screenRegion", QRect()).toRect();
|
|
|
|
screenGrabbed = s.value("screenGrabbed", false).toBool();
|
2016-08-01 03:24:48 +08:00
|
|
|
camVideoFPS = static_cast<quint16>(s.value("camVideoFPS", 0).toUInt());
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
2015-01-24 09:03:26 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
2016-01-23 16:06:17 +08:00
|
|
|
// Read the embedded DHT bootstrap nodes list if needed
|
2014-09-05 05:13:59 +08:00
|
|
|
if (dhtServerList.isEmpty())
|
|
|
|
{
|
|
|
|
QSettings rcs(":/conf/settings.ini", QSettings::IniFormat);
|
2016-01-21 11:59:20 +08:00
|
|
|
rcs.setIniCodec("UTF-8");
|
2014-09-05 05:13:59 +08:00
|
|
|
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();
|
2016-08-01 03:24:48 +08:00
|
|
|
server.port = static_cast<quint16>(rcs.value("port").toUInt());
|
2014-09-05 05:13:59 +08:00
|
|
|
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
|
|
|
|
2016-01-21 10:00:46 +08:00
|
|
|
void Settings::loadPersonal()
|
2015-06-06 21:54:58 +08:00
|
|
|
{
|
|
|
|
Profile* profile = Nexus::getProfile();
|
|
|
|
if (!profile)
|
2014-12-06 11:13:04 +08:00
|
|
|
{
|
2016-01-17 03:08:43 +08:00
|
|
|
qCritical() << "No active profile, couldn't load personal settings";
|
2015-06-06 21:54:58 +08:00
|
|
|
return;
|
2014-12-06 11:13:04 +08:00
|
|
|
}
|
2016-01-21 10:00:46 +08:00
|
|
|
loadPersonal(profile);
|
2014-06-25 04:11:11 +08:00
|
|
|
}
|
|
|
|
|
2016-01-21 10:00:46 +08:00
|
|
|
void Settings::loadPersonal(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
|
|
|
|
2016-01-17 03:08:43 +08:00
|
|
|
qDebug()<<"Loading personal settings from"<<filePath;
|
2015-06-06 21:54:58 +08:00
|
|
|
|
|
|
|
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();
|
2015-10-05 03:45:52 +08:00
|
|
|
|
|
|
|
ps.beginGroup("Privacy");
|
2016-07-14 05:01:50 +08:00
|
|
|
{
|
2015-10-05 03:45:52 +08:00
|
|
|
typingNotification = ps.value("typingNotification", true).toBool();
|
|
|
|
enableLogging = ps.value("enableLogging", true).toBool();
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
2015-10-05 03:45:52 +08:00
|
|
|
ps.endGroup();
|
|
|
|
|
2015-06-06 21:54:58 +08:00
|
|
|
ps.beginGroup("Friends");
|
2016-07-14 05:01:50 +08:00
|
|
|
{
|
2015-06-06 21:54:58 +08:00
|
|
|
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();
|
2015-11-10 04:54:28 +08:00
|
|
|
fp.note = ps.value("note").toString();
|
2015-06-06 21:54:58 +08:00
|
|
|
fp.autoAcceptDir = ps.value("autoAcceptDir").toString();
|
2016-06-26 03:03:52 +08:00
|
|
|
|
|
|
|
if(fp.autoAcceptDir == "")
|
|
|
|
fp.autoAcceptDir = ps.value("autoAccept").toString();
|
|
|
|
|
|
|
|
fp.autoAcceptCall = Settings::AutoAcceptCallFlags(QFlag(ps.value("autoAcceptCall", 0).toInt()));
|
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();
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
2015-06-06 21:54:58 +08:00
|
|
|
ps.endGroup();
|
2015-02-21 20:49:27 +08:00
|
|
|
|
2016-02-21 05:32:57 +08:00
|
|
|
ps.beginGroup("Requests");
|
2016-07-14 05:01:50 +08:00
|
|
|
{
|
|
|
|
int size = ps.beginReadArray("Request");
|
2016-02-25 23:46:40 +08:00
|
|
|
friendRequests.clear();
|
|
|
|
friendRequests.reserve(size);
|
2016-02-21 05:32:57 +08:00
|
|
|
for (int i = 0; i < size; i ++)
|
|
|
|
{
|
|
|
|
ps.setArrayIndex(i);
|
2016-04-21 05:36:02 +08:00
|
|
|
Request request;
|
|
|
|
request.address = ps.value("addr").toString();
|
|
|
|
request.message = ps.value("message").toString();
|
|
|
|
request.read = ps.value("read").toBool();
|
2016-02-21 05:32:57 +08:00
|
|
|
friendRequests.push_back(request);
|
|
|
|
}
|
|
|
|
ps.endArray();
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
2016-02-21 05:32:57 +08:00
|
|
|
ps.endGroup();
|
|
|
|
|
2016-09-13 16:38:42 +08:00
|
|
|
// TODO: values in this group are moved -> remove @ v1.8
|
2016-08-21 06:16:39 +08:00
|
|
|
ps.beginGroup("General");
|
|
|
|
{
|
|
|
|
compactLayout = ps.value("compactLayout", true).toBool();
|
|
|
|
}
|
|
|
|
ps.endGroup();
|
|
|
|
|
2016-07-14 05:01:50 +08:00
|
|
|
ps.beginGroup("GUI");
|
|
|
|
{
|
2016-09-13 16:38:42 +08:00
|
|
|
// TODO: Default values in this block should be changed @ v1.8
|
|
|
|
compactLayout = ps.value("compactLayout", compactLayout).toBool();
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
|
|
|
ps.endGroup();
|
|
|
|
|
|
|
|
ps.beginGroup("Proxy");
|
|
|
|
{
|
2016-09-13 16:38:42 +08:00
|
|
|
int type = ps.value("proxyType", static_cast<int>(getProxyType())).toInt();
|
2016-07-24 19:47:19 +08:00
|
|
|
setProxyType(static_cast<ProxyType>(type));
|
2016-09-13 16:38:42 +08:00
|
|
|
proxyAddr = ps.value("proxyAddr", proxyAddr).toString();
|
|
|
|
proxyPort = static_cast<quint16>(ps.value("proxyPort", proxyPort).toUInt());
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
2015-06-07 07:00:24 +08:00
|
|
|
ps.endGroup();
|
|
|
|
|
2015-05-31 03:10:43 +08:00
|
|
|
ps.beginGroup("Circles");
|
2016-07-14 05:01:50 +08:00
|
|
|
{
|
|
|
|
int 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();
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
2015-05-31 03:10:43 +08:00
|
|
|
ps.endGroup();
|
2016-01-24 05:50:57 +08:00
|
|
|
|
|
|
|
ps.beginGroup("Toxme");
|
2016-07-14 05:01:50 +08:00
|
|
|
{
|
2016-01-24 05:50:57 +08:00
|
|
|
toxmeInfo = ps.value("info", "").toString();
|
|
|
|
toxmeBio = ps.value("bio", "").toString();
|
|
|
|
toxmePriv = ps.value("priv", false).toBool();
|
|
|
|
toxmePass = ps.value("pass", "").toString();
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
2016-01-24 05:50:57 +08:00
|
|
|
ps.endGroup();
|
2015-02-21 20:49:27 +08:00
|
|
|
}
|
|
|
|
|
2016-07-08 21:41:13 +08:00
|
|
|
void Settings::resetToDefault()
|
|
|
|
{
|
|
|
|
// To stop saving
|
|
|
|
loaded = false;
|
|
|
|
|
|
|
|
// Remove file with profile settings
|
|
|
|
QDir dir(getSettingsDirPath());
|
|
|
|
Profile *profile = Nexus::getProfile();
|
|
|
|
QString localPath = dir.filePath(profile->getName() + ".ini");
|
|
|
|
QFile local(localPath);
|
|
|
|
if (local.exists())
|
|
|
|
local.remove();
|
|
|
|
}
|
|
|
|
|
2016-07-27 06:20:54 +08:00
|
|
|
/**
|
2016-08-01 16:21:23 +08:00
|
|
|
* @brief Asynchronous, saves the global settings.
|
|
|
|
*/
|
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};
|
2016-07-08 21:41:13 +08:00
|
|
|
if (!loaded)
|
|
|
|
return;
|
|
|
|
|
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);
|
2016-01-21 11:59:20 +08:00
|
|
|
s.setIniCodec("UTF-8");
|
2014-06-25 04:11:11 +08:00
|
|
|
|
|
|
|
s.clear();
|
|
|
|
|
2015-06-05 21:24:02 +08:00
|
|
|
s.beginGroup("Login");
|
2016-07-14 05:01:50 +08:00
|
|
|
{
|
2015-06-05 21:24:02 +08:00
|
|
|
s.setValue("autoLogin", autoLogin);
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
2015-06-05 21:24:02 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
s.beginGroup("DHT Server");
|
2016-07-14 05:01:50 +08:00
|
|
|
{
|
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();
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
2014-06-25 04:11:11 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
|
|
|
s.beginGroup("General");
|
2016-07-14 05:01:50 +08:00
|
|
|
{
|
2014-10-18 07:06:30 +08:00
|
|
|
s.setValue("translation",translation);
|
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-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-03-22 08:57:28 +08:00
|
|
|
s.setValue("notifySound", notifySound);
|
2016-05-13 03:15:22 +08:00
|
|
|
s.setValue("busySound", busySound);
|
2014-11-10 21:06:35 +08:00
|
|
|
s.setValue("fauxOfflineMessaging", fauxOfflineMessaging);
|
2014-11-17 18:10:38 +08:00
|
|
|
s.setValue("autoSaveEnabled", autoSaveEnabled);
|
|
|
|
s.setValue("globalAutoAcceptDir", globalAutoAcceptDir);
|
2016-07-08 11:07:22 +08:00
|
|
|
s.setValue("stylePreference", static_cast<int>(stylePreference));
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
2014-06-25 04:11:11 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
2014-11-12 20:56:24 +08:00
|
|
|
s.beginGroup("Advanced");
|
2016-07-14 05:01:50 +08:00
|
|
|
{
|
|
|
|
s.setValue("makeToxPortable",makeToxPortable);
|
|
|
|
s.setValue("enableIPv6", enableIPv6);
|
|
|
|
s.setValue("forceTCP", forceTCP);
|
2014-11-12 20:56:24 +08:00
|
|
|
s.setValue("dbSyncType", static_cast<int>(dbSyncType));
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
2014-11-12 20:56:24 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
s.beginGroup("Widgets");
|
2016-07-14 05:01:50 +08:00
|
|
|
{
|
|
|
|
const QList<QString> widgetNames = widgetSettings.keys();
|
|
|
|
for (const QString& name : widgetNames)
|
|
|
|
s.setValue(name, widgetSettings.value(name));
|
|
|
|
}
|
2014-06-25 04:11:11 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
|
|
|
s.beginGroup("GUI");
|
2016-07-14 05:01:50 +08:00
|
|
|
{
|
|
|
|
s.setValue("showWindow", showWindow);
|
|
|
|
s.setValue("showInFront", showInFront);
|
|
|
|
s.setValue("groupAlwaysNotify", groupAlwaysNotify);
|
|
|
|
s.setValue("separateWindow", separateWindow);
|
|
|
|
s.setValue("dontGroupWindows", dontGroupWindows);
|
|
|
|
s.setValue("groupchatPosition", groupchatPosition);
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
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);
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
2014-08-11 23:33:32 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
2016-06-28 19:03:58 +08:00
|
|
|
s.beginGroup("Chat");
|
|
|
|
{
|
|
|
|
s.setValue("chatMessageFont", chatMessageFont);
|
|
|
|
}
|
|
|
|
s.endGroup();
|
|
|
|
|
2014-08-11 23:33:32 +08:00
|
|
|
s.beginGroup("State");
|
2016-07-14 05:01:50 +08:00
|
|
|
{
|
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);
|
2015-07-03 01:16:11 +08:00
|
|
|
s.setValue("dialogGeometry", dialogGeometry);
|
|
|
|
s.setValue("dialogSplitterState", dialogSplitterState);
|
|
|
|
s.setValue("dialogSettingsGeometry", dialogSettingsGeometry);
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
2014-06-25 04:11:11 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
2014-10-29 04:21:37 +08:00
|
|
|
s.beginGroup("Audio");
|
2016-07-14 05:01:50 +08:00
|
|
|
{
|
2014-10-29 04:21:37 +08:00
|
|
|
s.setValue("inDev", inDev);
|
2016-06-27 06:04:19 +08:00
|
|
|
s.setValue("audioInDevEnabled", audioInDevEnabled);
|
2014-10-29 04:21:37 +08:00
|
|
|
s.setValue("outDev", outDev);
|
2016-06-27 06:04:19 +08:00
|
|
|
s.setValue("audioOutDevEnabled", audioOutDevEnabled);
|
2016-05-30 03:40:05 +08:00
|
|
|
s.setValue("inGain", audioInGainDecibel);
|
2015-10-18 16:15:02 +08:00
|
|
|
s.setValue("outVolume", outVolume);
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
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");
|
2016-07-14 05:01:50 +08:00
|
|
|
{
|
2015-05-14 10:46:28 +08:00
|
|
|
s.setValue("videoDev", videoDev);
|
2016-06-20 07:06:55 +08:00
|
|
|
s.setValue("camVideoRes", camVideoRes);
|
|
|
|
s.setValue("camVideoFPS", camVideoFPS);
|
|
|
|
s.setValue("screenRegion", screenRegion);
|
|
|
|
s.setValue("screenGrabbed", screenGrabbed);
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
2015-01-24 09:03:26 +08:00
|
|
|
s.endGroup();
|
2015-02-21 20:49:27 +08:00
|
|
|
}
|
2015-01-24 09:03:26 +08:00
|
|
|
|
2016-07-27 06:20:54 +08:00
|
|
|
/**
|
2016-08-01 16:21:23 +08:00
|
|
|
* @brief Asynchronous, saves the current profile.
|
|
|
|
*/
|
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());
|
|
|
|
}
|
|
|
|
|
2016-07-27 06:20:54 +08:00
|
|
|
/**
|
2016-08-01 16:21:23 +08:00
|
|
|
* @brief Asynchronous, saves the profile.
|
|
|
|
* @param profile Profile to save.
|
|
|
|
*/
|
2015-06-06 21:54:58 +08:00
|
|
|
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
|
|
|
|
2016-06-18 12:49:40 +08:00
|
|
|
void Settings::savePersonal(QString profileName, const QString &password)
|
2015-06-06 21:54:58 +08:00
|
|
|
{
|
|
|
|
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};
|
2016-07-08 21:41:13 +08:00
|
|
|
if (!loaded)
|
|
|
|
return;
|
2015-06-06 21:54:58 +08:00
|
|
|
|
|
|
|
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");
|
2016-07-14 05:01:50 +08:00
|
|
|
{
|
2015-02-21 20:49:27 +08:00
|
|
|
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);
|
2015-11-10 04:54:28 +08:00
|
|
|
ps.setValue("note", frnd.note);
|
2015-02-21 20:49:27 +08:00
|
|
|
ps.setValue("autoAcceptDir", frnd.autoAcceptDir);
|
2016-06-26 03:03:52 +08:00
|
|
|
ps.setValue("autoAcceptCall", static_cast<int>(frnd.autoAcceptCall));
|
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);
|
|
|
|
|
2016-02-21 05:32:57 +08:00
|
|
|
++index;
|
|
|
|
}
|
|
|
|
ps.endArray();
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
2016-02-21 05:32:57 +08:00
|
|
|
ps.endGroup();
|
|
|
|
|
|
|
|
ps.beginGroup("Requests");
|
2016-07-14 05:01:50 +08:00
|
|
|
{
|
2016-02-21 05:32:57 +08:00
|
|
|
ps.beginWriteArray("Request", friendRequests.size());
|
2016-07-14 05:01:50 +08:00
|
|
|
int index = 0;
|
2016-02-21 05:32:57 +08:00
|
|
|
for (auto& request : friendRequests)
|
|
|
|
{
|
|
|
|
ps.setArrayIndex(index);
|
2016-04-21 05:36:02 +08:00
|
|
|
ps.setValue("addr", request.address);
|
|
|
|
ps.setValue("message", request.message);
|
|
|
|
ps.setValue("read", request.read);
|
2016-02-21 05:32:57 +08:00
|
|
|
|
|
|
|
++index;
|
2015-02-21 20:49:27 +08:00
|
|
|
}
|
|
|
|
ps.endArray();
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
2015-02-21 20:49:27 +08:00
|
|
|
ps.endGroup();
|
|
|
|
|
2016-07-14 05:01:50 +08:00
|
|
|
ps.beginGroup("GUI");
|
|
|
|
{
|
2015-06-07 07:00:24 +08:00
|
|
|
ps.setValue("compactLayout", compactLayout);
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
|
|
|
ps.endGroup();
|
|
|
|
|
|
|
|
ps.beginGroup("Proxy");
|
|
|
|
{
|
|
|
|
ps.setValue("proxyType", static_cast<int>(proxyType));
|
|
|
|
ps.setValue("proxyAddr", proxyAddr);
|
|
|
|
ps.setValue("proxyPort", proxyPort);
|
|
|
|
}
|
2015-06-07 07:00:24 +08:00
|
|
|
ps.endGroup();
|
|
|
|
|
2015-05-31 03:10:43 +08:00
|
|
|
ps.beginGroup("Circles");
|
2016-07-14 05:01:50 +08:00
|
|
|
{
|
2015-05-31 03:10:43 +08:00
|
|
|
ps.beginWriteArray("Circle", circleLst.size());
|
2016-07-14 05:01:50 +08:00
|
|
|
int index = 0;
|
2015-05-31 03:10:43 +08:00
|
|
|
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();
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
2015-05-31 03:10:43 +08:00
|
|
|
ps.endGroup();
|
|
|
|
|
2015-02-21 20:49:27 +08:00
|
|
|
ps.beginGroup("Privacy");
|
2016-07-14 05:01:50 +08:00
|
|
|
{
|
2015-02-21 20:49:27 +08:00
|
|
|
ps.setValue("typingNotification", typingNotification);
|
|
|
|
ps.setValue("enableLogging", enableLogging);
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
2015-02-21 20:49:27 +08:00
|
|
|
ps.endGroup();
|
2015-06-06 21:54:58 +08:00
|
|
|
|
2016-01-24 05:50:57 +08:00
|
|
|
ps.beginGroup("Toxme");
|
2016-07-14 05:01:50 +08:00
|
|
|
{
|
2016-01-24 05:50:57 +08:00
|
|
|
ps.setValue("info", toxmeInfo);
|
|
|
|
ps.setValue("bio", toxmeBio);
|
|
|
|
ps.setValue("priv", toxmePriv);
|
|
|
|
ps.setValue("pass", toxmePass);
|
2016-07-14 05:01:50 +08:00
|
|
|
}
|
2016-01-24 05:50:57 +08:00
|
|
|
ps.endGroup();
|
|
|
|
|
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);
|
2016-08-01 03:24:48 +08:00
|
|
|
const uint32_t* dwords = reinterpret_cast<const uint32_t*>(data.constData());
|
2015-02-20 20:26:41 +08:00
|
|
|
return dwords[0] ^ dwords[1] ^ dwords[2] ^ dwords[3];
|
2014-06-25 04:11:11 +08:00
|
|
|
}
|
|
|
|
|
2016-07-27 06:20:54 +08:00
|
|
|
/**
|
2016-08-01 16:21:23 +08:00
|
|
|
* @brief Get path to directory, where the settings files are stored.
|
|
|
|
* @return Path to settings directory, ends with a directory separator.
|
|
|
|
*/
|
2016-08-05 01:56:23 +08:00
|
|
|
QString Settings::getSettingsDirPath() const
|
2014-06-25 04:11:11 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-07-13 04:58:58 +08:00
|
|
|
if (makeToxPortable)
|
2016-05-09 21:53:27 +08:00
|
|
|
return qApp->applicationDirPath()+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();
|
2016-01-19 03:36:35 +08:00
|
|
|
#elif defined(Q_OS_OSX)
|
|
|
|
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator()
|
|
|
|
+ "Library" + QDir::separator() + "Application Support" + 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
|
|
|
|
}
|
|
|
|
|
2016-07-27 06:20:54 +08:00
|
|
|
/**
|
2016-08-01 16:21:23 +08:00
|
|
|
* @brief Get path to directory, where the application data are stored.
|
|
|
|
* @return Path to application data, ends with a directory separator.
|
|
|
|
*/
|
2016-08-05 01:56:23 +08:00
|
|
|
QString Settings::getAppDataDirPath() const
|
2016-02-28 22:16:19 +08:00
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
if (makeToxPortable)
|
2016-05-09 21:53:27 +08:00
|
|
|
return qApp->applicationDirPath()+QDir::separator();
|
2016-02-28 22:16:19 +08:00
|
|
|
|
|
|
|
// workaround for https://bugreports.qt-project.org/browse/QTBUG-38845
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator()
|
|
|
|
+ "AppData" + QDir::separator() + "Roaming" + QDir::separator() + "tox")+QDir::separator();
|
|
|
|
#elif defined(Q_OS_OSX)
|
|
|
|
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator()
|
|
|
|
+ "Library" + QDir::separator() + "Application Support" + QDir::separator() + "Tox")+QDir::separator();
|
|
|
|
#else
|
2016-08-19 03:48:44 +08:00
|
|
|
/*
|
2016-08-15 17:00:06 +08:00
|
|
|
* TODO: Change QStandardPaths::DataLocation to AppDataLocation when upgrate Qt to 5.4+
|
2016-08-01 16:28:28 +08:00
|
|
|
* For now we need support Qt 5.3, so we use deprecated DataLocation
|
|
|
|
* BTW, it's not a big deal since for linux AppDataLocation and DataLocation are equal
|
|
|
|
*/
|
2016-03-23 16:56:21 +08:00
|
|
|
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::DataLocation))+QDir::separator();
|
2016-02-28 22:16:19 +08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-07-27 06:20:54 +08:00
|
|
|
/**
|
2016-08-01 16:21:23 +08:00
|
|
|
* @brief Get path to directory, where the application cache are stored.
|
|
|
|
* @return Path to application cache, ends with a directory separator.
|
|
|
|
*/
|
2016-08-05 01:56:23 +08:00
|
|
|
QString Settings::getAppCacheDirPath() const
|
2016-02-28 22:16:19 +08:00
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
if (makeToxPortable)
|
2016-05-09 21:53:27 +08:00
|
|
|
return qApp->applicationDirPath()+QDir::separator();
|
2016-02-28 22:16:19 +08:00
|
|
|
|
|
|
|
// workaround for https://bugreports.qt-project.org/browse/QTBUG-38845
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator()
|
|
|
|
+ "AppData" + QDir::separator() + "Roaming" + QDir::separator() + "tox")+QDir::separator();
|
|
|
|
#elif defined(Q_OS_OSX)
|
|
|
|
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator()
|
|
|
|
+ "Library" + QDir::separator() + "Application Support" + QDir::separator() + "Tox")+QDir::separator();
|
|
|
|
#else
|
2016-03-23 16:56:21 +08:00
|
|
|
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation))+QDir::separator();
|
2016-02-28 22:16:19 +08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newDhtServerList != dhtServerList)
|
|
|
|
{
|
|
|
|
dhtServerList = newDhtServerList;
|
|
|
|
emit dhtServerListChanged(dhtServerList);
|
|
|
|
}
|
2014-06-25 04:11:11 +08:00
|
|
|
}
|
|
|
|
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newValue != enableIPv6)
|
|
|
|
{
|
|
|
|
enableIPv6 = newValue;
|
|
|
|
emit enableIPv6Changed(enableIPv6);
|
|
|
|
}
|
2014-07-02 06:47:06 +08:00
|
|
|
}
|
|
|
|
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newValue != makeToxPortable)
|
|
|
|
{
|
|
|
|
QFile(getSettingsDirPath() + globalSettingsFile).remove();
|
|
|
|
makeToxPortable = newValue;
|
|
|
|
saveGlobal();
|
|
|
|
|
|
|
|
emit makeToxPortableChanged(makeToxPortable);
|
|
|
|
}
|
2014-07-13 04:58:58 +08:00
|
|
|
}
|
|
|
|
|
2014-12-17 21:44:23 +08:00
|
|
|
bool Settings::getAutorun() const
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
#ifdef QTOX_PLATFORM_EXT
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
bool autorun = Platform::getAutorun();
|
|
|
|
|
|
|
|
if (newValue != autorun)
|
|
|
|
{
|
|
|
|
Platform::setAutorun(newValue);
|
|
|
|
emit autorunChanged(autorun);
|
|
|
|
}
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newStyle != style)
|
|
|
|
{
|
|
|
|
style = newStyle;
|
|
|
|
emit styleChanged(style);
|
|
|
|
}
|
2014-10-09 06:31:20 +08:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
void Settings::setShowSystemTray(bool newValue)
|
2014-11-14 04:33:11 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newValue != showSystemTray)
|
|
|
|
{
|
|
|
|
showSystemTray = newValue;
|
|
|
|
emit showSystemTrayChanged(newValue);
|
|
|
|
}
|
2014-11-14 04:33:11 +08:00
|
|
|
}
|
|
|
|
|
2014-11-05 23:20:32 +08:00
|
|
|
void Settings::setUseEmoticons(bool newValue)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newValue != useEmoticons)
|
|
|
|
{
|
|
|
|
useEmoticons = newValue;
|
|
|
|
emit useEmoticonsChanged(useEmoticons);
|
|
|
|
}
|
2014-11-05 23:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newValue != autoSaveEnabled)
|
|
|
|
{
|
|
|
|
autoSaveEnabled = newValue;
|
|
|
|
emit autoSaveEnabledChanged(autoSaveEnabled);
|
|
|
|
}
|
2014-11-05 23:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newValue != autostartInTray)
|
|
|
|
{
|
|
|
|
autostartInTray = newValue;
|
|
|
|
emit autostartInTrayChanged(autostartInTray);
|
|
|
|
}
|
2014-10-08 22:17:05 +08:00
|
|
|
}
|
|
|
|
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newValue != closeToTray)
|
|
|
|
{
|
|
|
|
closeToTray = newValue;
|
|
|
|
emit closeToTrayChanged(newValue);
|
|
|
|
}
|
2014-10-20 03:47:06 +08:00
|
|
|
}
|
|
|
|
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newValue != minimizeToTray)
|
|
|
|
{
|
|
|
|
minimizeToTray = newValue;
|
|
|
|
emit minimizeToTrayChanged(minimizeToTray);
|
|
|
|
}
|
2014-10-20 19:50:12 +08:00
|
|
|
}
|
|
|
|
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newValue != lightTrayIcon)
|
|
|
|
{
|
|
|
|
lightTrayIcon = newValue;
|
|
|
|
emit lightTrayIconChanged(lightTrayIcon);
|
|
|
|
}
|
2014-12-12 03:34:12 +08:00
|
|
|
}
|
|
|
|
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newValue != statusChangeNotificationEnabled)
|
|
|
|
{
|
|
|
|
statusChangeNotificationEnabled = newValue;
|
|
|
|
emit statusChangeNotificationEnabledChanged(statusChangeNotificationEnabled);
|
|
|
|
}
|
2014-10-11 07:18:32 +08:00
|
|
|
}
|
|
|
|
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newValue != showInFront)
|
|
|
|
{
|
|
|
|
showInFront = newValue;
|
|
|
|
emit showInFrontChanged(showInFront);
|
|
|
|
}
|
2015-01-21 19:10:41 +08:00
|
|
|
}
|
|
|
|
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newValue != notifySound)
|
|
|
|
{
|
|
|
|
notifySound = newValue;
|
|
|
|
emit notifySoundChanged(notifySound);
|
|
|
|
}
|
2015-03-22 08:57:28 +08:00
|
|
|
}
|
|
|
|
|
2016-05-13 03:15:22 +08:00
|
|
|
bool Settings::getBusySound() const
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
return busySound;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setBusySound(bool newValue)
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newValue != busySound)
|
|
|
|
{
|
|
|
|
busySound = newValue;
|
|
|
|
emit busySoundChanged(busySound);
|
|
|
|
}
|
2016-05-13 03:15:22 +08:00
|
|
|
}
|
|
|
|
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newValue != groupAlwaysNotify)
|
|
|
|
{
|
|
|
|
groupAlwaysNotify = newValue;
|
|
|
|
emit groupAlwaysNotifyChanged(groupAlwaysNotify);
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
void Settings::setTranslation(const QString& newValue)
|
2014-07-05 01:22:43 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newValue != translation)
|
|
|
|
{
|
|
|
|
translation = newValue;
|
|
|
|
emit translationChanged(translation);
|
|
|
|
}
|
2014-10-06 04:49:44 +08:00
|
|
|
}
|
|
|
|
|
2016-01-24 05:50:57 +08:00
|
|
|
void Settings::deleteToxme()
|
|
|
|
{
|
|
|
|
setToxmeInfo("");
|
|
|
|
setToxmeBio("");
|
2016-08-01 03:24:48 +08:00
|
|
|
setToxmePriv(false);
|
2016-01-24 05:50:57 +08:00
|
|
|
setToxmePass("");
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setToxme(QString name, QString server, QString bio, bool priv, QString pass)
|
|
|
|
{
|
|
|
|
setToxmeInfo(name + "@" + server);
|
|
|
|
setToxmeBio(bio);
|
|
|
|
setToxmePriv(priv);
|
|
|
|
if (!pass.isEmpty())
|
|
|
|
setToxmePass(pass);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Settings::getToxmeInfo() const
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
return toxmeInfo;
|
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
void Settings::setToxmeInfo(const QString& info)
|
2016-01-24 05:50:57 +08:00
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (info != toxmeInfo)
|
|
|
|
{
|
|
|
|
if (info.split("@").size() == 2)
|
|
|
|
{
|
|
|
|
toxmeInfo = info;
|
|
|
|
emit toxmeInfoChanged(toxmeInfo);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qWarning() << info << "is not a valid toxme string -> value ignored.";
|
|
|
|
}
|
|
|
|
}
|
2016-01-24 05:50:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
QString Settings::getToxmeBio() const
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
return toxmeBio;
|
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
void Settings::setToxmeBio(const QString& bio)
|
2016-01-24 05:50:57 +08:00
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (bio != toxmeBio)
|
|
|
|
{
|
|
|
|
toxmeBio = bio;
|
|
|
|
emit toxmeBioChanged(toxmeBio);
|
|
|
|
}
|
2016-01-24 05:50:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Settings::getToxmePriv() const
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
return toxmePriv;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setToxmePriv(bool priv)
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (priv != toxmePriv)
|
|
|
|
{
|
|
|
|
toxmePriv = priv;
|
|
|
|
emit toxmePrivChanged(toxmePriv);
|
|
|
|
}
|
2016-01-24 05:50:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
QString Settings::getToxmePass() const
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
return toxmePass;
|
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
void Settings::setToxmePass(const QString& pass)
|
2016-01-24 05:50:57 +08:00
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (pass != toxmePass)
|
|
|
|
{
|
|
|
|
toxmePass = pass;
|
|
|
|
|
|
|
|
// password is not exposed for security reasons
|
|
|
|
emit toxmePassChanged();
|
|
|
|
}
|
2016-01-24 05:50:57 +08:00
|
|
|
}
|
|
|
|
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newValue != forceTCP)
|
|
|
|
{
|
|
|
|
forceTCP = newValue;
|
|
|
|
emit forceTCPChanged(forceTCP);
|
|
|
|
}
|
2014-10-06 04:49:44 +08:00
|
|
|
}
|
|
|
|
|
2016-01-19 07:19:07 +08:00
|
|
|
QNetworkProxy Settings::getProxy() const
|
|
|
|
{
|
|
|
|
QNetworkProxy proxy;
|
|
|
|
switch(Settings::getProxyType())
|
|
|
|
{
|
|
|
|
case ProxyType::ptNone:
|
|
|
|
proxy.setType(QNetworkProxy::NoProxy);
|
|
|
|
break;
|
|
|
|
case ProxyType::ptSOCKS5:
|
|
|
|
proxy.setType(QNetworkProxy::Socks5Proxy);
|
|
|
|
break;
|
|
|
|
case ProxyType::ptHTTP:
|
|
|
|
proxy.setType(QNetworkProxy::HttpProxy);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
proxy.setType(QNetworkProxy::NoProxy);
|
|
|
|
qWarning() << "Invalid Proxy type, setting to NoProxy";
|
2016-08-01 03:24:48 +08:00
|
|
|
break;
|
2016-01-19 07:19:07 +08:00
|
|
|
}
|
2016-08-01 03:24:48 +08:00
|
|
|
|
2016-01-19 07:19:07 +08:00
|
|
|
proxy.setHostName(Settings::getProxyAddr());
|
|
|
|
proxy.setPort(Settings::getProxyPort());
|
|
|
|
return proxy;
|
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
Settings::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
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
void Settings::setProxyType(ProxyType newValue)
|
2014-10-07 10:09:15 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newValue != proxyType)
|
|
|
|
{
|
|
|
|
proxyType = newValue;
|
|
|
|
emit proxyTypeChanged(proxyType);
|
|
|
|
}
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newValue != proxyAddr)
|
|
|
|
{
|
|
|
|
proxyAddr = newValue;
|
|
|
|
emit proxyAddressChanged(proxyAddr);
|
|
|
|
}
|
2014-10-06 04:49:44 +08:00
|
|
|
}
|
|
|
|
|
2016-08-01 03:24:48 +08:00
|
|
|
quint16 Settings::getProxyPort() const
|
2014-10-06 04:49:44 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2014-10-06 04:49:44 +08:00
|
|
|
return proxyPort;
|
|
|
|
}
|
|
|
|
|
2016-08-01 03:24:48 +08:00
|
|
|
void Settings::setProxyPort(quint16 newValue)
|
2014-10-06 04:49:44 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newValue != proxyPort)
|
|
|
|
{
|
|
|
|
proxyPort = newValue;
|
|
|
|
emit proxyPortChanged(proxyPort);
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
void Settings::setCurrentProfile(const QString& profile)
|
2014-10-11 06:43:15 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (profile != currentProfile)
|
|
|
|
{
|
|
|
|
currentProfile = profile;
|
|
|
|
currentProfileId = makeProfileId(currentProfile);
|
|
|
|
emit currentProfileChanged(currentProfile);
|
|
|
|
emit currentProfileIdChanged(currentProfileId);
|
|
|
|
}
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newValue != enableLogging)
|
|
|
|
{
|
|
|
|
enableLogging = newValue;
|
|
|
|
emit enableLoggingChanged(enableLogging);
|
|
|
|
}
|
2014-06-25 04:11:11 +08:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
void Settings::setDbSyncType(Db::syncType newValue)
|
2014-11-12 20:56:24 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newValue != dbSyncType)
|
|
|
|
{
|
|
|
|
dbSyncType = newValue;
|
|
|
|
emit dbSyncTypeChanged(dbSyncType);
|
|
|
|
}
|
2014-11-12 20:56:24 +08:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
/**
|
|
|
|
* @brief Sets how long the user may stay idle, before online status is set to "away".
|
|
|
|
* @param[in] newValue the user idle duration in minutes
|
|
|
|
* @note Values < 0 default to 10 minutes.
|
|
|
|
*/
|
2014-10-16 17:47:58 +08:00
|
|
|
void Settings::setAutoAwayTime(int newValue)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
2014-10-16 17:47:58 +08:00
|
|
|
if (newValue < 0)
|
|
|
|
newValue = 10;
|
2015-04-24 19:01:50 +08:00
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
if (newValue != autoAwayTime)
|
|
|
|
{
|
|
|
|
autoAwayTime = newValue;
|
|
|
|
emit autoAwayTimeChanged(autoAwayTime);
|
|
|
|
}
|
2014-10-16 17:47:58 +08:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
{
|
2016-08-08 19:40:55 +08:00
|
|
|
updateFriendAddress(id.toString());
|
2014-11-17 18:10:38 +08:00
|
|
|
setAutoAcceptDir(id, dir);
|
|
|
|
}
|
2014-10-18 11:02:13 +08:00
|
|
|
}
|
|
|
|
|
2016-06-26 03:03:52 +08:00
|
|
|
Settings::AutoAcceptCallFlags Settings::getAutoAcceptCall(const ToxId &id) const
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
QString key = id.publicKey;
|
|
|
|
|
|
|
|
auto it = friendLst.find(key);
|
|
|
|
if (it != friendLst.end())
|
|
|
|
return it->autoAcceptCall;
|
|
|
|
|
|
|
|
return Settings::AutoAcceptCallFlags();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setAutoAcceptCall(const ToxId& id, AutoAcceptCallFlags accept)
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
QString key = id.publicKey;
|
|
|
|
|
|
|
|
auto it = friendLst.find(key);
|
|
|
|
if(it != friendLst.end())
|
|
|
|
{
|
|
|
|
it->autoAcceptCall = accept;
|
|
|
|
emit autoAcceptCallChanged(id, accept);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-10 04:54:28 +08:00
|
|
|
QString Settings::getContactNote(const ToxId &id) const
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
|
|
|
|
auto it = friendLst.find(id.publicKey);
|
|
|
|
if (it != friendLst.end())
|
|
|
|
return it->note;
|
|
|
|
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setContactNote(const ToxId &id, const QString& note)
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
|
|
|
|
auto it = friendLst.find(id.publicKey);
|
|
|
|
if (it != friendLst.end())
|
|
|
|
{
|
|
|
|
qDebug() << note;
|
|
|
|
it->note = note;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-08-08 19:40:55 +08:00
|
|
|
updateFriendAddress(id.toString());
|
2015-11-10 04:54:28 +08:00
|
|
|
setContactNote(id, note);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newValue != globalAutoAcceptDir)
|
|
|
|
{
|
|
|
|
globalAutoAcceptDir = newValue;
|
|
|
|
emit globalAutoAcceptDirChanged(globalAutoAcceptDir);
|
|
|
|
}
|
2014-10-20 12:25:52 +08:00
|
|
|
}
|
|
|
|
|
2016-06-28 19:03:58 +08:00
|
|
|
const QFont& Settings::getChatMessageFont() const
|
|
|
|
{
|
|
|
|
QMutexLocker locker(&bigLock);
|
|
|
|
return chatMessageFont;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setChatMessageFont(const QFont& font)
|
|
|
|
{
|
|
|
|
QMutexLocker locker(&bigLock);
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (font != chatMessageFont)
|
|
|
|
{
|
|
|
|
chatMessageFont = font;
|
|
|
|
emit chatMessageFontChanged(chatMessageFont);
|
|
|
|
}
|
2016-06-28 19:03:58 +08:00
|
|
|
}
|
|
|
|
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (!widgetSettings.contains(uniqueName) ||
|
|
|
|
widgetSettings[uniqueName] != data)
|
|
|
|
{
|
|
|
|
widgetSettings[uniqueName] = data;
|
|
|
|
emit widgetDataChanged(uniqueName);
|
|
|
|
}
|
2014-06-25 04:11:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (value != smileyPack)
|
|
|
|
{
|
|
|
|
smileyPack = value;
|
|
|
|
emit smileyPackChanged(smileyPack);
|
|
|
|
}
|
2014-06-25 04:11:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
if (value != emojiFontPointSize)
|
|
|
|
{
|
|
|
|
emojiFontPointSize = value;
|
|
|
|
emit emojiFontPointSizeChanged(emojiFontPointSize);
|
|
|
|
}
|
2014-06-25 04:11:11 +08:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
void Settings::setTimestampFormat(const QString& format)
|
2014-06-25 04:11:11 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (format != timestampFormat)
|
|
|
|
{
|
|
|
|
timestampFormat = format;
|
|
|
|
emit timestampFormatChanged(timestampFormat);
|
|
|
|
}
|
2014-06-25 04:11:11 +08:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
void Settings::setDateFormat(const QString& format)
|
2015-03-15 04:15:56 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (format != dateFormat)
|
|
|
|
{
|
|
|
|
dateFormat = format;
|
|
|
|
emit dateFormatChanged(dateFormat);
|
|
|
|
}
|
2015-03-15 04:15:56 +08:00
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
Settings::StyleType Settings::getStylePreference() const
|
2016-01-23 16:06:17 +08:00
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
2016-07-08 11:07:22 +08:00
|
|
|
return stylePreference;
|
2016-01-23 16:06:17 +08:00
|
|
|
}
|
|
|
|
|
2016-07-08 11:07:22 +08:00
|
|
|
void Settings::setStylePreference(StyleType newValue)
|
2016-01-23 16:06:17 +08:00
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newValue != stylePreference)
|
|
|
|
{
|
|
|
|
stylePreference = newValue;
|
|
|
|
emit stylePreferenceChanged(stylePreference);
|
|
|
|
}
|
2016-01-23 16:06:17 +08:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
void Settings::setWindowGeometry(const QByteArray& value)
|
2014-08-11 16:00:08 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (value != windowGeometry)
|
|
|
|
{
|
|
|
|
windowGeometry = value;
|
|
|
|
emit windowGeometryChanged(windowGeometry);
|
|
|
|
}
|
2014-08-11 16:00:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
void Settings::setWindowState(const QByteArray& value)
|
2014-08-11 16:00:08 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (value != windowState)
|
|
|
|
{
|
|
|
|
windowState = value;
|
|
|
|
emit windowStateChanged(windowState);
|
|
|
|
}
|
2014-08-11 16:00:08 +08:00
|
|
|
}
|
|
|
|
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newValue != checkUpdates)
|
|
|
|
{
|
|
|
|
checkUpdates = newValue;
|
|
|
|
emit checkUpdatesChanged(checkUpdates);
|
|
|
|
}
|
2014-11-10 07:31:29 +08:00
|
|
|
}
|
|
|
|
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newValue != showWindow)
|
|
|
|
{
|
|
|
|
showWindow = newValue;
|
|
|
|
emit showWindowChanged(showWindow);
|
|
|
|
}
|
2015-01-21 19:10:41 +08:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
void Settings::setSplitterState(const QByteArray& value)
|
2014-08-11 20:07:27 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if(value != splitterState)
|
|
|
|
{
|
|
|
|
splitterState = value;
|
|
|
|
emit splitterStateChanged(splitterState);
|
|
|
|
}
|
2014-08-11 20:07:27 +08:00
|
|
|
}
|
|
|
|
|
2015-06-19 22:58:48 +08:00
|
|
|
QByteArray Settings::getDialogGeometry() const
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
return dialogGeometry;
|
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
void Settings::setDialogGeometry(const QByteArray& value)
|
2015-06-19 22:58:48 +08:00
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (value != dialogGeometry)
|
|
|
|
{
|
|
|
|
dialogGeometry = value;
|
|
|
|
emit dialogGeometryChanged(dialogGeometry);
|
|
|
|
}
|
2015-06-19 22:58:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray Settings::getDialogSplitterState() const
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
return dialogSplitterState;
|
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
void Settings::setDialogSplitterState(const QByteArray& value)
|
2015-06-19 22:58:48 +08:00
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (value != dialogSplitterState)
|
|
|
|
{
|
|
|
|
dialogSplitterState = value;
|
|
|
|
emit dialogSplitterStateChanged(dialogSplitterState);
|
|
|
|
}
|
2015-06-19 22:58:48 +08:00
|
|
|
}
|
|
|
|
|
2015-07-03 01:16:11 +08:00
|
|
|
QByteArray Settings::getDialogSettingsGeometry() const
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
return dialogSettingsGeometry;
|
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
void Settings::setDialogSettingsGeometry(const QByteArray& value)
|
2015-07-03 01:16:11 +08:00
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (value != dialogSettingsGeometry)
|
|
|
|
{
|
|
|
|
dialogSettingsGeometry = value;
|
|
|
|
emit dialogSettingsGeometryChanged(dialogSettingsGeometry);
|
|
|
|
}
|
2015-07-03 01:16:11 +08:00
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
bool Settings::getMinimizeOnClose() 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 minimizeOnClose;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setMinimizeOnClose(bool newValue)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newValue != minimizeOnClose)
|
|
|
|
{
|
|
|
|
minimizeOnClose = newValue;
|
|
|
|
emit minimizeOnCloseChanged(minimizeOnClose);
|
|
|
|
}
|
2014-06-25 04:11:11 +08:00
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
bool Settings::getTypingNotification() 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 typingNotification;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setTypingNotification(bool enabled)
|
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (enabled != typingNotification)
|
|
|
|
{
|
|
|
|
typingNotification = enabled;
|
|
|
|
emit typingNotificationChanged(typingNotification);
|
|
|
|
}
|
2014-06-25 04:11:11 +08:00
|
|
|
}
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (deviceSpecifier != inDev)
|
|
|
|
{
|
|
|
|
inDev = deviceSpecifier;
|
|
|
|
emit inDevChanged(inDev);
|
|
|
|
}
|
2014-10-29 04:21:37 +08:00
|
|
|
}
|
|
|
|
|
2016-06-27 06:04:19 +08:00
|
|
|
bool Settings::getAudioInDevEnabled() const
|
|
|
|
{
|
|
|
|
QMutexLocker locker(&bigLock);
|
|
|
|
return audioInDevEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setAudioInDevEnabled(bool enabled)
|
|
|
|
{
|
|
|
|
QMutexLocker locker(&bigLock);
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (enabled != audioInDevEnabled)
|
|
|
|
{
|
|
|
|
audioInDevEnabled = enabled;
|
|
|
|
emit audioInDevEnabledChanged(enabled);
|
|
|
|
}
|
2016-06-27 06:04:19 +08:00
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
qreal Settings::getAudioInGainDecibel() const
|
2015-10-18 16:15:02 +08:00
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
2016-05-30 03:40:05 +08:00
|
|
|
return audioInGainDecibel;
|
2015-10-18 16:15:02 +08:00
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
void Settings::setAudioInGainDecibel(qreal dB)
|
2015-10-18 16:15:02 +08:00
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (dB < audioInGainDecibel || dB > audioInGainDecibel)
|
|
|
|
{
|
|
|
|
audioInGainDecibel = dB;
|
|
|
|
emit audioInGainDecibelChanged(audioInGainDecibel);
|
|
|
|
}
|
2015-10-18 16:15:02 +08:00
|
|
|
}
|
|
|
|
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if(deviceSpecifier != videoDev)
|
|
|
|
{
|
|
|
|
videoDev = deviceSpecifier;
|
|
|
|
emit videoDevChanged(videoDev);
|
|
|
|
}
|
2015-05-14 10:46:28 +08:00
|
|
|
}
|
|
|
|
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (deviceSpecifier != outDev)
|
|
|
|
{
|
|
|
|
outDev = deviceSpecifier;
|
|
|
|
emit outDevChanged(outDev);
|
|
|
|
}
|
2014-10-29 04:21:37 +08:00
|
|
|
}
|
2014-11-08 00:02:10 +08:00
|
|
|
|
2016-06-27 06:04:19 +08:00
|
|
|
bool Settings::getAudioOutDevEnabled() const
|
|
|
|
{
|
|
|
|
QMutexLocker locker(&bigLock);
|
|
|
|
return audioOutDevEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setAudioOutDevEnabled(bool enabled)
|
|
|
|
{
|
|
|
|
QMutexLocker locker(&bigLock);
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if(enabled != audioOutDevEnabled)
|
|
|
|
{
|
|
|
|
audioOutDevEnabled = enabled;
|
|
|
|
emit audioOutDevEnabledChanged(audioOutDevEnabled);
|
|
|
|
}
|
2016-06-27 06:04:19 +08:00
|
|
|
}
|
|
|
|
|
2015-10-18 16:15:02 +08:00
|
|
|
int Settings::getOutVolume() const
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
return outVolume;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setOutVolume(int volume)
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (volume != outVolume)
|
|
|
|
{
|
|
|
|
outVolume = volume;
|
|
|
|
emit outVolumeChanged(outVolume);
|
|
|
|
}
|
2015-10-18 16:15:02 +08:00
|
|
|
}
|
|
|
|
|
2016-06-20 07:06:55 +08:00
|
|
|
QRect Settings::getScreenRegion() const
|
|
|
|
{
|
2016-08-08 19:40:55 +08:00
|
|
|
QMutexLocker locker (&bigLock);
|
2016-06-20 07:06:55 +08:00
|
|
|
return screenRegion;
|
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
void Settings::setScreenRegion(const QRect& value)
|
2016-06-20 07:06:55 +08:00
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (value != screenRegion)
|
|
|
|
{
|
|
|
|
screenRegion = value;
|
|
|
|
emit screenRegionChanged(screenRegion);
|
|
|
|
}
|
2016-06-20 07:06:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Settings::getScreenGrabbed() const
|
|
|
|
{
|
2016-08-08 19:40:55 +08:00
|
|
|
QMutexLocker locker(&bigLock);
|
2016-06-20 07:06:55 +08:00
|
|
|
return screenGrabbed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setScreenGrabbed(bool value)
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (value != screenGrabbed)
|
|
|
|
{
|
|
|
|
screenGrabbed = value;
|
|
|
|
emit screenGrabbedChanged(screenGrabbed);
|
|
|
|
}
|
2016-06-20 07:06:55 +08:00
|
|
|
}
|
|
|
|
|
2016-06-19 03:44:31 +08:00
|
|
|
QRect Settings::getCamVideoRes() const
|
2015-01-24 09:03:26 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2015-01-24 09:03:26 +08:00
|
|
|
return camVideoRes;
|
|
|
|
}
|
|
|
|
|
2016-06-19 03:44:31 +08:00
|
|
|
void Settings::setCamVideoRes(QRect newValue)
|
2015-01-24 09:03:26 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newValue != camVideoRes)
|
|
|
|
{
|
|
|
|
camVideoRes = newValue;
|
|
|
|
emit camVideoResChanged(camVideoRes);
|
|
|
|
}
|
2015-01-24 09:03:26 +08:00
|
|
|
}
|
|
|
|
|
2015-08-19 05:44:34 +08:00
|
|
|
unsigned short Settings::getCamVideoFPS() const
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
return camVideoFPS;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setCamVideoFPS(unsigned short newValue)
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (newValue != camVideoFPS)
|
|
|
|
{
|
|
|
|
camVideoFPS = newValue;
|
|
|
|
emit camVideoFPSChanged(camVideoFPS);
|
|
|
|
}
|
2015-08-19 05:44:34 +08:00
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
QString Settings::getFriendAddress(const QString& publicKey) const
|
2014-11-08 00:02:10 +08:00
|
|
|
{
|
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();
|
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
void Settings::updateFriendAddress(const QString& newAddr)
|
2014-11-08 00:02:10 +08:00
|
|
|
{
|
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 = "";
|
2015-11-10 04:54:28 +08:00
|
|
|
fp.note = "";
|
2014-11-17 18:10:38 +08:00
|
|
|
fp.autoAcceptDir = "";
|
2014-11-08 00:02:10 +08:00
|
|
|
friendLst[newAddr] = fp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +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();
|
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +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;
|
2015-11-10 04:54:28 +08:00
|
|
|
fp.note = "";
|
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
|
|
|
|
2016-08-08 19:40:55 +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;
|
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +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 = "";
|
2015-11-10 04:54:28 +08:00
|
|
|
fp.note = "";
|
2015-06-06 01:38:07 +08:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
QDate Settings::getFriendActivity(const ToxId& id) const
|
2015-06-12 03:27:54 +08:00
|
|
|
{
|
|
|
|
QString key = id.publicKey;
|
|
|
|
auto it = friendLst.find(key);
|
|
|
|
if (it != friendLst.end())
|
|
|
|
return it->activity;
|
|
|
|
|
|
|
|
return QDate();
|
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
void Settings::setFriendActivity(const ToxId& id, const QDate& activity)
|
2015-06-12 03:27:54 +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-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 = "";
|
2015-11-10 04:54:28 +08:00
|
|
|
fp.note = "";
|
2015-06-12 03:27:54 +08:00
|
|
|
fp.autoAcceptDir = "";
|
|
|
|
fp.circleID = -1;
|
|
|
|
fp.activity = activity;
|
|
|
|
friendLst[key] = fp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (value != fauxOfflineMessaging)
|
|
|
|
{
|
|
|
|
fauxOfflineMessaging = value;
|
|
|
|
emit fauxOfflineMessagingChanged(fauxOfflineMessaging);
|
|
|
|
}
|
2014-11-10 21:06:35 +08:00
|
|
|
}
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (value != compactLayout)
|
|
|
|
{
|
|
|
|
compactLayout = value;
|
|
|
|
emit compactLayoutChanged(value);
|
|
|
|
}
|
2014-12-11 20:02:45 +08:00
|
|
|
}
|
|
|
|
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (value != separateWindow)
|
|
|
|
{
|
|
|
|
separateWindow = value;
|
|
|
|
emit separateWindowChanged(value);
|
|
|
|
}
|
2015-06-17 02:25:19 +08:00
|
|
|
}
|
|
|
|
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (value != dontGroupWindows)
|
|
|
|
{
|
|
|
|
dontGroupWindows = value;
|
|
|
|
emit dontGroupWindowsChanged(dontGroupWindows);
|
|
|
|
}
|
2015-06-19 22:58:48 +08:00
|
|
|
}
|
|
|
|
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (value != groupchatPosition)
|
|
|
|
{
|
|
|
|
groupchatPosition = value;
|
|
|
|
emit groupchatPositionChanged(value);
|
|
|
|
}
|
2015-03-12 08:41:18 +08:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +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
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
int Settings::addCircle(const QString& name)
|
2015-06-04 04:18:40 +08:00
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
bool Settings::addFriendRequest(const QString& friendAddress, const QString& message)
|
2016-02-21 05:32:57 +08:00
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
|
2016-02-25 23:46:40 +08:00
|
|
|
for (auto queued : friendRequests)
|
|
|
|
{
|
2016-04-21 05:36:02 +08:00
|
|
|
if (queued.address == friendAddress)
|
2016-02-25 23:46:40 +08:00
|
|
|
{
|
2016-04-21 05:36:02 +08:00
|
|
|
queued.message = message;
|
|
|
|
queued.read = false;
|
2016-02-25 23:46:40 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2016-02-21 05:32:57 +08:00
|
|
|
|
2016-04-21 05:36:02 +08:00
|
|
|
Request request;
|
|
|
|
request.address = friendAddress;
|
|
|
|
request.message = message;
|
|
|
|
request.read = false;
|
|
|
|
|
2016-02-21 05:32:57 +08:00
|
|
|
friendRequests.push_back(request);
|
2016-02-25 23:46:40 +08:00
|
|
|
return true;
|
2016-02-21 05:32:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int Settings::getUnreadFriendRequests() const
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
2016-04-21 06:31:42 +08:00
|
|
|
unsigned int unreadFriendRequests = 0;
|
|
|
|
for (auto request : friendRequests)
|
|
|
|
if (!request.read)
|
|
|
|
unreadFriendRequests++;
|
|
|
|
|
2016-02-21 05:32:57 +08:00
|
|
|
return unreadFriendRequests;
|
|
|
|
}
|
|
|
|
|
2016-04-21 05:36:02 +08:00
|
|
|
Settings::Request Settings::getFriendRequest(int index) const
|
2016-02-21 05:32:57 +08:00
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
return friendRequests.at(index);
|
|
|
|
}
|
|
|
|
|
|
|
|
int Settings::getFriendRequestSize() const
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
return friendRequests.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::clearUnreadFriendRequests()
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
2016-04-21 06:31:42 +08:00
|
|
|
|
|
|
|
for (auto& request : friendRequests)
|
|
|
|
request.read = true;
|
2016-02-21 05:32:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::removeFriendRequest(int index)
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
friendRequests.removeAt(index);
|
|
|
|
}
|
|
|
|
|
2016-04-21 06:31:42 +08:00
|
|
|
void Settings::readFriendRequest(int index)
|
|
|
|
{
|
|
|
|
QMutexLocker locker{&bigLock};
|
|
|
|
friendRequests[index].read = true;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-08-08 19:40:55 +08:00
|
|
|
void Settings::setThemeColor(int value)
|
2014-11-16 04:30:20 +08:00
|
|
|
{
|
2015-06-05 22:27:15 +08:00
|
|
|
QMutexLocker locker{&bigLock};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (value != themeColor)
|
|
|
|
{
|
|
|
|
themeColor = value;
|
|
|
|
emit themeColorChanged(themeColor);
|
|
|
|
}
|
2014-11-16 04:30:20 +08:00
|
|
|
}
|
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};
|
2016-08-08 19:40:55 +08:00
|
|
|
|
|
|
|
if (state != autoLogin)
|
|
|
|
{
|
|
|
|
autoLogin = state;
|
|
|
|
emit autoLoginChanged(autoLogin);
|
|
|
|
}
|
2015-06-05 22:27:15 +08:00
|
|
|
}
|
|
|
|
|
2016-07-27 06:20:54 +08:00
|
|
|
/**
|
2016-08-01 16:21:23 +08:00
|
|
|
* @brief Write a default personal .ini settings file for a profile.
|
|
|
|
* @param basename Filename without extension to save settings.
|
|
|
|
* @example If basename is "profile", settings will be saved in profile.ini
|
|
|
|
*/
|
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);
|
2016-01-21 11:59:20 +08:00
|
|
|
ps.setIniCodec("UTF-8");
|
2015-06-04 05:20:47 +08:00
|
|
|
ps.beginGroup("Friends");
|
|
|
|
ps.beginWriteArray("Friend", 0);
|
|
|
|
ps.endArray();
|
|
|
|
ps.endGroup();
|
|
|
|
|
|
|
|
ps.beginGroup("Privacy");
|
|
|
|
ps.endGroup();
|
|
|
|
}
|
2015-06-04 17:37:54 +08:00
|
|
|
|
2016-07-27 06:20:54 +08:00
|
|
|
/**
|
2016-08-01 16:21:23 +08:00
|
|
|
* @brief Creates a path to the settings dir, if it doesn't already exist
|
|
|
|
*/
|
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
|
|
|
|
2016-07-27 06:20:54 +08:00
|
|
|
/**
|
2016-08-01 16:21:23 +08:00
|
|
|
* @brief Waits for all asynchronous operations to complete
|
|
|
|
*/
|
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();
|
|
|
|
}
|