2014-06-25 04:11:11 +08:00
|
|
|
/*
|
|
|
|
Copyright (C) 2013 by Maxim Biro <nurupo.contributions@gmail.com>
|
2014-10-08 22:17:05 +08:00
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
This file is part of Tox Qt GUI.
|
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.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
2014-10-08 22:17:05 +08:00
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
See the COPYING file for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "settings.h"
|
2014-08-01 20:46:28 +08:00
|
|
|
#include "smileypack.h"
|
2014-10-18 11:02:13 +08:00
|
|
|
#include "src/corestructs.h"
|
2014-11-12 20:56:24 +08:00
|
|
|
#include "src/misc/db/plaindb.h"
|
2015-02-06 19:28:49 +08:00
|
|
|
#include "src/core.h"
|
|
|
|
#include "src/widget/gui.h"
|
2014-12-17 21:44:23 +08:00
|
|
|
#ifdef QTOX_PLATFORM_EXT
|
|
|
|
#include "src/platform/autorun.h"
|
|
|
|
#endif
|
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 <QSettings>
|
|
|
|
#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>
|
2014-06-25 04:11:11 +08:00
|
|
|
|
2014-11-17 23:35:30 +08:00
|
|
|
#define SHOW_SYSTEM_TRAY_DEFAULT (bool) true
|
|
|
|
|
2014-12-03 06:47:55 +08:00
|
|
|
const QString Settings::OLDFILENAME = "settings.ini";
|
|
|
|
const QString Settings::FILENAME = "qtox.ini";
|
2014-12-03 08:26:17 +08:00
|
|
|
Settings* Settings::settings{nullptr};
|
2014-07-13 04:58:58 +08:00
|
|
|
bool Settings::makeToxPortable{false};
|
2014-06-25 04:11:11 +08:00
|
|
|
|
|
|
|
Settings::Settings() :
|
2014-09-05 05:13:59 +08:00
|
|
|
loaded(false), useCustomDhtList{false}
|
2014-06-25 04:11:11 +08:00
|
|
|
{
|
|
|
|
load();
|
|
|
|
}
|
|
|
|
|
|
|
|
Settings& Settings::getInstance()
|
|
|
|
{
|
2014-11-12 06:21:16 +08:00
|
|
|
if (!settings)
|
|
|
|
settings = new Settings();
|
|
|
|
return *settings;
|
2014-06-25 04:11:11 +08:00
|
|
|
}
|
|
|
|
|
2014-12-03 08:26:17 +08:00
|
|
|
void Settings::resetInstance()
|
|
|
|
{
|
|
|
|
if (settings)
|
|
|
|
{
|
|
|
|
delete settings;
|
|
|
|
settings = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-09 06:03:51 +08:00
|
|
|
void Settings::switchProfile(const QString& profile)
|
|
|
|
{
|
|
|
|
setCurrentProfile(profile);
|
|
|
|
save(false);
|
|
|
|
resetInstance();
|
|
|
|
}
|
|
|
|
|
2015-02-06 19:28:49 +08:00
|
|
|
QString Settings::detectProfile()
|
|
|
|
{
|
|
|
|
QDir dir(getSettingsDirPath());
|
|
|
|
QString path, profile = getCurrentProfile();
|
|
|
|
path = dir.filePath(profile + Core::TOX_EXT);
|
|
|
|
QFile file(path);
|
|
|
|
if (profile.isEmpty() || !file.exists())
|
|
|
|
{
|
|
|
|
setCurrentProfile("");
|
|
|
|
#if 1 // deprecation attempt
|
|
|
|
// if the last profile doesn't exist, fall back to old "data"
|
|
|
|
path = dir.filePath(Core::CONFIG_FILE_NAME);
|
|
|
|
QFile file(path);
|
|
|
|
if (file.exists())
|
|
|
|
return path;
|
|
|
|
else if (QFile(path = dir.filePath("tox_save")).exists()) // also import tox_save if no data
|
|
|
|
return path;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
profile = askProfiles();
|
|
|
|
if (profile.isEmpty())
|
|
|
|
return "";
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switchProfile(profile);
|
|
|
|
return dir.filePath(profile + Core::TOX_EXT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
QList<QString> Settings::searchProfiles()
|
|
|
|
{
|
|
|
|
QList<QString> out;
|
|
|
|
QDir dir(getSettingsDirPath());
|
|
|
|
dir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
|
|
|
|
dir.setNameFilters(QStringList("*.tox"));
|
|
|
|
for (QFileInfo file : dir.entryInfoList())
|
|
|
|
out += file.completeBaseName();
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Settings::askProfiles()
|
|
|
|
{ // TODO: allow user to create new Tox ID, even if a profile already exists
|
|
|
|
QList<QString> profiles = searchProfiles();
|
|
|
|
if (profiles.empty()) return "";
|
|
|
|
bool ok;
|
|
|
|
QString profile = GUI::itemInputDialog(nullptr,
|
|
|
|
tr("Choose a profile"),
|
|
|
|
tr("Please choose which identity to use"),
|
|
|
|
profiles,
|
|
|
|
0, // which slot to start on
|
|
|
|
false, // if the user can enter their own input
|
|
|
|
&ok);
|
|
|
|
if (!ok) // user cancelled
|
|
|
|
return "";
|
|
|
|
else
|
|
|
|
return profile;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
void Settings::load()
|
|
|
|
{
|
2014-12-03 06:47:55 +08:00
|
|
|
if (loaded)
|
2014-06-25 04:11:11 +08:00
|
|
|
return;
|
|
|
|
|
2014-12-03 06:47:55 +08:00
|
|
|
if (QFile(FILENAME).exists())
|
2014-09-05 05:11:46 +08:00
|
|
|
{
|
|
|
|
QSettings ps(FILENAME, QSettings::IniFormat);
|
|
|
|
ps.beginGroup("General");
|
|
|
|
makeToxPortable = ps.value("makeToxPortable", false).toBool();
|
|
|
|
ps.endGroup();
|
|
|
|
}
|
2014-12-03 06:47:55 +08:00
|
|
|
else if (QFile(OLDFILENAME).exists())
|
|
|
|
{
|
|
|
|
QSettings ps(OLDFILENAME, QSettings::IniFormat);
|
|
|
|
ps.beginGroup("General");
|
|
|
|
makeToxPortable = ps.value("makeToxPortable", false).toBool();
|
|
|
|
ps.endGroup();
|
|
|
|
}
|
2014-09-05 05:11:46 +08:00
|
|
|
else
|
|
|
|
makeToxPortable = false;
|
2014-07-13 04:58:58 +08:00
|
|
|
|
2014-12-03 06:47:55 +08:00
|
|
|
QDir dir(getSettingsDirPath());
|
|
|
|
QString filePath = dir.filePath(FILENAME);
|
2014-06-25 04:11:11 +08:00
|
|
|
|
|
|
|
//if no settings file exist -- use the default one
|
2014-12-03 06:47:55 +08:00
|
|
|
if (!QFile(filePath).exists())
|
|
|
|
{
|
|
|
|
if (!QFile(filePath = dir.filePath(OLDFILENAME)).exists())
|
|
|
|
{
|
|
|
|
qDebug() << "No settings file found, using defaults";
|
|
|
|
filePath = ":/conf/" + FILENAME;
|
|
|
|
}
|
2014-06-25 04:11:11 +08:00
|
|
|
}
|
|
|
|
|
2014-09-05 05:13:59 +08:00
|
|
|
qDebug() << "Settings: Loading from "<<filePath;
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
QSettings s(filePath, QSettings::IniFormat);
|
|
|
|
s.beginGroup("DHT Server");
|
2014-09-05 05:13:59 +08:00
|
|
|
if (s.value("useCustomList").toBool())
|
|
|
|
{
|
|
|
|
useCustomDhtList = true;
|
|
|
|
qDebug() << "Using custom bootstrap nodes list";
|
|
|
|
int serverListSize = s.beginReadArray("dhtServerList");
|
|
|
|
for (int i = 0; i < serverListSize; i ++) {
|
|
|
|
s.setArrayIndex(i);
|
|
|
|
DhtServer server;
|
|
|
|
server.name = s.value("name").toString();
|
|
|
|
server.userId = s.value("userId").toString();
|
|
|
|
server.address = s.value("address").toString();
|
|
|
|
server.port = s.value("port").toInt();
|
|
|
|
dhtServerList << server;
|
|
|
|
}
|
|
|
|
s.endArray();
|
2014-06-25 04:11:11 +08:00
|
|
|
}
|
2014-09-05 05:13:59 +08:00
|
|
|
else
|
|
|
|
useCustomDhtList=false;
|
2014-06-25 04:11:11 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
|
|
|
s.beginGroup("General");
|
2014-07-02 06:47:06 +08:00
|
|
|
enableIPv6 = s.value("enableIPv6", true).toBool();
|
2014-11-06 06:34:28 +08:00
|
|
|
translation = s.value("translation", "en").toString();
|
2014-11-17 23:35:30 +08:00
|
|
|
showSystemTray = s.value("showSystemTray", SHOW_SYSTEM_TRAY_DEFAULT).toBool();
|
2014-07-13 04:58:58 +08:00
|
|
|
makeToxPortable = s.value("makeToxPortable", false).toBool();
|
2014-10-08 22:17:05 +08:00
|
|
|
autostartInTray = s.value("autostartInTray", false).toBool();
|
2014-10-20 03:47:06 +08:00
|
|
|
closeToTray = s.value("closeToTray", false).toBool();
|
2014-10-07 10:16:06 +08:00
|
|
|
forceTCP = s.value("forceTCP", false).toBool();
|
2014-12-28 21:04:32 +08:00
|
|
|
setProxyType(s.value("proxyType", static_cast<int>(ProxyType::ptNone)).toInt());
|
2014-10-07 10:16:06 +08:00
|
|
|
proxyAddr = s.value("proxyAddr", "").toString();
|
|
|
|
proxyPort = s.value("proxyPort", 0).toInt();
|
2014-10-16 17:47:58 +08:00
|
|
|
currentProfile = s.value("currentProfile", "").toString();
|
2014-11-12 20:56:24 +08:00
|
|
|
autoAwayTime = s.value("autoAwayTime", 10).toInt();
|
2014-11-10 07:31:29 +08:00
|
|
|
checkUpdates = s.value("checkUpdates", false).toBool();
|
2015-01-21 19:10:41 +08:00
|
|
|
showWindow = s.value("showWindow", true).toBool();
|
2014-11-10 08:23:41 +08:00
|
|
|
showInFront = s.value("showInFront", false).toBool();
|
2015-01-21 19:10:41 +08:00
|
|
|
groupAlwaysNotify = s.value("groupAlwaysNotify", false).toBool();
|
2014-11-11 06:45:09 +08:00
|
|
|
fauxOfflineMessaging = s.value("fauxOfflineMessaging", true).toBool();
|
2014-11-17 18:10:38 +08:00
|
|
|
autoSaveEnabled = s.value("autoSaveEnabled", false).toBool();
|
|
|
|
globalAutoAcceptDir = s.value("globalAutoAcceptDir",
|
|
|
|
QStandardPaths::locate(QStandardPaths::HomeLocation, QString(), QStandardPaths::LocateDirectory)
|
|
|
|
).toString();
|
2014-12-11 20:02:45 +08:00
|
|
|
compactLayout = s.value("compactLayout", false).toBool();
|
2014-06-25 04:11:11 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
2014-11-12 20:56:24 +08:00
|
|
|
s.beginGroup("Advanced");
|
|
|
|
int sType = s.value("dbSyncType", static_cast<int>(Db::syncType::stFull)).toInt();
|
|
|
|
setDbSyncType(sType);
|
|
|
|
s.endGroup();
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
s.beginGroup("Widgets");
|
|
|
|
QList<QString> objectNames = s.childKeys();
|
|
|
|
for (const QString& name : objectNames) {
|
|
|
|
widgetSettings[name] = s.value(name).toByteArray();
|
|
|
|
}
|
|
|
|
s.endGroup();
|
|
|
|
|
|
|
|
s.beginGroup("GUI");
|
|
|
|
enableSmoothAnimation = s.value("smoothAnimation", true).toBool();
|
2015-02-08 06:22:45 +08:00
|
|
|
smileyPack = s.value("smileyPack", ":/smileys/TwitterEmojiSVG/emoticons.xml").toString();
|
2014-06-25 04:11:11 +08:00
|
|
|
customEmojiFont = s.value("customEmojiFont", true).toBool();
|
|
|
|
emojiFontFamily = s.value("emojiFontFamily", "DejaVu Sans").toString();
|
2015-02-08 06:22:45 +08:00
|
|
|
emojiFontPointSize = s.value("emojiFontPointSize", 16).toInt();
|
2014-06-25 04:11:11 +08:00
|
|
|
firstColumnHandlePos = s.value("firstColumnHandlePos", 50).toInt();
|
|
|
|
secondColumnHandlePosFromRight = s.value("secondColumnHandlePosFromRight", 50).toInt();
|
|
|
|
timestampFormat = s.value("timestampFormat", "hh:mm").toString();
|
|
|
|
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-08-11 00:14:50 +08:00
|
|
|
useNativeStyle = s.value("nativeStyle", false).toBool();
|
2014-11-05 23:20:32 +08:00
|
|
|
useEmoticons = s.value("useEmoticons", true).toBool();
|
2014-10-11 07:18:32 +08:00
|
|
|
statusChangeNotificationEnabled = s.value("statusChangeNotificationEnabled", false).toBool();
|
2014-11-16 04:30:20 +08:00
|
|
|
themeColor = s.value("themeColor", 0).toInt();
|
2014-11-09 08:10:06 +08:00
|
|
|
style = s.value("style", "").toString();
|
|
|
|
if (style == "") // Default to Fusion if available, otherwise no style
|
|
|
|
{
|
|
|
|
if (QStyleFactory::keys().contains("Fusion"))
|
|
|
|
style = "Fusion";
|
|
|
|
else
|
|
|
|
style = "None";
|
|
|
|
}
|
2014-08-11 23:33:32 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
|
|
|
s.beginGroup("State");
|
2014-08-11 16:00:08 +08:00
|
|
|
windowGeometry = s.value("windowGeometry", QByteArray()).toByteArray();
|
|
|
|
windowState = s.value("windowState", QByteArray()).toByteArray();
|
2014-08-11 20:07:27 +08:00
|
|
|
splitterState = s.value("splitterState", QByteArray()).toByteArray();
|
2014-06-25 04:11:11 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
2014-10-29 04:21:37 +08:00
|
|
|
s.beginGroup("Audio");
|
|
|
|
inDev = s.value("inDev", "").toString();
|
|
|
|
outDev = s.value("outDev", "").toString();
|
2014-12-14 16:50:18 +08:00
|
|
|
filterAudio = s.value("filterAudio", false).toBool();
|
2014-10-29 04:21:37 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
2015-01-24 09:03:26 +08:00
|
|
|
s.beginGroup("Video");
|
|
|
|
camVideoRes = s.value("camVideoRes",QSize()).toSize();
|
|
|
|
s.endGroup();
|
|
|
|
|
2014-09-05 05:13:59 +08:00
|
|
|
// Read the embedded DHT bootsrap nodes list if needed
|
|
|
|
if (dhtServerList.isEmpty())
|
|
|
|
{
|
|
|
|
qDebug() << "Using embeded bootstrap nodes list";
|
|
|
|
QSettings rcs(":/conf/settings.ini", QSettings::IniFormat);
|
|
|
|
rcs.beginGroup("DHT Server");
|
|
|
|
int serverListSize = rcs.beginReadArray("dhtServerList");
|
|
|
|
for (int i = 0; i < serverListSize; i ++) {
|
|
|
|
rcs.setArrayIndex(i);
|
|
|
|
DhtServer server;
|
|
|
|
server.name = rcs.value("name").toString();
|
|
|
|
server.userId = rcs.value("userId").toString();
|
|
|
|
server.address = rcs.value("address").toString();
|
|
|
|
server.port = rcs.value("port").toInt();
|
|
|
|
dhtServerList << server;
|
|
|
|
}
|
|
|
|
rcs.endArray();
|
|
|
|
rcs.endGroup();
|
|
|
|
}
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
loaded = true;
|
2014-12-03 08:26:17 +08:00
|
|
|
|
2014-12-06 11:13:04 +08:00
|
|
|
if (!currentProfile.isEmpty()) // new profile in Core::switchConfiguration
|
|
|
|
{
|
|
|
|
// load from a profile specific friend data list if possible
|
|
|
|
QString tmp = dir.filePath(currentProfile + ".ini");
|
|
|
|
if (QFile(tmp).exists()) // otherwise, filePath remains the global file
|
|
|
|
filePath = tmp;
|
|
|
|
|
|
|
|
QSettings ps(filePath, QSettings::IniFormat);
|
|
|
|
friendLst.clear();
|
|
|
|
ps.beginGroup("Friends");
|
|
|
|
int size = ps.beginReadArray("Friend");
|
|
|
|
for (int i = 0; i < size; i ++)
|
|
|
|
{
|
|
|
|
ps.setArrayIndex(i);
|
|
|
|
friendProp fp;
|
|
|
|
fp.addr = ps.value("addr").toString();
|
|
|
|
fp.alias = ps.value("alias").toString();
|
|
|
|
fp.autoAcceptDir = ps.value("autoAcceptDir").toString();
|
|
|
|
friendLst[ToxID::fromString(fp.addr).publicKey] = fp;
|
|
|
|
}
|
|
|
|
ps.endArray();
|
|
|
|
ps.endGroup();
|
2014-12-03 08:26:17 +08:00
|
|
|
|
2014-12-06 11:13:04 +08:00
|
|
|
ps.beginGroup("Privacy");
|
|
|
|
typingNotification = ps.value("typingNotification", false).toBool();
|
|
|
|
enableLogging = ps.value("enableLogging", false).toBool();
|
|
|
|
encryptLogs = ps.value("encryptLogs", false).toBool();
|
|
|
|
encryptTox = ps.value("encryptTox", false).toBool();
|
|
|
|
ps.endGroup();
|
|
|
|
}
|
2014-06-25 04:11:11 +08:00
|
|
|
}
|
|
|
|
|
2014-12-06 11:13:04 +08:00
|
|
|
void Settings::save(bool writePersonal)
|
2014-06-25 04:11:11 +08:00
|
|
|
{
|
2014-08-30 16:28:00 +08:00
|
|
|
QString filePath = QDir(getSettingsDirPath()).filePath(FILENAME);
|
2014-12-06 11:13:04 +08:00
|
|
|
save(filePath, writePersonal);
|
2014-07-13 04:58:58 +08:00
|
|
|
}
|
2014-06-25 04:11:11 +08:00
|
|
|
|
2014-12-06 11:13:04 +08:00
|
|
|
void Settings::save(QString path, bool writePersonal)
|
2014-07-13 04:58:58 +08:00
|
|
|
{
|
2014-09-05 05:13:59 +08:00
|
|
|
qDebug() << "Settings: Saving in "<<path;
|
|
|
|
|
2014-07-13 04:58:58 +08:00
|
|
|
QSettings s(path, QSettings::IniFormat);
|
2014-06-25 04:11:11 +08:00
|
|
|
|
|
|
|
s.clear();
|
|
|
|
|
|
|
|
s.beginGroup("DHT Server");
|
2014-09-05 05:13:59 +08:00
|
|
|
s.setValue("useCustomList", useCustomDhtList);
|
2014-06-25 04:11:11 +08:00
|
|
|
s.beginWriteArray("dhtServerList", dhtServerList.size());
|
|
|
|
for (int i = 0; i < dhtServerList.size(); i ++) {
|
|
|
|
s.setArrayIndex(i);
|
|
|
|
s.setValue("name", dhtServerList[i].name);
|
|
|
|
s.setValue("userId", dhtServerList[i].userId);
|
|
|
|
s.setValue("address", dhtServerList[i].address);
|
|
|
|
s.setValue("port", dhtServerList[i].port);
|
|
|
|
}
|
|
|
|
s.endArray();
|
|
|
|
s.endGroup();
|
|
|
|
|
|
|
|
s.beginGroup("General");
|
2014-07-02 06:47:06 +08:00
|
|
|
s.setValue("enableIPv6", enableIPv6);
|
2014-10-18 07:06:30 +08:00
|
|
|
s.setValue("translation",translation);
|
2014-07-13 04:58:58 +08:00
|
|
|
s.setValue("makeToxPortable",makeToxPortable);
|
2014-11-14 04:33:11 +08:00
|
|
|
s.setValue("showSystemTray", showSystemTray);
|
2014-10-08 22:17:05 +08:00
|
|
|
s.setValue("autostartInTray",autostartInTray);
|
2014-10-20 03:47:06 +08:00
|
|
|
s.setValue("closeToTray", closeToTray);
|
2014-12-28 20:32:25 +08:00
|
|
|
s.setValue("proxyType", static_cast<int>(proxyType));
|
2014-10-07 10:16:06 +08:00
|
|
|
s.setValue("forceTCP", forceTCP);
|
|
|
|
s.setValue("proxyAddr", proxyAddr);
|
|
|
|
s.setValue("proxyPort", proxyPort);
|
2014-07-17 06:43:30 +08:00
|
|
|
s.setValue("currentProfile", currentProfile);
|
2014-10-16 17:47:58 +08:00
|
|
|
s.setValue("autoAwayTime", autoAwayTime);
|
2014-11-10 07:31:29 +08:00
|
|
|
s.setValue("checkUpdates", checkUpdates);
|
2015-01-21 19:10:41 +08:00
|
|
|
s.setValue("showWindow", showWindow);
|
2014-11-10 08:23:41 +08:00
|
|
|
s.setValue("showInFront", showInFront);
|
2015-01-21 19:10:41 +08:00
|
|
|
s.setValue("groupAlwaysNotify", groupAlwaysNotify);
|
2014-11-10 21:06:35 +08:00
|
|
|
s.setValue("fauxOfflineMessaging", fauxOfflineMessaging);
|
2014-12-11 20:02:45 +08:00
|
|
|
s.setValue("compactLayout", compactLayout);
|
2014-11-17 18:10:38 +08:00
|
|
|
s.setValue("autoSaveEnabled", autoSaveEnabled);
|
|
|
|
s.setValue("globalAutoAcceptDir", globalAutoAcceptDir);
|
2014-06-25 04:11:11 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
2014-11-12 20:56:24 +08:00
|
|
|
s.beginGroup("Advanced");
|
|
|
|
s.setValue("dbSyncType", static_cast<int>(dbSyncType));
|
|
|
|
s.endGroup();
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
s.beginGroup("Widgets");
|
|
|
|
const QList<QString> widgetNames = widgetSettings.keys();
|
|
|
|
for (const QString& name : widgetNames) {
|
|
|
|
s.setValue(name, widgetSettings.value(name));
|
|
|
|
}
|
|
|
|
s.endGroup();
|
|
|
|
|
|
|
|
s.beginGroup("GUI");
|
|
|
|
s.setValue("smoothAnimation", enableSmoothAnimation);
|
|
|
|
s.setValue("smileyPack", smileyPack);
|
|
|
|
s.setValue("customEmojiFont", customEmojiFont);
|
|
|
|
s.setValue("emojiFontFamily", emojiFontFamily);
|
|
|
|
s.setValue("emojiFontPointSize", emojiFontPointSize);
|
|
|
|
s.setValue("firstColumnHandlePos", firstColumnHandlePos);
|
|
|
|
s.setValue("secondColumnHandlePosFromRight", secondColumnHandlePosFromRight);
|
|
|
|
s.setValue("timestampFormat", timestampFormat);
|
|
|
|
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-08-11 00:14:50 +08:00
|
|
|
s.setValue("nativeStyle", useNativeStyle);
|
2014-11-05 23:20:32 +08:00
|
|
|
s.setValue("useEmoticons", useEmoticons);
|
2014-11-16 04:30:20 +08:00
|
|
|
s.setValue("themeColor", themeColor);
|
2014-11-05 23:20:32 +08:00
|
|
|
s.setValue("style", style);
|
2014-10-11 07:18:32 +08:00
|
|
|
s.setValue("statusChangeNotificationEnabled", statusChangeNotificationEnabled);
|
2014-08-11 23:33:32 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
|
|
|
s.beginGroup("State");
|
2014-08-11 16:00:08 +08:00
|
|
|
s.setValue("windowGeometry", windowGeometry);
|
|
|
|
s.setValue("windowState", windowState);
|
2014-08-11 20:07:27 +08:00
|
|
|
s.setValue("splitterState", splitterState);
|
2014-06-25 04:11:11 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
2014-10-29 04:21:37 +08:00
|
|
|
s.beginGroup("Audio");
|
|
|
|
s.setValue("inDev", inDev);
|
|
|
|
s.setValue("outDev", outDev);
|
2014-12-14 16:50:18 +08:00
|
|
|
s.setValue("filterAudio", filterAudio);
|
2014-10-29 04:21:37 +08:00
|
|
|
s.endGroup();
|
2014-12-03 08:26:17 +08:00
|
|
|
|
2015-01-24 09:03:26 +08:00
|
|
|
s.beginGroup("Video");
|
|
|
|
s.setValue("camVideoRes",camVideoRes);
|
|
|
|
s.endGroup();
|
|
|
|
|
2014-12-06 11:13:04 +08:00
|
|
|
if (writePersonal && !currentProfile.isEmpty()) // Core::switchConfiguration
|
|
|
|
{
|
|
|
|
QSettings ps(QFileInfo(path).dir().filePath(currentProfile + ".ini"), QSettings::IniFormat);
|
|
|
|
ps.beginGroup("Friends");
|
|
|
|
ps.beginWriteArray("Friend", friendLst.size());
|
|
|
|
int index = 0;
|
|
|
|
for (auto& frnd : friendLst)
|
|
|
|
{
|
|
|
|
ps.setArrayIndex(index);
|
|
|
|
ps.setValue("addr", frnd.addr);
|
|
|
|
ps.setValue("alias", frnd.alias);
|
|
|
|
ps.setValue("autoAcceptDir", frnd.autoAcceptDir);
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
ps.endArray();
|
|
|
|
ps.endGroup();
|
2014-12-03 08:26:17 +08:00
|
|
|
|
2014-12-06 11:13:04 +08:00
|
|
|
ps.beginGroup("Privacy");
|
|
|
|
ps.setValue("typingNotification", typingNotification);
|
|
|
|
ps.setValue("enableLogging", enableLogging);
|
|
|
|
ps.setValue("encryptLogs", encryptLogs);
|
|
|
|
ps.setValue("encryptTox", encryptTox);
|
|
|
|
ps.endGroup();
|
|
|
|
}
|
2014-06-25 04:11:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
QString Settings::getSettingsDirPath()
|
|
|
|
{
|
2014-07-13 04:58:58 +08:00
|
|
|
if (makeToxPortable)
|
|
|
|
return ".";
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
// workaround for https://bugreports.qt-project.org/browse/QTBUG-38845
|
|
|
|
#ifdef Q_OS_WIN
|
2014-11-01 22:02:43 +08:00
|
|
|
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)
|
|
|
|
+ QDir::separator() + "AppData" + QDir::separator() + "Roaming" + QDir::separator() + "tox");
|
2014-06-25 04:11:11 +08:00
|
|
|
#else
|
2014-08-30 16:28:00 +08:00
|
|
|
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QDir::separator() + "tox");
|
2014-06-25 04:11:11 +08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-09-24 23:55:54 +08:00
|
|
|
QPixmap Settings::getSavedAvatar(const QString &ownerId)
|
2014-09-24 22:51:16 +08:00
|
|
|
{
|
2014-09-28 05:37:39 +08:00
|
|
|
QDir dir(getSettingsDirPath());
|
2014-09-28 06:19:30 +08:00
|
|
|
QString filePath = dir.filePath("avatars/"+ownerId.left(64)+".png");
|
2014-09-28 05:37:39 +08:00
|
|
|
QFileInfo info(filePath);
|
2014-09-24 22:51:16 +08:00
|
|
|
QPixmap pic;
|
2014-09-28 05:37:39 +08:00
|
|
|
if (!info.exists())
|
|
|
|
{
|
2014-09-28 06:19:30 +08:00
|
|
|
QString filePath = dir.filePath("avatar_"+ownerId.left(64));
|
|
|
|
if (!QFileInfo(filePath).exists()) // try without truncation, for old self avatars
|
2014-09-28 06:36:19 +08:00
|
|
|
filePath = dir.filePath("avatar_"+ownerId);
|
2014-09-28 05:37:39 +08:00
|
|
|
pic.load(filePath);
|
|
|
|
saveAvatar(pic, ownerId);
|
|
|
|
QFile::remove(filePath);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pic.load(filePath);
|
2014-09-24 22:51:16 +08:00
|
|
|
return pic;
|
|
|
|
}
|
|
|
|
|
2014-09-24 23:55:54 +08:00
|
|
|
void Settings::saveAvatar(QPixmap& pic, const QString& ownerId)
|
2014-09-24 22:51:16 +08:00
|
|
|
{
|
2014-09-28 05:37:39 +08:00
|
|
|
QDir dir(getSettingsDirPath());
|
2014-09-29 09:54:28 +08:00
|
|
|
dir.mkdir("avatars/");
|
2014-09-28 06:19:30 +08:00
|
|
|
// ignore nospam (good idea, and also the addFriend funcs which call getAvatar don't have it)
|
|
|
|
QString filePath = dir.filePath("avatars/"+ownerId.left(64)+".png");
|
2014-09-24 22:51:16 +08:00
|
|
|
pic.save(filePath, "png");
|
|
|
|
}
|
|
|
|
|
2014-09-29 09:54:28 +08:00
|
|
|
void Settings::saveAvatarHash(const QByteArray& hash, const QString& ownerId)
|
|
|
|
{
|
|
|
|
QDir dir(getSettingsDirPath());
|
|
|
|
dir.mkdir("avatars/");
|
|
|
|
QFile file(dir.filePath("avatars/"+ownerId.left(64)+".hash"));
|
|
|
|
if (!file.open(QIODevice::WriteOnly))
|
|
|
|
return;
|
|
|
|
file.write(hash);
|
|
|
|
file.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray Settings::getAvatarHash(const QString& ownerId)
|
|
|
|
{
|
|
|
|
QDir dir(getSettingsDirPath());
|
|
|
|
dir.mkdir("avatars/");
|
|
|
|
QFile file(dir.filePath("avatars/"+ownerId.left(64)+".hash"));
|
|
|
|
if (!file.open(QIODevice::ReadOnly))
|
|
|
|
return QByteArray();
|
|
|
|
QByteArray out = file.readAll();
|
|
|
|
file.close();
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
const QList<Settings::DhtServer>& Settings::getDhtServerList() const
|
|
|
|
{
|
|
|
|
return dhtServerList;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setDhtServerList(const QList<DhtServer>& newDhtServerList)
|
|
|
|
{
|
|
|
|
dhtServerList = newDhtServerList;
|
|
|
|
emit dhtServerListChanged();
|
|
|
|
}
|
|
|
|
|
2014-07-02 06:47:06 +08:00
|
|
|
bool Settings::getEnableIPv6() const
|
|
|
|
{
|
|
|
|
return enableIPv6;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setEnableIPv6(bool newValue)
|
|
|
|
{
|
|
|
|
enableIPv6 = newValue;
|
|
|
|
}
|
|
|
|
|
2014-07-13 04:58:58 +08:00
|
|
|
bool Settings::getMakeToxPortable() const
|
|
|
|
{
|
|
|
|
return makeToxPortable;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setMakeToxPortable(bool newValue)
|
|
|
|
{
|
|
|
|
makeToxPortable = newValue;
|
|
|
|
save(FILENAME); // Commit to the portable file that we don't want to use it
|
2014-09-01 04:44:52 +08:00
|
|
|
if (!newValue) // Update the new file right now if not already done
|
|
|
|
save();
|
2014-07-13 04:58:58 +08:00
|
|
|
}
|
|
|
|
|
2014-12-17 21:44:23 +08:00
|
|
|
bool Settings::getAutorun() const
|
|
|
|
{
|
|
|
|
#ifdef QTOX_PLATFORM_EXT
|
|
|
|
return Platform::getAutorun();
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setAutorun(bool newValue)
|
|
|
|
{
|
|
|
|
#ifdef QTOX_PLATFORM_EXT
|
|
|
|
Platform::setAutorun(newValue);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-10-08 22:17:05 +08:00
|
|
|
bool Settings::getAutostartInTray() const
|
|
|
|
{
|
|
|
|
return autostartInTray;
|
|
|
|
}
|
|
|
|
|
2014-10-09 06:31:20 +08:00
|
|
|
QString Settings::getStyle() const
|
|
|
|
{
|
|
|
|
return style;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setStyle(const QString& newStyle)
|
|
|
|
{
|
|
|
|
style = newStyle;
|
|
|
|
}
|
|
|
|
|
2014-11-14 04:33:11 +08:00
|
|
|
bool Settings::getShowSystemTray() const
|
|
|
|
{
|
|
|
|
return showSystemTray;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setShowSystemTray(const bool& newValue)
|
|
|
|
{
|
|
|
|
showSystemTray = newValue;
|
|
|
|
}
|
|
|
|
|
2014-11-05 23:20:32 +08:00
|
|
|
void Settings::setUseEmoticons(bool newValue)
|
|
|
|
{
|
|
|
|
useEmoticons = newValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Settings::getUseEmoticons() const
|
|
|
|
{
|
|
|
|
return useEmoticons;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setAutoSaveEnabled(bool newValue)
|
|
|
|
{
|
|
|
|
autoSaveEnabled = newValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Settings::getAutoSaveEnabled() const
|
|
|
|
{
|
|
|
|
return autoSaveEnabled;
|
|
|
|
}
|
|
|
|
|
2014-10-08 22:17:05 +08:00
|
|
|
void Settings::setAutostartInTray(bool newValue)
|
|
|
|
{
|
|
|
|
autostartInTray = newValue;
|
|
|
|
}
|
|
|
|
|
2014-10-20 03:47:06 +08:00
|
|
|
bool Settings::getCloseToTray() const
|
|
|
|
{
|
|
|
|
return closeToTray;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setCloseToTray(bool newValue)
|
|
|
|
{
|
|
|
|
closeToTray = newValue;
|
|
|
|
}
|
|
|
|
|
2014-10-20 19:50:12 +08:00
|
|
|
bool Settings::getMinimizeToTray() const
|
|
|
|
{
|
|
|
|
return minimizeToTray;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Settings::setMinimizeToTray(bool newValue)
|
|
|
|
{
|
|
|
|
minimizeToTray = newValue;
|
|
|
|
}
|
|
|
|
|
2014-12-12 03:34:12 +08:00
|
|
|
bool Settings::getLightTrayIcon() const
|
|
|
|
{
|
|
|
|
return lightTrayIcon;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setLightTrayIcon(bool newValue)
|
|
|
|
{
|
|
|
|
lightTrayIcon = newValue;
|
|
|
|
}
|
|
|
|
|
2014-10-11 07:18:32 +08:00
|
|
|
bool Settings::getStatusChangeNotificationEnabled() const
|
|
|
|
{
|
|
|
|
return statusChangeNotificationEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setStatusChangeNotificationEnabled(bool newValue)
|
|
|
|
{
|
|
|
|
statusChangeNotificationEnabled = newValue;
|
|
|
|
}
|
|
|
|
|
2014-11-10 08:23:41 +08:00
|
|
|
bool Settings::getShowInFront() const
|
|
|
|
{
|
|
|
|
return showInFront;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setShowInFront(bool newValue)
|
|
|
|
{
|
2015-01-21 19:10:41 +08:00
|
|
|
showInFront = newValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Settings::getGroupAlwaysNotify() const
|
|
|
|
{
|
|
|
|
return groupAlwaysNotify;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setGroupAlwaysNotify(bool newValue)
|
|
|
|
{
|
|
|
|
groupAlwaysNotify = newValue;
|
2014-11-10 08:23:41 +08:00
|
|
|
}
|
|
|
|
|
2014-10-18 07:06:30 +08:00
|
|
|
QString Settings::getTranslation() const
|
2014-07-05 01:22:43 +08:00
|
|
|
{
|
2014-10-18 07:06:30 +08:00
|
|
|
return translation;
|
2014-07-05 01:22:43 +08:00
|
|
|
}
|
|
|
|
|
2014-10-18 07:06:30 +08:00
|
|
|
void Settings::setTranslation(QString newValue)
|
2014-07-05 01:22:43 +08:00
|
|
|
{
|
2014-10-18 07:06:30 +08:00
|
|
|
translation = newValue;
|
2014-10-06 04:49:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Settings::getForceTCP() const
|
|
|
|
{
|
|
|
|
return forceTCP;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setForceTCP(bool newValue)
|
|
|
|
{
|
|
|
|
forceTCP = newValue;
|
|
|
|
}
|
|
|
|
|
2014-12-28 20:32:25 +08:00
|
|
|
ProxyType Settings::getProxyType() const
|
2014-10-07 10:09:15 +08:00
|
|
|
{
|
2014-12-28 20:32:25 +08:00
|
|
|
return proxyType;
|
2014-10-07 10:09:15 +08:00
|
|
|
}
|
2014-12-28 20:32:25 +08:00
|
|
|
|
|
|
|
void Settings::setProxyType(int newValue)
|
2014-10-07 10:09:15 +08:00
|
|
|
{
|
2014-12-28 21:04:32 +08:00
|
|
|
if (newValue >= 0 && newValue <= 2)
|
2014-12-28 20:32:25 +08:00
|
|
|
proxyType = static_cast<ProxyType>(newValue);
|
|
|
|
else
|
|
|
|
proxyType = ProxyType::ptNone;
|
2014-10-07 10:09:15 +08:00
|
|
|
}
|
|
|
|
|
2014-10-06 04:49:44 +08:00
|
|
|
QString Settings::getProxyAddr() const
|
|
|
|
{
|
|
|
|
return proxyAddr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setProxyAddr(const QString& newValue)
|
|
|
|
{
|
|
|
|
proxyAddr = newValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Settings::getProxyPort() const
|
|
|
|
{
|
|
|
|
return proxyPort;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setProxyPort(int newValue)
|
|
|
|
{
|
|
|
|
proxyPort = newValue;
|
2014-07-05 01:22:43 +08:00
|
|
|
}
|
|
|
|
|
2014-10-11 06:43:15 +08:00
|
|
|
QString Settings::getCurrentProfile() const
|
|
|
|
{
|
|
|
|
return currentProfile;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setCurrentProfile(QString profile)
|
|
|
|
{
|
|
|
|
currentProfile = profile;
|
|
|
|
}
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
bool Settings::getEnableLogging() const
|
|
|
|
{
|
|
|
|
return enableLogging;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setEnableLogging(bool newValue)
|
|
|
|
{
|
|
|
|
enableLogging = newValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Settings::getEncryptLogs() const
|
|
|
|
{
|
|
|
|
return encryptLogs;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setEncryptLogs(bool newValue)
|
|
|
|
{
|
|
|
|
encryptLogs = newValue;
|
|
|
|
}
|
|
|
|
|
2014-10-12 15:31:48 +08:00
|
|
|
bool Settings::getEncryptTox() const
|
|
|
|
{
|
|
|
|
return encryptTox;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setEncryptTox(bool newValue)
|
|
|
|
{
|
|
|
|
encryptTox = newValue;
|
|
|
|
}
|
|
|
|
|
2014-11-12 20:56:24 +08:00
|
|
|
Db::syncType Settings::getDbSyncType() const
|
|
|
|
{
|
|
|
|
return dbSyncType;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setDbSyncType(int newValue)
|
|
|
|
{
|
|
|
|
if (newValue >= 0 && newValue <= 2)
|
|
|
|
dbSyncType = static_cast<Db::syncType>(newValue);
|
|
|
|
else
|
|
|
|
dbSyncType = Db::syncType::stFull;
|
|
|
|
}
|
|
|
|
|
2014-10-16 17:47:58 +08:00
|
|
|
int Settings::getAutoAwayTime() const
|
|
|
|
{
|
|
|
|
return autoAwayTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setAutoAwayTime(int newValue)
|
|
|
|
{
|
|
|
|
if (newValue < 0)
|
|
|
|
newValue = 10;
|
|
|
|
autoAwayTime = newValue;
|
|
|
|
}
|
|
|
|
|
2014-11-17 18:10:38 +08:00
|
|
|
QString Settings::getAutoAcceptDir(const ToxID& id) const
|
2014-10-18 11:02:13 +08:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2014-11-17 18:10:38 +08:00
|
|
|
void Settings::setAutoAcceptDir(const ToxID &id, const QString& dir)
|
2014-10-18 11:02:13 +08:00
|
|
|
{
|
2014-11-17 18:10:38 +08:00
|
|
|
QString key = id.publicKey;
|
|
|
|
|
|
|
|
auto it = friendLst.find(key);
|
|
|
|
if (it != friendLst.end())
|
|
|
|
{
|
|
|
|
it->autoAcceptDir = dir;
|
|
|
|
} else {
|
|
|
|
updateFriendAdress(id.toString());
|
|
|
|
setAutoAcceptDir(id, dir);
|
|
|
|
}
|
2014-10-18 11:02:13 +08:00
|
|
|
}
|
|
|
|
|
2014-10-20 12:25:52 +08:00
|
|
|
QString Settings::getGlobalAutoAcceptDir() const
|
|
|
|
{
|
|
|
|
return globalAutoAcceptDir;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setGlobalAutoAcceptDir(const QString& newValue)
|
|
|
|
{
|
|
|
|
globalAutoAcceptDir = newValue;
|
|
|
|
}
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
void Settings::setWidgetData(const QString& uniqueName, const QByteArray& data)
|
|
|
|
{
|
|
|
|
widgetSettings[uniqueName] = data;
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray Settings::getWidgetData(const QString& uniqueName) const
|
|
|
|
{
|
|
|
|
return widgetSettings.value(uniqueName);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Settings::isAnimationEnabled() const
|
|
|
|
{
|
|
|
|
return enableSmoothAnimation;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setAnimationEnabled(bool newValue)
|
|
|
|
{
|
|
|
|
enableSmoothAnimation = newValue;
|
|
|
|
}
|
|
|
|
|
2014-07-25 20:52:14 +08:00
|
|
|
QString Settings::getSmileyPack() const
|
2014-06-25 04:11:11 +08:00
|
|
|
{
|
|
|
|
return smileyPack;
|
|
|
|
}
|
|
|
|
|
2014-07-25 20:52:14 +08:00
|
|
|
void Settings::setSmileyPack(const QString &value)
|
2014-06-25 04:11:11 +08:00
|
|
|
{
|
|
|
|
smileyPack = value;
|
|
|
|
emit smileyPackChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Settings::isCurstomEmojiFont() const
|
|
|
|
{
|
|
|
|
return customEmojiFont;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setCurstomEmojiFont(bool value)
|
|
|
|
{
|
|
|
|
customEmojiFont = value;
|
|
|
|
emit emojiFontChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
int Settings::getEmojiFontPointSize() const
|
|
|
|
{
|
|
|
|
return emojiFontPointSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setEmojiFontPointSize(int value)
|
|
|
|
{
|
|
|
|
emojiFontPointSize = value;
|
|
|
|
emit emojiFontChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
int Settings::getFirstColumnHandlePos() const
|
|
|
|
{
|
|
|
|
return firstColumnHandlePos;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setFirstColumnHandlePos(const int pos)
|
|
|
|
{
|
|
|
|
firstColumnHandlePos = pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Settings::getSecondColumnHandlePosFromRight() const
|
|
|
|
{
|
|
|
|
return secondColumnHandlePosFromRight;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setSecondColumnHandlePosFromRight(const int pos)
|
|
|
|
{
|
|
|
|
secondColumnHandlePosFromRight = pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString &Settings::getTimestampFormat() const
|
|
|
|
{
|
|
|
|
return timestampFormat;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setTimestampFormat(const QString &format)
|
|
|
|
{
|
|
|
|
timestampFormat = format;
|
|
|
|
emit timestampFormatChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Settings::getEmojiFontFamily() const
|
|
|
|
{
|
|
|
|
return emojiFontFamily;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setEmojiFontFamily(const QString &value)
|
|
|
|
{
|
|
|
|
emojiFontFamily = value;
|
|
|
|
emit emojiFontChanged();
|
|
|
|
}
|
|
|
|
|
2014-08-11 00:14:50 +08:00
|
|
|
bool Settings::getUseNativeStyle() const
|
|
|
|
{
|
|
|
|
return useNativeStyle;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setUseNativeStyle(bool value)
|
|
|
|
{
|
|
|
|
useNativeStyle = value;
|
|
|
|
}
|
|
|
|
|
2014-08-11 16:00:08 +08:00
|
|
|
QByteArray Settings::getWindowGeometry() const
|
|
|
|
{
|
|
|
|
return windowGeometry;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setWindowGeometry(const QByteArray &value)
|
|
|
|
{
|
|
|
|
windowGeometry = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray Settings::getWindowState() const
|
|
|
|
{
|
|
|
|
return windowState;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setWindowState(const QByteArray &value)
|
|
|
|
{
|
|
|
|
windowState = value;
|
|
|
|
}
|
|
|
|
|
2014-11-10 07:31:29 +08:00
|
|
|
bool Settings::getCheckUpdates() const
|
|
|
|
{
|
|
|
|
return checkUpdates;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setCheckUpdates(bool newValue)
|
|
|
|
{
|
|
|
|
checkUpdates = newValue;
|
|
|
|
}
|
|
|
|
|
2015-01-21 19:10:41 +08:00
|
|
|
bool Settings::getShowWindow() const
|
|
|
|
{
|
|
|
|
return showWindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setShowWindow(bool newValue)
|
|
|
|
{
|
|
|
|
showWindow = newValue;
|
|
|
|
}
|
|
|
|
|
2014-08-11 20:07:27 +08:00
|
|
|
QByteArray Settings::getSplitterState() const
|
|
|
|
{
|
|
|
|
return splitterState;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setSplitterState(const QByteArray &value)
|
|
|
|
{
|
|
|
|
splitterState = value;
|
|
|
|
}
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
bool Settings::isMinimizeOnCloseEnabled() const
|
|
|
|
{
|
|
|
|
return minimizeOnClose;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setMinimizeOnClose(bool newValue)
|
|
|
|
{
|
|
|
|
minimizeOnClose = newValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Settings::isTypingNotificationEnabled() const
|
|
|
|
{
|
|
|
|
return typingNotification;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setTypingNotification(bool enabled)
|
|
|
|
{
|
|
|
|
typingNotification = enabled;
|
|
|
|
}
|
2014-10-29 04:21:37 +08:00
|
|
|
|
|
|
|
QString Settings::getInDev() const
|
|
|
|
{
|
|
|
|
return inDev;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setInDev(const QString& deviceSpecifier)
|
|
|
|
{
|
|
|
|
inDev = deviceSpecifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Settings::getOutDev() const
|
|
|
|
{
|
|
|
|
return outDev;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setOutDev(const QString& deviceSpecifier)
|
|
|
|
{
|
|
|
|
outDev = deviceSpecifier;
|
|
|
|
}
|
2014-11-08 00:02:10 +08:00
|
|
|
|
2014-12-17 08:05:13 +08:00
|
|
|
bool Settings::getFilterAudio() const
|
|
|
|
{
|
2014-12-14 16:50:18 +08:00
|
|
|
return filterAudio;
|
|
|
|
}
|
|
|
|
|
2014-12-17 08:05:13 +08:00
|
|
|
void Settings::setFilterAudio(bool newValue)
|
|
|
|
{
|
2014-12-14 16:50:18 +08:00
|
|
|
filterAudio = newValue;
|
|
|
|
}
|
|
|
|
|
2015-01-24 09:03:26 +08:00
|
|
|
QSize Settings::getCamVideoRes() const
|
|
|
|
{
|
|
|
|
return camVideoRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setCamVideoRes(QSize newValue)
|
|
|
|
{
|
|
|
|
camVideoRes = newValue;
|
|
|
|
}
|
|
|
|
|
2014-11-08 00:02:10 +08:00
|
|
|
QString Settings::getFriendAdress(const QString &publicKey) const
|
|
|
|
{
|
|
|
|
QString key = ToxID::fromString(publicKey).publicKey;
|
|
|
|
auto it = friendLst.find(key);
|
|
|
|
if (it != friendLst.end())
|
|
|
|
{
|
|
|
|
return it->addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::updateFriendAdress(const QString &newAddr)
|
|
|
|
{
|
|
|
|
QString key = ToxID::fromString(newAddr).publicKey;
|
|
|
|
auto it = friendLst.find(key);
|
|
|
|
if (it != friendLst.end())
|
|
|
|
{
|
|
|
|
it->addr = newAddr;
|
|
|
|
} else {
|
|
|
|
friendProp fp;
|
|
|
|
fp.addr = newAddr;
|
|
|
|
fp.alias = "";
|
2014-11-17 18:10:38 +08:00
|
|
|
fp.autoAcceptDir = "";
|
2014-11-08 00:02:10 +08:00
|
|
|
friendLst[newAddr] = fp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Settings::getFriendAlias(const ToxID &id) const
|
|
|
|
{
|
|
|
|
QString key = id.publicKey;
|
|
|
|
auto it = friendLst.find(key);
|
|
|
|
if (it != friendLst.end())
|
|
|
|
{
|
|
|
|
return it->alias;
|
|
|
|
}
|
|
|
|
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setFriendAlias(const ToxID &id, const QString &alias)
|
|
|
|
{
|
|
|
|
QString key = id.publicKey;
|
|
|
|
auto it = friendLst.find(key);
|
|
|
|
if (it != friendLst.end())
|
|
|
|
{
|
|
|
|
it->alias = alias;
|
2014-11-12 00:29:00 +08:00
|
|
|
} else {
|
|
|
|
friendProp fp;
|
|
|
|
fp.addr = key;
|
|
|
|
fp.alias = alias;
|
2014-11-17 18:10:38 +08:00
|
|
|
fp.autoAcceptDir = "";
|
2014-11-12 00:29:00 +08:00
|
|
|
friendLst[key] = fp;
|
2014-11-08 00:02:10 +08:00
|
|
|
}
|
|
|
|
}
|
2014-11-10 21:06:35 +08:00
|
|
|
|
2014-11-12 00:52:19 +08:00
|
|
|
void Settings::removeFriendSettings(const ToxID &id)
|
|
|
|
{
|
|
|
|
QString key = id.publicKey;
|
|
|
|
friendLst.remove(key);
|
|
|
|
}
|
|
|
|
|
2014-11-10 21:06:35 +08:00
|
|
|
bool Settings::getFauxOfflineMessaging() const
|
|
|
|
{
|
|
|
|
return fauxOfflineMessaging;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setFauxOfflineMessaging(bool value)
|
|
|
|
{
|
|
|
|
fauxOfflineMessaging = value;
|
|
|
|
}
|
2014-11-16 04:30:20 +08:00
|
|
|
|
2014-12-11 22:31:01 +08:00
|
|
|
bool Settings::getCompactLayout() const
|
|
|
|
{
|
2014-12-11 20:02:45 +08:00
|
|
|
return compactLayout;
|
|
|
|
}
|
|
|
|
|
2014-12-11 22:31:01 +08:00
|
|
|
void Settings::setCompactLayout(bool value)
|
|
|
|
{
|
2014-12-11 20:02:45 +08:00
|
|
|
compactLayout = value;
|
|
|
|
emit compactLayoutChanged();
|
|
|
|
}
|
|
|
|
|
2014-11-16 04:30:20 +08:00
|
|
|
int Settings::getThemeColor() const
|
|
|
|
{
|
|
|
|
return themeColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Settings::setThemeColor(const int &value)
|
|
|
|
{
|
|
|
|
themeColor = value;
|
|
|
|
}
|