2014-06-25 04:11:11 +08:00
|
|
|
/*
|
|
|
|
Copyright (C) 2013 by Maxim Biro <nurupo.contributions@gmail.com>
|
|
|
|
|
|
|
|
This file is part of Tox Qt GUI.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
See the COPYING file for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SETTINGS_HPP
|
|
|
|
#define SETTINGS_HPP
|
|
|
|
|
|
|
|
#include <QHash>
|
2014-09-11 21:44:34 +08:00
|
|
|
#include <QObject>
|
2014-09-24 22:51:16 +08:00
|
|
|
#include <QPixmap>
|
2014-06-25 04:11:11 +08:00
|
|
|
|
|
|
|
class Settings : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
static Settings& getInstance();
|
|
|
|
~Settings();
|
|
|
|
|
|
|
|
void executeSettingsDialog(QWidget* parent);
|
|
|
|
|
|
|
|
static QString getSettingsDirPath();
|
|
|
|
|
|
|
|
struct DhtServer
|
|
|
|
{
|
|
|
|
QString name;
|
|
|
|
QString userId;
|
|
|
|
QString address;
|
2014-06-26 19:09:08 +08:00
|
|
|
quint16 port;
|
2014-06-25 04:11:11 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const QList<DhtServer>& getDhtServerList() const;
|
|
|
|
void setDhtServerList(const QList<DhtServer>& newDhtServerList);
|
|
|
|
|
2014-07-02 06:47:06 +08:00
|
|
|
bool getEnableIPv6() const;
|
|
|
|
void setEnableIPv6(bool newValue);
|
|
|
|
|
2014-07-13 04:58:58 +08:00
|
|
|
bool getMakeToxPortable() const;
|
|
|
|
void setMakeToxPortable(bool newValue);
|
|
|
|
|
2014-07-05 01:22:43 +08:00
|
|
|
bool getUseTranslations() const;
|
|
|
|
void setUseTranslations(bool newValue);
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
bool getEnableLogging() const;
|
|
|
|
void setEnableLogging(bool newValue);
|
|
|
|
|
|
|
|
bool getEncryptLogs() const;
|
|
|
|
void setEncryptLogs(bool newValue);
|
|
|
|
|
2014-09-24 23:55:54 +08:00
|
|
|
QPixmap getSavedAvatar(const QString& ownerId);
|
|
|
|
void saveAvatar(QPixmap& pic, const QString& ownerId);
|
2014-09-24 22:51:16 +08:00
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
// 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;
|
|
|
|
void setAnimationEnabled(bool newValue);
|
|
|
|
|
2014-07-25 20:52:14 +08:00
|
|
|
QString getSmileyPack() const;
|
|
|
|
void setSmileyPack(const QString &value);
|
2014-06-25 04:11:11 +08:00
|
|
|
|
|
|
|
bool isCurstomEmojiFont() const;
|
|
|
|
void setCurstomEmojiFont(bool value);
|
|
|
|
|
|
|
|
QString getEmojiFontFamily() const;
|
|
|
|
void setEmojiFontFamily(const QString &value);
|
|
|
|
|
|
|
|
int getEmojiFontPointSize() const;
|
|
|
|
void setEmojiFontPointSize(int value);
|
|
|
|
|
|
|
|
// ChatView
|
|
|
|
int getFirstColumnHandlePos() const;
|
|
|
|
void setFirstColumnHandlePos(const int pos);
|
|
|
|
|
|
|
|
int getSecondColumnHandlePosFromRight() const;
|
|
|
|
void setSecondColumnHandlePosFromRight(const int pos);
|
|
|
|
|
|
|
|
const QString &getTimestampFormat() const;
|
|
|
|
void setTimestampFormat(const QString &format);
|
|
|
|
|
|
|
|
bool isMinimizeOnCloseEnabled() const;
|
|
|
|
void setMinimizeOnClose(bool newValue);
|
|
|
|
|
|
|
|
// Privacy
|
|
|
|
bool isTypingNotificationEnabled() const;
|
|
|
|
void setTypingNotification(bool enabled);
|
|
|
|
|
2014-08-11 00:14:50 +08:00
|
|
|
bool getUseNativeStyle() const;
|
|
|
|
void setUseNativeStyle(bool value);
|
|
|
|
|
|
|
|
bool getUseNativeDecoration() const;
|
|
|
|
void setUseNativeDecoration(bool value);
|
|
|
|
|
2014-08-11 16:00:08 +08:00
|
|
|
QByteArray getWindowGeometry() const;
|
|
|
|
void setWindowGeometry(const QByteArray &value);
|
|
|
|
|
|
|
|
QByteArray getWindowState() const;
|
|
|
|
void setWindowState(const QByteArray &value);
|
|
|
|
|
2014-08-11 20:07:27 +08:00
|
|
|
QByteArray getSplitterState() const;
|
|
|
|
void setSplitterState(const QByteArray &value);
|
|
|
|
|
2014-09-01 04:26:45 +08:00
|
|
|
public:
|
|
|
|
QList<QString> friendAddresses;
|
2014-06-25 04:11:11 +08:00
|
|
|
void save();
|
2014-07-13 04:58:58 +08:00
|
|
|
void save(QString path);
|
2014-06-25 04:11:11 +08:00
|
|
|
void load();
|
|
|
|
|
2014-09-01 04:26:45 +08:00
|
|
|
private:
|
|
|
|
Settings();
|
|
|
|
Settings(Settings &settings) = delete;
|
|
|
|
Settings& operator=(const Settings&) = delete;
|
2014-06-25 04:11:11 +08:00
|
|
|
|
|
|
|
static const QString FILENAME;
|
2014-09-24 22:51:16 +08:00
|
|
|
static const QString AVATAR_FILENAME;
|
2014-06-25 04:11:11 +08:00
|
|
|
|
|
|
|
bool loaded;
|
|
|
|
|
2014-09-05 05:13:59 +08:00
|
|
|
bool useCustomDhtList;
|
2014-06-25 04:11:11 +08:00
|
|
|
QList<DhtServer> dhtServerList;
|
|
|
|
int dhtServerId;
|
|
|
|
bool dontShowDhtDialog;
|
|
|
|
|
2014-07-02 06:47:06 +08:00
|
|
|
bool enableIPv6;
|
2014-07-05 01:22:43 +08:00
|
|
|
bool useTranslations;
|
2014-07-13 04:58:58 +08:00
|
|
|
static bool makeToxPortable;
|
2014-07-02 06:47:06 +08:00
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
bool enableLogging;
|
|
|
|
bool encryptLogs;
|
|
|
|
|
|
|
|
QHash<QString, QByteArray> widgetSettings;
|
|
|
|
|
|
|
|
// GUI
|
|
|
|
bool enableSmoothAnimation;
|
2014-07-25 20:52:14 +08:00
|
|
|
QString smileyPack;
|
2014-06-25 04:11:11 +08:00
|
|
|
bool customEmojiFont;
|
|
|
|
QString emojiFontFamily;
|
|
|
|
int emojiFontPointSize;
|
|
|
|
bool minimizeOnClose;
|
2014-08-11 00:14:50 +08:00
|
|
|
bool useNativeStyle;
|
|
|
|
bool useNativeDecoration;
|
2014-08-11 16:00:08 +08:00
|
|
|
QByteArray windowGeometry;
|
|
|
|
QByteArray windowState;
|
2014-08-11 20:07:27 +08:00
|
|
|
QByteArray splitterState;
|
2014-06-25 04:11:11 +08:00
|
|
|
|
|
|
|
// ChatView
|
|
|
|
int firstColumnHandlePos;
|
|
|
|
int secondColumnHandlePosFromRight;
|
|
|
|
QString timestampFormat;
|
|
|
|
|
|
|
|
// Privacy
|
|
|
|
bool typingNotification;
|
|
|
|
|
|
|
|
signals:
|
|
|
|
//void dataChanged();
|
|
|
|
void dhtServerListChanged();
|
|
|
|
void logStorageOptsChanged();
|
|
|
|
void smileyPackChanged();
|
|
|
|
void emojiFontChanged();
|
|
|
|
void timestampFormatChanged();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SETTINGS_HPP
|