mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
commit
1753f750b3
|
@ -419,7 +419,7 @@ bool Core::checkConnection()
|
||||||
void Core::bootstrapDht()
|
void Core::bootstrapDht()
|
||||||
{
|
{
|
||||||
const Settings& s = Settings::getInstance();
|
const Settings& s = Settings::getInstance();
|
||||||
QList<Settings::DhtServer> dhtServerList = s.getDhtServerList();
|
QList<DhtServer> dhtServerList = s.getDhtServerList();
|
||||||
|
|
||||||
int listSize = dhtServerList.size();
|
int listSize = dhtServerList.size();
|
||||||
if (listSize == 0)
|
if (listSize == 0)
|
||||||
|
@ -434,7 +434,7 @@ void Core::bootstrapDht()
|
||||||
int i=0;
|
int i=0;
|
||||||
while (i < 2) // i think the more we bootstrap, the more we jitter because the more we overwrite nodes
|
while (i < 2) // i think the more we bootstrap, the more we jitter because the more we overwrite nodes
|
||||||
{
|
{
|
||||||
const Settings::DhtServer& dhtServer = dhtServerList[j % listSize];
|
const DhtServer& dhtServer = dhtServerList[j % listSize];
|
||||||
if (tox_bootstrap(tox, dhtServer.address.toLatin1().data(),
|
if (tox_bootstrap(tox, dhtServer.address.toLatin1().data(),
|
||||||
dhtServer.port, CUserId(dhtServer.userId).data(), nullptr))
|
dhtServer.port, CUserId(dhtServer.userId).data(), nullptr))
|
||||||
{
|
{
|
||||||
|
|
|
@ -243,8 +243,8 @@ void CoreFile::onFileReceiveCallback(Tox*, uint32_t friendId, uint32_t fileId, u
|
||||||
{
|
{
|
||||||
// Avatars of size 0 means explicitely no avatar
|
// Avatars of size 0 means explicitely no avatar
|
||||||
emit core->friendAvatarRemoved(friendId);
|
emit core->friendAvatarRemoved(friendId);
|
||||||
QFile::remove(QDir(Settings::getSettingsDirPath()).filePath("avatars/"+friendAddr.left(64)+".png"));
|
QFile::remove(Settings::getInstance().getSettingsDirPath()+"avatars/"+friendAddr.left(64)+".png");
|
||||||
QFile::remove(QDir(Settings::getSettingsDirPath()).filePath("avatars/"+friendAddr.left(64)+".hash"));
|
QFile::remove(Settings::getInstance().getSettingsDirPath()+"avatars/"+friendAddr.left(64)+".hash");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -11,6 +11,14 @@ class QTimer;
|
||||||
|
|
||||||
enum class Status : int {Online = 0, Away, Busy, Offline};
|
enum class Status : int {Online = 0, Away, Busy, Offline};
|
||||||
|
|
||||||
|
struct DhtServer
|
||||||
|
{
|
||||||
|
QString name;
|
||||||
|
QString userId;
|
||||||
|
QString address;
|
||||||
|
quint16 port;
|
||||||
|
};
|
||||||
|
|
||||||
struct ToxFile
|
struct ToxFile
|
||||||
{
|
{
|
||||||
enum FileStatus
|
enum FileStatus
|
||||||
|
|
|
@ -359,7 +359,7 @@ HistoryKeeper::ChatType HistoryKeeper::convertToChatType(int ct)
|
||||||
|
|
||||||
QString HistoryKeeper::getHistoryPath(QString currentProfile, int encrypted)
|
QString HistoryKeeper::getHistoryPath(QString currentProfile, int encrypted)
|
||||||
{
|
{
|
||||||
QDir baseDir(Settings::getSettingsDirPath());
|
QDir baseDir(Settings::getInstance().getSettingsDirPath());
|
||||||
if (currentProfile.isEmpty())
|
if (currentProfile.isEmpty())
|
||||||
currentProfile = Settings::getInstance().getCurrentProfile();
|
currentProfile = Settings::getInstance().getCurrentProfile();
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ int main(int argc, char *argv[])
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
qsrand(time(0));
|
qsrand(time(0));
|
||||||
|
Settings::getInstance();
|
||||||
Translator::translate();
|
Translator::translate();
|
||||||
|
|
||||||
// Process arguments
|
// Process arguments
|
||||||
|
@ -110,7 +110,6 @@ int main(int argc, char *argv[])
|
||||||
#ifndef Q_OS_ANDROID
|
#ifndef Q_OS_ANDROID
|
||||||
IPC::getInstance();
|
IPC::getInstance();
|
||||||
#endif
|
#endif
|
||||||
Settings::getInstance(); // Build our Settings singleton as soon as QApplication is ready, not before
|
|
||||||
|
|
||||||
if (parser.isSet("p"))
|
if (parser.isSet("p"))
|
||||||
{
|
{
|
||||||
|
@ -144,7 +143,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
#ifdef LOG_TO_FILE
|
#ifdef LOG_TO_FILE
|
||||||
logFile = new QTextStream;
|
logFile = new QTextStream;
|
||||||
QFile logfile(Settings::getSettingsDirPath()+"qtox.log");
|
QFile logfile(Settings::getInstance().getSettingsDirPath()+"qtox.log");
|
||||||
if (logfile.open(QIODevice::Append))
|
if (logfile.open(QIODevice::Append))
|
||||||
{
|
{
|
||||||
logFile->setDevice(&logfile);
|
logFile->setDevice(&logfile);
|
||||||
|
@ -272,6 +271,7 @@ int main(int argc, char *argv[])
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Nexus::destroyInstance();
|
Nexus::destroyInstance();
|
||||||
|
Settings::destroyInstance();
|
||||||
|
qDebug() << "Clean exit with status"<<errorcode;
|
||||||
return errorcode;
|
return errorcode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,20 +36,35 @@
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QStyleFactory>
|
#include <QStyleFactory>
|
||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
|
#include <QMutexLocker>
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
#define SHOW_SYSTEM_TRAY_DEFAULT (bool) true
|
#define SHOW_SYSTEM_TRAY_DEFAULT (bool) true
|
||||||
|
|
||||||
const QString Settings::globalSettingsFile = "qtox.ini";
|
const QString Settings::globalSettingsFile = "qtox.ini";
|
||||||
Settings* Settings::settings{nullptr};
|
Settings* Settings::settings{nullptr};
|
||||||
bool Settings::makeToxPortable{false};
|
QMutex Settings::bigLock{QMutex::Recursive};
|
||||||
|
QThread* Settings::settingsThread{nullptr};
|
||||||
|
|
||||||
Settings::Settings() :
|
Settings::Settings() :
|
||||||
loaded(false), useCustomDhtList{false}, currentProfileId(0)
|
loaded(false), useCustomDhtList{false},
|
||||||
|
makeToxPortable{false}, currentProfileId(0)
|
||||||
{
|
{
|
||||||
|
settingsThread = new QThread();
|
||||||
|
settingsThread->setObjectName("qTox Settings");
|
||||||
|
settingsThread->start(QThread::LowPriority);
|
||||||
|
moveToThread(settingsThread);
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Settings::~Settings()
|
||||||
|
{
|
||||||
|
sync();
|
||||||
|
settingsThread->exit(0);
|
||||||
|
settingsThread->wait();
|
||||||
|
delete settingsThread;
|
||||||
|
}
|
||||||
|
|
||||||
Settings& Settings::getInstance()
|
Settings& Settings::getInstance()
|
||||||
{
|
{
|
||||||
if (!settings)
|
if (!settings)
|
||||||
|
@ -58,8 +73,16 @@ Settings& Settings::getInstance()
|
||||||
return *settings;
|
return *settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Settings::destroyInstance()
|
||||||
|
{
|
||||||
|
delete settings;
|
||||||
|
settings = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void Settings::load()
|
void Settings::load()
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
|
|
||||||
if (loaded)
|
if (loaded)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -259,12 +282,20 @@ void Settings::load()
|
||||||
|
|
||||||
void Settings::save(bool writePersonal)
|
void Settings::save(bool writePersonal)
|
||||||
{
|
{
|
||||||
QString filePath = QDir(getSettingsDirPath()).filePath(globalSettingsFile);
|
if (QThread::currentThread() != settingsThread)
|
||||||
|
return (void) QMetaObject::invokeMethod(&getInstance(), "save",
|
||||||
|
Q_ARG(bool, writePersonal));
|
||||||
|
|
||||||
|
QString filePath = getSettingsDirPath()+globalSettingsFile;
|
||||||
save(filePath, writePersonal);
|
save(filePath, writePersonal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::save(QString path, bool writePersonal)
|
void Settings::save(QString path, bool writePersonal)
|
||||||
{
|
{
|
||||||
|
if (QThread::currentThread() != settingsThread)
|
||||||
|
return (void) QMetaObject::invokeMethod(&getInstance(), "save",
|
||||||
|
Q_ARG(QString, path), Q_ARG(bool, writePersonal));
|
||||||
|
|
||||||
#ifndef Q_OS_ANDROID
|
#ifndef Q_OS_ANDROID
|
||||||
if (IPC::getInstance().isCurrentOwner())
|
if (IPC::getInstance().isCurrentOwner())
|
||||||
#endif
|
#endif
|
||||||
|
@ -276,6 +307,7 @@ void Settings::save(QString path, bool writePersonal)
|
||||||
|
|
||||||
void Settings::saveGlobal(QString path)
|
void Settings::saveGlobal(QString path)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
qDebug() << "Saving settings in " + path;
|
qDebug() << "Saving settings in " + path;
|
||||||
|
|
||||||
QSettings s(path, QSettings::IniFormat);
|
QSettings s(path, QSettings::IniFormat);
|
||||||
|
@ -376,6 +408,7 @@ void Settings::saveGlobal(QString path)
|
||||||
|
|
||||||
void Settings::savePersonal(QString path)
|
void Settings::savePersonal(QString path)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
if (currentProfile.isEmpty())
|
if (currentProfile.isEmpty())
|
||||||
{
|
{
|
||||||
qDebug() << "could not save personal settings because currentProfile profile is empty";
|
qDebug() << "could not save personal settings because currentProfile profile is empty";
|
||||||
|
@ -414,16 +447,17 @@ uint32_t Settings::makeProfileId(const QString& profile)
|
||||||
|
|
||||||
QString Settings::getSettingsDirPath()
|
QString Settings::getSettingsDirPath()
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
if (makeToxPortable)
|
if (makeToxPortable)
|
||||||
return QString(".")+QDir::separator();
|
return QString(".")+QDir::separator();
|
||||||
|
|
||||||
// workaround for https://bugreports.qt-project.org/browse/QTBUG-38845
|
// workaround for https://bugreports.qt-project.org/browse/QTBUG-38845
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator()
|
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator()
|
||||||
+ "AppData" + QDir::separator() + "Roaming" + QDir::separator() + "tox" + QDir::separator());
|
+ "AppData" + QDir::separator() + "Roaming" + QDir::separator() + "tox")+QDir::separator();
|
||||||
#else
|
#else
|
||||||
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)
|
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)
|
||||||
+ QDir::separator() + "tox" + QDir::separator());
|
+ QDir::separator() + "tox")+QDir::separator();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,34 +518,40 @@ QByteArray Settings::getAvatarHash(const QString& ownerId)
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QList<Settings::DhtServer>& Settings::getDhtServerList() const
|
const QList<DhtServer>& Settings::getDhtServerList() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return dhtServerList;
|
return dhtServerList;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setDhtServerList(const QList<DhtServer>& newDhtServerList)
|
void Settings::setDhtServerList(const QList<DhtServer>& newDhtServerList)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
dhtServerList = newDhtServerList;
|
dhtServerList = newDhtServerList;
|
||||||
emit dhtServerListChanged();
|
emit dhtServerListChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::getEnableIPv6() const
|
bool Settings::getEnableIPv6() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return enableIPv6;
|
return enableIPv6;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setEnableIPv6(bool newValue)
|
void Settings::setEnableIPv6(bool newValue)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
enableIPv6 = newValue;
|
enableIPv6 = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::getMakeToxPortable() const
|
bool Settings::getMakeToxPortable() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return makeToxPortable;
|
return makeToxPortable;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setMakeToxPortable(bool newValue)
|
void Settings::setMakeToxPortable(bool newValue)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
makeToxPortable = newValue;
|
makeToxPortable = newValue;
|
||||||
save(globalSettingsFile); // Commit to the portable file that we don't want to use it
|
save(globalSettingsFile); // Commit to the portable file that we don't want to use it
|
||||||
if (!newValue) // Update the new file right now if not already done
|
if (!newValue) // Update the new file right now if not already done
|
||||||
|
@ -521,6 +561,7 @@ void Settings::setMakeToxPortable(bool newValue)
|
||||||
bool Settings::getAutorun() const
|
bool Settings::getAutorun() const
|
||||||
{
|
{
|
||||||
#ifdef QTOX_PLATFORM_EXT
|
#ifdef QTOX_PLATFORM_EXT
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return Platform::getAutorun();
|
return Platform::getAutorun();
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
|
@ -530,6 +571,7 @@ bool Settings::getAutorun() const
|
||||||
void Settings::setAutorun(bool newValue)
|
void Settings::setAutorun(bool newValue)
|
||||||
{
|
{
|
||||||
#ifdef QTOX_PLATFORM_EXT
|
#ifdef QTOX_PLATFORM_EXT
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
Platform::setAutorun(newValue);
|
Platform::setAutorun(newValue);
|
||||||
#else
|
#else
|
||||||
Q_UNUSED(newValue);
|
Q_UNUSED(newValue);
|
||||||
|
@ -538,152 +580,181 @@ void Settings::setAutorun(bool newValue)
|
||||||
|
|
||||||
bool Settings::getAutostartInTray() const
|
bool Settings::getAutostartInTray() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return autostartInTray;
|
return autostartInTray;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Settings::getStyle() const
|
QString Settings::getStyle() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return style;
|
return style;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setStyle(const QString& newStyle)
|
void Settings::setStyle(const QString& newStyle)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
style = newStyle;
|
style = newStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::getShowSystemTray() const
|
bool Settings::getShowSystemTray() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return showSystemTray;
|
return showSystemTray;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setShowSystemTray(const bool& newValue)
|
void Settings::setShowSystemTray(const bool& newValue)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
showSystemTray = newValue;
|
showSystemTray = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setUseEmoticons(bool newValue)
|
void Settings::setUseEmoticons(bool newValue)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
useEmoticons = newValue;
|
useEmoticons = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::getUseEmoticons() const
|
bool Settings::getUseEmoticons() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return useEmoticons;
|
return useEmoticons;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setAutoSaveEnabled(bool newValue)
|
void Settings::setAutoSaveEnabled(bool newValue)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
autoSaveEnabled = newValue;
|
autoSaveEnabled = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::getAutoSaveEnabled() const
|
bool Settings::getAutoSaveEnabled() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return autoSaveEnabled;
|
return autoSaveEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setAutostartInTray(bool newValue)
|
void Settings::setAutostartInTray(bool newValue)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
autostartInTray = newValue;
|
autostartInTray = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::getCloseToTray() const
|
bool Settings::getCloseToTray() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return closeToTray;
|
return closeToTray;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setCloseToTray(bool newValue)
|
void Settings::setCloseToTray(bool newValue)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
closeToTray = newValue;
|
closeToTray = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::getMinimizeToTray() const
|
bool Settings::getMinimizeToTray() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return minimizeToTray;
|
return minimizeToTray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Settings::setMinimizeToTray(bool newValue)
|
void Settings::setMinimizeToTray(bool newValue)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
minimizeToTray = newValue;
|
minimizeToTray = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::getLightTrayIcon() const
|
bool Settings::getLightTrayIcon() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return lightTrayIcon;
|
return lightTrayIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setLightTrayIcon(bool newValue)
|
void Settings::setLightTrayIcon(bool newValue)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
lightTrayIcon = newValue;
|
lightTrayIcon = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::getStatusChangeNotificationEnabled() const
|
bool Settings::getStatusChangeNotificationEnabled() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return statusChangeNotificationEnabled;
|
return statusChangeNotificationEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setStatusChangeNotificationEnabled(bool newValue)
|
void Settings::setStatusChangeNotificationEnabled(bool newValue)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
statusChangeNotificationEnabled = newValue;
|
statusChangeNotificationEnabled = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::getShowInFront() const
|
bool Settings::getShowInFront() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return showInFront;
|
return showInFront;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setShowInFront(bool newValue)
|
void Settings::setShowInFront(bool newValue)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
showInFront = newValue;
|
showInFront = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::getNotifySound() const
|
bool Settings::getNotifySound() const
|
||||||
{
|
{
|
||||||
return notifySound;
|
QMutexLocker locker{&bigLock};
|
||||||
|
return notifySound;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setNotifySound(bool newValue)
|
void Settings::setNotifySound(bool newValue)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
notifySound = newValue;
|
notifySound = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::getGroupAlwaysNotify() const
|
bool Settings::getGroupAlwaysNotify() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return groupAlwaysNotify;
|
return groupAlwaysNotify;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setGroupAlwaysNotify(bool newValue)
|
void Settings::setGroupAlwaysNotify(bool newValue)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
groupAlwaysNotify = newValue;
|
groupAlwaysNotify = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Settings::getTranslation() const
|
QString Settings::getTranslation() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return translation;
|
return translation;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setTranslation(QString newValue)
|
void Settings::setTranslation(QString newValue)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
translation = newValue;
|
translation = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::getForceTCP() const
|
bool Settings::getForceTCP() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return forceTCP;
|
return forceTCP;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setForceTCP(bool newValue)
|
void Settings::setForceTCP(bool newValue)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
forceTCP = newValue;
|
forceTCP = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProxyType Settings::getProxyType() const
|
ProxyType Settings::getProxyType() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return proxyType;
|
return proxyType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setProxyType(int newValue)
|
void Settings::setProxyType(int newValue)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
if (newValue >= 0 && newValue <= 2)
|
if (newValue >= 0 && newValue <= 2)
|
||||||
proxyType = static_cast<ProxyType>(newValue);
|
proxyType = static_cast<ProxyType>(newValue);
|
||||||
else
|
else
|
||||||
|
@ -692,57 +763,68 @@ void Settings::setProxyType(int newValue)
|
||||||
|
|
||||||
QString Settings::getProxyAddr() const
|
QString Settings::getProxyAddr() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return proxyAddr;
|
return proxyAddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setProxyAddr(const QString& newValue)
|
void Settings::setProxyAddr(const QString& newValue)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
proxyAddr = newValue;
|
proxyAddr = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Settings::getProxyPort() const
|
int Settings::getProxyPort() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return proxyPort;
|
return proxyPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setProxyPort(int newValue)
|
void Settings::setProxyPort(int newValue)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
proxyPort = newValue;
|
proxyPort = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Settings::getCurrentProfile() const
|
QString Settings::getCurrentProfile() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return currentProfile;
|
return currentProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Settings::getCurrentProfileId() const
|
uint32_t Settings::getCurrentProfileId() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return currentProfileId;
|
return currentProfileId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setCurrentProfile(QString profile)
|
void Settings::setCurrentProfile(QString profile)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
currentProfile = profile;
|
currentProfile = profile;
|
||||||
currentProfileId = makeProfileId(currentProfile);
|
currentProfileId = makeProfileId(currentProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::getEnableLogging() const
|
bool Settings::getEnableLogging() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return enableLogging;
|
return enableLogging;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setEnableLogging(bool newValue)
|
void Settings::setEnableLogging(bool newValue)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
enableLogging = newValue;
|
enableLogging = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Db::syncType Settings::getDbSyncType() const
|
Db::syncType Settings::getDbSyncType() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return dbSyncType;
|
return dbSyncType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setDbSyncType(int newValue)
|
void Settings::setDbSyncType(int newValue)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
if (newValue >= 0 && newValue <= 2)
|
if (newValue >= 0 && newValue <= 2)
|
||||||
dbSyncType = static_cast<Db::syncType>(newValue);
|
dbSyncType = static_cast<Db::syncType>(newValue);
|
||||||
else
|
else
|
||||||
|
@ -751,11 +833,13 @@ void Settings::setDbSyncType(int newValue)
|
||||||
|
|
||||||
int Settings::getAutoAwayTime() const
|
int Settings::getAutoAwayTime() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return autoAwayTime;
|
return autoAwayTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setAutoAwayTime(int newValue)
|
void Settings::setAutoAwayTime(int newValue)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
if (newValue < 0)
|
if (newValue < 0)
|
||||||
newValue = 10;
|
newValue = 10;
|
||||||
|
|
||||||
|
@ -764,6 +848,7 @@ void Settings::setAutoAwayTime(int newValue)
|
||||||
|
|
||||||
QString Settings::getAutoAcceptDir(const ToxId& id) const
|
QString Settings::getAutoAcceptDir(const ToxId& id) const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
QString key = id.publicKey;
|
QString key = id.publicKey;
|
||||||
|
|
||||||
auto it = friendLst.find(key);
|
auto it = friendLst.find(key);
|
||||||
|
@ -775,6 +860,7 @@ QString Settings::getAutoAcceptDir(const ToxId& id) const
|
||||||
|
|
||||||
void Settings::setAutoAcceptDir(const ToxId &id, const QString& dir)
|
void Settings::setAutoAcceptDir(const ToxId &id, const QString& dir)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
QString key = id.publicKey;
|
QString key = id.publicKey;
|
||||||
|
|
||||||
auto it = friendLst.find(key);
|
auto it = friendLst.find(key);
|
||||||
|
@ -791,251 +877,299 @@ void Settings::setAutoAcceptDir(const ToxId &id, const QString& dir)
|
||||||
|
|
||||||
QString Settings::getGlobalAutoAcceptDir() const
|
QString Settings::getGlobalAutoAcceptDir() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return globalAutoAcceptDir;
|
return globalAutoAcceptDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setGlobalAutoAcceptDir(const QString& newValue)
|
void Settings::setGlobalAutoAcceptDir(const QString& newValue)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
globalAutoAcceptDir = newValue;
|
globalAutoAcceptDir = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setWidgetData(const QString& uniqueName, const QByteArray& data)
|
void Settings::setWidgetData(const QString& uniqueName, const QByteArray& data)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
widgetSettings[uniqueName] = data;
|
widgetSettings[uniqueName] = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray Settings::getWidgetData(const QString& uniqueName) const
|
QByteArray Settings::getWidgetData(const QString& uniqueName) const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return widgetSettings.value(uniqueName);
|
return widgetSettings.value(uniqueName);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::isAnimationEnabled() const
|
bool Settings::isAnimationEnabled() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return enableSmoothAnimation;
|
return enableSmoothAnimation;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setAnimationEnabled(bool newValue)
|
void Settings::setAnimationEnabled(bool newValue)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
enableSmoothAnimation = newValue;
|
enableSmoothAnimation = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Settings::getSmileyPack() const
|
QString Settings::getSmileyPack() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return smileyPack;
|
return smileyPack;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setSmileyPack(const QString &value)
|
void Settings::setSmileyPack(const QString &value)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
smileyPack = value;
|
smileyPack = value;
|
||||||
emit smileyPackChanged();
|
emit smileyPackChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::isCurstomEmojiFont() const
|
bool Settings::isCurstomEmojiFont() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return customEmojiFont;
|
return customEmojiFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setCurstomEmojiFont(bool value)
|
void Settings::setCurstomEmojiFont(bool value)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
customEmojiFont = value;
|
customEmojiFont = value;
|
||||||
emit emojiFontChanged();
|
emit emojiFontChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Settings::getEmojiFontPointSize() const
|
int Settings::getEmojiFontPointSize() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return emojiFontPointSize;
|
return emojiFontPointSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setEmojiFontPointSize(int value)
|
void Settings::setEmojiFontPointSize(int value)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
emojiFontPointSize = value;
|
emojiFontPointSize = value;
|
||||||
emit emojiFontChanged();
|
emit emojiFontChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Settings::getFirstColumnHandlePos() const
|
int Settings::getFirstColumnHandlePos() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return firstColumnHandlePos;
|
return firstColumnHandlePos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setFirstColumnHandlePos(const int pos)
|
void Settings::setFirstColumnHandlePos(const int pos)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
firstColumnHandlePos = pos;
|
firstColumnHandlePos = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Settings::getSecondColumnHandlePosFromRight() const
|
int Settings::getSecondColumnHandlePosFromRight() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return secondColumnHandlePosFromRight;
|
return secondColumnHandlePosFromRight;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setSecondColumnHandlePosFromRight(const int pos)
|
void Settings::setSecondColumnHandlePosFromRight(const int pos)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
secondColumnHandlePosFromRight = pos;
|
secondColumnHandlePosFromRight = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString& Settings::getTimestampFormat() const
|
const QString& Settings::getTimestampFormat() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return timestampFormat;
|
return timestampFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setTimestampFormat(const QString &format)
|
void Settings::setTimestampFormat(const QString &format)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
timestampFormat = format;
|
timestampFormat = format;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString& Settings::getDateFormat() const
|
const QString& Settings::getDateFormat() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return dateFormat;
|
return dateFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setDateFormat(const QString &format)
|
void Settings::setDateFormat(const QString &format)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
dateFormat = format;
|
dateFormat = format;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString Settings::getEmojiFontFamily() const
|
QString Settings::getEmojiFontFamily() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return emojiFontFamily;
|
return emojiFontFamily;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setEmojiFontFamily(const QString &value)
|
void Settings::setEmojiFontFamily(const QString &value)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
emojiFontFamily = value;
|
emojiFontFamily = value;
|
||||||
emit emojiFontChanged();
|
emit emojiFontChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::getUseNativeStyle() const
|
bool Settings::getUseNativeStyle() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return useNativeStyle;
|
return useNativeStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setUseNativeStyle(bool value)
|
void Settings::setUseNativeStyle(bool value)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
useNativeStyle = value;
|
useNativeStyle = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray Settings::getWindowGeometry() const
|
QByteArray Settings::getWindowGeometry() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return windowGeometry;
|
return windowGeometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setWindowGeometry(const QByteArray &value)
|
void Settings::setWindowGeometry(const QByteArray &value)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
windowGeometry = value;
|
windowGeometry = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray Settings::getWindowState() const
|
QByteArray Settings::getWindowState() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return windowState;
|
return windowState;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setWindowState(const QByteArray &value)
|
void Settings::setWindowState(const QByteArray &value)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
windowState = value;
|
windowState = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::getCheckUpdates() const
|
bool Settings::getCheckUpdates() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return checkUpdates;
|
return checkUpdates;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setCheckUpdates(bool newValue)
|
void Settings::setCheckUpdates(bool newValue)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
checkUpdates = newValue;
|
checkUpdates = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::getShowWindow() const
|
bool Settings::getShowWindow() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return showWindow;
|
return showWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setShowWindow(bool newValue)
|
void Settings::setShowWindow(bool newValue)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
showWindow = newValue;
|
showWindow = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray Settings::getSplitterState() const
|
QByteArray Settings::getSplitterState() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return splitterState;
|
return splitterState;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setSplitterState(const QByteArray &value)
|
void Settings::setSplitterState(const QByteArray &value)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
splitterState = value;
|
splitterState = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::isMinimizeOnCloseEnabled() const
|
bool Settings::isMinimizeOnCloseEnabled() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return minimizeOnClose;
|
return minimizeOnClose;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setMinimizeOnClose(bool newValue)
|
void Settings::setMinimizeOnClose(bool newValue)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
minimizeOnClose = newValue;
|
minimizeOnClose = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::isTypingNotificationEnabled() const
|
bool Settings::isTypingNotificationEnabled() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return typingNotification;
|
return typingNotification;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setTypingNotification(bool enabled)
|
void Settings::setTypingNotification(bool enabled)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
typingNotification = enabled;
|
typingNotification = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Settings::getInDev() const
|
QString Settings::getInDev() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return inDev;
|
return inDev;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setInDev(const QString& deviceSpecifier)
|
void Settings::setInDev(const QString& deviceSpecifier)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
inDev = deviceSpecifier;
|
inDev = deviceSpecifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Settings::getVideoDev() const
|
QString Settings::getVideoDev() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return videoDev;
|
return videoDev;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setVideoDev(const QString& deviceSpecifier)
|
void Settings::setVideoDev(const QString& deviceSpecifier)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
videoDev = deviceSpecifier;
|
videoDev = deviceSpecifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Settings::getOutDev() const
|
QString Settings::getOutDev() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return outDev;
|
return outDev;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setOutDev(const QString& deviceSpecifier)
|
void Settings::setOutDev(const QString& deviceSpecifier)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
outDev = deviceSpecifier;
|
outDev = deviceSpecifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::getFilterAudio() const
|
bool Settings::getFilterAudio() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return filterAudio;
|
return filterAudio;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setFilterAudio(bool newValue)
|
void Settings::setFilterAudio(bool newValue)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
filterAudio = newValue;
|
filterAudio = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize Settings::getCamVideoRes() const
|
QSize Settings::getCamVideoRes() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return camVideoRes;
|
return camVideoRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setCamVideoRes(QSize newValue)
|
void Settings::setCamVideoRes(QSize newValue)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
camVideoRes = newValue;
|
camVideoRes = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Settings::getFriendAdress(const QString &publicKey) const
|
QString Settings::getFriendAdress(const QString &publicKey) const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
QString key = ToxId(publicKey).publicKey;
|
QString key = ToxId(publicKey).publicKey;
|
||||||
auto it = friendLst.find(key);
|
auto it = friendLst.find(key);
|
||||||
if (it != friendLst.end())
|
if (it != friendLst.end())
|
||||||
|
@ -1046,6 +1180,7 @@ QString Settings::getFriendAdress(const QString &publicKey) const
|
||||||
|
|
||||||
void Settings::updateFriendAdress(const QString &newAddr)
|
void Settings::updateFriendAdress(const QString &newAddr)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
QString key = ToxId(newAddr).publicKey;
|
QString key = ToxId(newAddr).publicKey;
|
||||||
auto it = friendLst.find(key);
|
auto it = friendLst.find(key);
|
||||||
if (it != friendLst.end())
|
if (it != friendLst.end())
|
||||||
|
@ -1064,6 +1199,7 @@ void Settings::updateFriendAdress(const QString &newAddr)
|
||||||
|
|
||||||
QString Settings::getFriendAlias(const ToxId &id) const
|
QString Settings::getFriendAlias(const ToxId &id) const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
QString key = id.publicKey;
|
QString key = id.publicKey;
|
||||||
auto it = friendLst.find(key);
|
auto it = friendLst.find(key);
|
||||||
if (it != friendLst.end())
|
if (it != friendLst.end())
|
||||||
|
@ -1074,6 +1210,7 @@ QString Settings::getFriendAlias(const ToxId &id) const
|
||||||
|
|
||||||
void Settings::setFriendAlias(const ToxId &id, const QString &alias)
|
void Settings::setFriendAlias(const ToxId &id, const QString &alias)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
QString key = id.publicKey;
|
QString key = id.publicKey;
|
||||||
auto it = friendLst.find(key);
|
auto it = friendLst.find(key);
|
||||||
if (it != friendLst.end())
|
if (it != friendLst.end())
|
||||||
|
@ -1092,50 +1229,71 @@ void Settings::setFriendAlias(const ToxId &id, const QString &alias)
|
||||||
|
|
||||||
void Settings::removeFriendSettings(const ToxId &id)
|
void Settings::removeFriendSettings(const ToxId &id)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
QString key = id.publicKey;
|
QString key = id.publicKey;
|
||||||
friendLst.remove(key);
|
friendLst.remove(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::getFauxOfflineMessaging() const
|
bool Settings::getFauxOfflineMessaging() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return fauxOfflineMessaging;
|
return fauxOfflineMessaging;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setFauxOfflineMessaging(bool value)
|
void Settings::setFauxOfflineMessaging(bool value)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
fauxOfflineMessaging = value;
|
fauxOfflineMessaging = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::getCompactLayout() const
|
bool Settings::getCompactLayout() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return compactLayout;
|
return compactLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setCompactLayout(bool value)
|
void Settings::setCompactLayout(bool value)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
compactLayout = value;
|
compactLayout = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::getGroupchatPosition() const
|
bool Settings::getGroupchatPosition() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return groupchatPosition;
|
return groupchatPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setGroupchatPosition(bool value)
|
void Settings::setGroupchatPosition(bool value)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
groupchatPosition = value;
|
groupchatPosition = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Settings::getThemeColor() const
|
int Settings::getThemeColor() const
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
return themeColor;
|
return themeColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setThemeColor(const int &value)
|
void Settings::setThemeColor(const int &value)
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
themeColor = value;
|
themeColor = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Settings::getAutoLogin() const
|
||||||
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
|
return autoLogin;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::setAutoLogin(bool state)
|
||||||
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
|
autoLogin = state;
|
||||||
|
}
|
||||||
|
|
||||||
void Settings::createPersonal(QString basename)
|
void Settings::createPersonal(QString basename)
|
||||||
{
|
{
|
||||||
QString path = getSettingsDirPath() + QDir::separator() + basename + ".ini";
|
QString path = getSettingsDirPath() + QDir::separator() + basename + ".ini";
|
||||||
|
@ -1159,12 +1317,14 @@ void Settings::createSettingsDir()
|
||||||
qCritical() << "Error while creating directory " << dir;
|
qCritical() << "Error while creating directory " << dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::getAutoLogin() const
|
void Settings::sync()
|
||||||
{
|
{
|
||||||
return autoLogin;
|
if (QThread::currentThread() != settingsThread)
|
||||||
}
|
{
|
||||||
|
QMetaObject::invokeMethod(&getInstance(), "sync", Qt::BlockingQueuedConnection);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void Settings::setAutoLogin(bool state)
|
QMutexLocker locker{&bigLock};
|
||||||
{
|
qApp->processEvents();
|
||||||
autoLogin = state;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
#include <QMutex>
|
||||||
|
#include "src/core/corestructs.h"
|
||||||
|
|
||||||
class ToxId;
|
class ToxId;
|
||||||
namespace Db { enum class syncType; }
|
namespace Db { enum class syncType; }
|
||||||
|
@ -30,22 +32,26 @@ class Settings : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
~Settings() = default;
|
|
||||||
static Settings& getInstance();
|
static Settings& getInstance();
|
||||||
|
static void destroyInstance();
|
||||||
|
QString getSettingsDirPath(); ///< The returned path ends with a directory separator
|
||||||
|
|
||||||
void createSettingsDir(); ///< Creates a path to the settings dir, if it doesn't already exist
|
void createSettingsDir(); ///< Creates a path to the settings dir, if it doesn't already exist
|
||||||
|
void createPersonal(QString basename); ///< Write a default personnal .ini settings file for a profile
|
||||||
|
|
||||||
void createPersonal(QString basename); ///< Write a default personnal settings file for a profile
|
public slots:
|
||||||
|
void load();
|
||||||
|
void save(bool writePersonal = true); ///< Asynchronous
|
||||||
|
void save(QString path, bool writePersonal = true); ///< Asynchronous
|
||||||
|
void sync(); ///< Waits for all asynchronous operations to complete
|
||||||
|
|
||||||
static QString getSettingsDirPath(); ///< The returned path ends with a directory separator
|
signals:
|
||||||
|
void dhtServerListChanged();
|
||||||
struct DhtServer
|
void smileyPackChanged();
|
||||||
{
|
void emojiFontChanged();
|
||||||
QString name;
|
|
||||||
QString userId;
|
|
||||||
QString address;
|
|
||||||
quint16 port;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Getter/setters
|
||||||
const QList<DhtServer>& getDhtServerList() const;
|
const QList<DhtServer>& getDhtServerList() const;
|
||||||
void setDhtServerList(const QList<DhtServer>& newDhtServerList);
|
void setDhtServerList(const QList<DhtServer>& newDhtServerList);
|
||||||
|
|
||||||
|
@ -146,28 +152,6 @@ public:
|
||||||
QSize getCamVideoRes() const;
|
QSize getCamVideoRes() const;
|
||||||
void setCamVideoRes(QSize newValue);
|
void setCamVideoRes(QSize newValue);
|
||||||
|
|
||||||
// Assume all widgets have unique names
|
|
||||||
// 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.
|
|
||||||
QByteArray getWidgetData(const QString& uniqueName) const;
|
|
||||||
void setWidgetData(const QString& uniqueName, const QByteArray& data);
|
|
||||||
|
|
||||||
// Wrappers around getWidgetData() and setWidgetData()
|
|
||||||
// Assume widget has a unique objectName set
|
|
||||||
template <class T>
|
|
||||||
void restoreGeometryState(T* widget) const
|
|
||||||
{
|
|
||||||
widget->restoreGeometry(getWidgetData(widget->objectName() + "Geometry"));
|
|
||||||
widget->restoreState(getWidgetData(widget->objectName() + "State"));
|
|
||||||
}
|
|
||||||
template <class T>
|
|
||||||
void saveGeometryState(const T* widget)
|
|
||||||
{
|
|
||||||
setWidgetData(widget->objectName() + "Geometry", widget->saveGeometry());
|
|
||||||
setWidgetData(widget->objectName() + "State", widget->saveState());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isAnimationEnabled() const;
|
bool isAnimationEnabled() const;
|
||||||
void setAnimationEnabled(bool newValue);
|
void setAnimationEnabled(bool newValue);
|
||||||
|
|
||||||
|
@ -248,24 +232,38 @@ public:
|
||||||
bool getAutoLogin() const;
|
bool getAutoLogin() const;
|
||||||
void setAutoLogin(bool state);
|
void setAutoLogin(bool state);
|
||||||
|
|
||||||
public:
|
// Assume all widgets have unique names
|
||||||
void save(bool writePersonal = true);
|
// Don't use it to save every single thing you want to save, use it
|
||||||
void save(QString path, bool writePersonal = true);
|
// for some general purpose widgets, such as MainWindows or Splitters,
|
||||||
void load();
|
// which have widget->saveX() and widget->loadX() methods.
|
||||||
|
QByteArray getWidgetData(const QString& uniqueName) const;
|
||||||
|
void setWidgetData(const QString& uniqueName, const QByteArray& data);
|
||||||
|
|
||||||
|
// Wrappers around getWidgetData() and setWidgetData()
|
||||||
|
// Assume widget has a unique objectName set
|
||||||
|
template <class T>
|
||||||
|
void restoreGeometryState(T* widget) const
|
||||||
|
{
|
||||||
|
widget->restoreGeometry(getWidgetData(widget->objectName() + "Geometry"));
|
||||||
|
widget->restoreState(getWidgetData(widget->objectName() + "State"));
|
||||||
|
}
|
||||||
|
template <class T>
|
||||||
|
void saveGeometryState(const T* widget)
|
||||||
|
{
|
||||||
|
setWidgetData(widget->objectName() + "Geometry", widget->saveGeometry());
|
||||||
|
setWidgetData(widget->objectName() + "State", widget->saveState());
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Settings* settings;
|
|
||||||
|
|
||||||
Settings();
|
Settings();
|
||||||
|
~Settings();
|
||||||
Settings(Settings &settings) = delete;
|
Settings(Settings &settings) = delete;
|
||||||
Settings& operator=(const Settings&) = delete;
|
Settings& operator=(const Settings&) = delete;
|
||||||
static uint32_t makeProfileId(const QString& profile);
|
static uint32_t makeProfileId(const QString& profile);
|
||||||
void saveGlobal(QString path);
|
void saveGlobal(QString path);
|
||||||
void savePersonal(QString path);
|
void savePersonal(QString path);
|
||||||
|
|
||||||
static const QString globalSettingsFile;
|
private:
|
||||||
static const QString OLDFILENAME;
|
|
||||||
|
|
||||||
bool loaded;
|
bool loaded;
|
||||||
|
|
||||||
bool useCustomDhtList;
|
bool useCustomDhtList;
|
||||||
|
@ -279,7 +277,7 @@ private:
|
||||||
bool groupchatPosition;
|
bool groupchatPosition;
|
||||||
bool enableIPv6;
|
bool enableIPv6;
|
||||||
QString translation;
|
QString translation;
|
||||||
static bool makeToxPortable;
|
bool makeToxPortable;
|
||||||
bool autostartInTray;
|
bool autostartInTray;
|
||||||
bool closeToTray;
|
bool closeToTray;
|
||||||
bool minimizeToTray;
|
bool minimizeToTray;
|
||||||
|
@ -354,10 +352,10 @@ private:
|
||||||
|
|
||||||
int themeColor;
|
int themeColor;
|
||||||
|
|
||||||
signals:
|
static QMutex bigLock;
|
||||||
void dhtServerListChanged();
|
static Settings* settings;
|
||||||
void smileyPackChanged();
|
static const QString globalSettingsFile;
|
||||||
void emojiFontChanged();
|
static QThread* settingsThread;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SETTINGS_HPP
|
#endif // SETTINGS_HPP
|
||||||
|
|
|
@ -144,7 +144,7 @@ QByteArray Profile::loadToxSave()
|
||||||
/// TODO: Cache the data, invalidate it only when we save
|
/// TODO: Cache the data, invalidate it only when we save
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
|
|
||||||
QString path = Settings::getSettingsDirPath() + QDir::separator() + name + ".tox";
|
QString path = Settings::getInstance().getSettingsDirPath() + name + ".tox";
|
||||||
QFile saveFile(path);
|
QFile saveFile(path);
|
||||||
qint64 fileSize;
|
qint64 fileSize;
|
||||||
qDebug() << "Loading tox save "<<path;
|
qDebug() << "Loading tox save "<<path;
|
||||||
|
@ -211,7 +211,7 @@ void Profile::saveToxSave(QByteArray data)
|
||||||
ProfileLocker::assertLock();
|
ProfileLocker::assertLock();
|
||||||
assert(ProfileLocker::getCurLockName() == name);
|
assert(ProfileLocker::getCurLockName() == name);
|
||||||
|
|
||||||
QString path = Settings::getSettingsDirPath() + QDir::separator() + name + ".tox";
|
QString path = Settings::getInstance().getSettingsDirPath() + name + ".tox";
|
||||||
qDebug() << "Saving tox save to "<<path;
|
qDebug() << "Saving tox save to "<<path;
|
||||||
QSaveFile saveFile(path);
|
QSaveFile saveFile(path);
|
||||||
if (!saveFile.open(QIODevice::WriteOnly))
|
if (!saveFile.open(QIODevice::WriteOnly))
|
||||||
|
@ -239,7 +239,7 @@ void Profile::saveToxSave(QByteArray data)
|
||||||
|
|
||||||
bool Profile::exists(QString name)
|
bool Profile::exists(QString name)
|
||||||
{
|
{
|
||||||
QString path = Settings::getSettingsDirPath() + QDir::separator() + name;
|
QString path = Settings::getInstance().getSettingsDirPath() + name;
|
||||||
return QFile::exists(path+".tox") && QFile::exists(path+".ini");
|
return QFile::exists(path+".tox") && QFile::exists(path+".ini");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,7 +251,7 @@ bool Profile::isEncrypted()
|
||||||
bool Profile::isEncrypted(QString name)
|
bool Profile::isEncrypted(QString name)
|
||||||
{
|
{
|
||||||
uint8_t data[encryptHeaderSize] = {0};
|
uint8_t data[encryptHeaderSize] = {0};
|
||||||
QString path = Settings::getSettingsDirPath() + QDir::separator() + name + ".tox";
|
QString path = Settings::getInstance().getSettingsDirPath() + name + ".tox";
|
||||||
QFile saveFile(path);
|
QFile saveFile(path);
|
||||||
if (!saveFile.open(QIODevice::ReadOnly))
|
if (!saveFile.open(QIODevice::ReadOnly))
|
||||||
{
|
{
|
||||||
|
@ -283,7 +283,7 @@ void Profile::remove()
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QString path = Settings::getSettingsDirPath() + QDir::separator() + name;
|
QString path = Settings::getInstance().getSettingsDirPath() + name;
|
||||||
QFile::remove(path+".tox");
|
QFile::remove(path+".tox");
|
||||||
QFile::remove(path+".ini");
|
QFile::remove(path+".ini");
|
||||||
|
|
||||||
|
@ -293,8 +293,8 @@ void Profile::remove()
|
||||||
|
|
||||||
bool Profile::rename(QString newName)
|
bool Profile::rename(QString newName)
|
||||||
{
|
{
|
||||||
QString path = Settings::getSettingsDirPath() + QDir::separator() + name,
|
QString path = Settings::getInstance().getSettingsDirPath() + name,
|
||||||
newPath = Settings::getSettingsDirPath() + QDir::separator() + newName;
|
newPath = Settings::getInstance().getSettingsDirPath() + newName;
|
||||||
|
|
||||||
if (!ProfileLocker::lock(newName))
|
if (!ProfileLocker::lock(newName))
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -876,11 +876,11 @@ void ChatForm::doScreenshot()
|
||||||
connect(screenshotGrabber, &ScreenshotGrabber::screenshotTaken, this, &ChatForm::onScreenshotTaken);
|
connect(screenshotGrabber, &ScreenshotGrabber::screenshotTaken, this, &ChatForm::onScreenshotTaken);
|
||||||
screenshotGrabber->showGrabber();
|
screenshotGrabber->showGrabber();
|
||||||
// Create dir for screenshots
|
// Create dir for screenshots
|
||||||
QDir(Settings::getSettingsDirPath()).mkdir("screenshots");
|
QDir(Settings::getInstance().getSettingsDirPath()).mkdir("screenshots");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatForm::onScreenshotTaken(const QPixmap &pixmap) {
|
void ChatForm::onScreenshotTaken(const QPixmap &pixmap) {
|
||||||
QTemporaryFile file(QDir(Settings::getSettingsDirPath() + QDir::separator() + "screenshots" + QDir::separator()).filePath("qTox-Screenshot-XXXXXXXX.png"));
|
QTemporaryFile file(Settings::getInstance().getSettingsDirPath()+"screenshots"+QDir::separator()+"qTox-Screenshot-XXXXXXXX.png");
|
||||||
if (!file.open())
|
if (!file.open())
|
||||||
{
|
{
|
||||||
QMessageBox::warning(this, tr("Failed to open temporary file", "Temporary file for screenshot"),
|
QMessageBox::warning(this, tr("Failed to open temporary file", "Temporary file for screenshot"),
|
||||||
|
|
|
@ -264,7 +264,7 @@ void ProfileForm::onExportClicked()
|
||||||
GUI::showWarning(tr("Location not writable","Title of permissions popup"), tr("You do not have permission to write that location. Choose another, or cancel the save dialog.", "text of permissions popup"));
|
GUI::showWarning(tr("Location not writable","Title of permissions popup"), tr("You do not have permission to write that location. Choose another, or cancel the save dialog.", "text of permissions popup"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!QFile::copy(QDir(Settings::getSettingsDirPath()).filePath(current), path))
|
if (!QFile::copy(Settings::getInstance().getSettingsDirPath()+current, path))
|
||||||
GUI::showWarning(tr("Failed to copy file"), tr("The file you chose could not be written to."));
|
GUI::showWarning(tr("Failed to copy file"), tr("The file you chose could not be written to."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
#include "src/core/core.h"
|
#include "src/core/core.h"
|
||||||
#include "src/misc/settings.h"
|
#include "src/misc/settings.h"
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDir>
|
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
|
||||||
bool toxSaveEventHandler(const QByteArray& eventData)
|
bool toxSaveEventHandler(const QByteArray& eventData)
|
||||||
|
@ -55,7 +54,7 @@ bool handleToxSave(const QString& path)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString profilePath = QDir(Settings::getSettingsDirPath()).filePath(profile + Core::TOX_EXT);
|
QString profilePath = Settings::getInstance().getSettingsDirPath()+profile+Core::TOX_EXT;
|
||||||
|
|
||||||
if (QFileInfo(profilePath).exists() && !GUI::askQuestion(QObject::tr("Profile already exists", "import confirm title"),
|
if (QFileInfo(profilePath).exists() && !GUI::askQuestion(QObject::tr("Profile already exists", "import confirm title"),
|
||||||
QObject::tr("A profile named \"%1\" already exists. Do you want to erase it?", "import confirm text").arg(profile)))
|
QObject::tr("A profile named \"%1\" already exists. Do you want to erase it?", "import confirm text").arg(profile)))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user