1 /*
2     Copyright © 2013 by Maxim Biro <nurupo.contributions@gmail.com>
3     Copyright © 2014-2019 by The qTox Project Contributors
4 
5     This file is part of qTox, a Qt-based graphical interface for Tox.
6 
7     qTox is libre software: you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by
9     the Free Software Foundation, either version 3 of the License, or
10     (at your option) any later version.
11 
12     qTox is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16 
17     You should have received a copy of the GNU General Public License
18     along with qTox.  If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef SETTINGS_HPP
22 #define SETTINGS_HPP
23 
24 #include "src/audio/iaudiosettings.h"
25 #include "src/core/icoresettings.h"
26 #include "src/core/toxencrypt.h"
27 #include "src/core/toxfile.h"
28 #include "src/persistence/ifriendsettings.h"
29 #include "src/persistence/igroupsettings.h"
30 #include "src/video/ivideosettings.h"
31 
32 #include "src/util/compatiblerecursivemutex.h"
33 
34 #include <QDateTime>
35 #include <QFlags>
36 #include <QFont>
37 #include <QHash>
38 #include <QMutex>
39 #include <QNetworkProxy>
40 #include <QObject>
41 #include <QPixmap>
42 
43 class Profile;
44 class QCommandLineParser;
45 
46 namespace Db {
47 enum class syncType;
48 }
49 
50 class Settings : public QObject,
51                  public ICoreSettings,
52                  public IFriendSettings,
53                  public IGroupSettings,
54                  public IAudioSettings,
55                  public IVideoSettings
56 {
57     Q_OBJECT
58 
59     Q_ENUMS(StyleType)
60 
61     // general
62     Q_PROPERTY(bool compactLayout READ getCompactLayout WRITE setCompactLayout NOTIFY compactLayoutChanged FINAL)
63     Q_PROPERTY(bool autorun READ getAutorun WRITE setAutorun NOTIFY autorunChanged FINAL)
64 
65     // GUI
66     Q_PROPERTY(bool separateWindow READ getSeparateWindow WRITE setSeparateWindow NOTIFY
67                    separateWindowChanged FINAL)
68     Q_PROPERTY(QString smileyPack READ getSmileyPack WRITE setSmileyPack NOTIFY smileyPackChanged FINAL)
69     Q_PROPERTY(int emojiFontPointSize READ getEmojiFontPointSize WRITE setEmojiFontPointSize NOTIFY
70                    emojiFontPointSizeChanged FINAL)
71     Q_PROPERTY(bool minimizeOnClose READ getMinimizeOnClose WRITE setMinimizeOnClose NOTIFY
72                    minimizeOnCloseChanged FINAL)
73     Q_PROPERTY(QByteArray windowGeometry READ getWindowGeometry WRITE setWindowGeometry NOTIFY
74                    windowGeometryChanged FINAL)
75     Q_PROPERTY(QByteArray windowState READ getWindowState WRITE setWindowState NOTIFY windowStateChanged FINAL)
76     Q_PROPERTY(QByteArray splitterState READ getSplitterState WRITE setSplitterState NOTIFY
77                    splitterStateChanged FINAL)
78     Q_PROPERTY(QByteArray dialogGeometry READ getDialogGeometry WRITE setDialogGeometry NOTIFY
79                    dialogGeometryChanged FINAL)
80     Q_PROPERTY(QByteArray dialogSplitterState READ getDialogSplitterState WRITE
81                    setDialogSplitterState NOTIFY dialogSplitterStateChanged FINAL)
82     Q_PROPERTY(QByteArray dialogSettingsGeometry READ getDialogSettingsGeometry WRITE
83                    setDialogSettingsGeometry NOTIFY dialogSettingsGeometryChanged FINAL)
84     Q_PROPERTY(QString style READ getStyle WRITE setStyle NOTIFY styleChanged FINAL)
85     Q_PROPERTY(bool showSystemTray READ getShowSystemTray WRITE setShowSystemTray NOTIFY
86                    showSystemTrayChanged FINAL)
87     Q_PROPERTY(bool showIdenticons READ getShowIdenticons WRITE setShowIdenticons NOTIFY
88                    showIdenticonsChanged FINAL)
89 
90     // ChatView
91     Q_PROPERTY(bool groupchatPosition READ getGroupchatPosition WRITE setGroupchatPosition NOTIFY
92                    groupchatPositionChanged FINAL)
93     Q_PROPERTY(QFont chatMessageFont READ getChatMessageFont WRITE setChatMessageFont NOTIFY
94                    chatMessageFontChanged FINAL)
95     Q_PROPERTY(StyleType stylePreference READ getStylePreference WRITE setStylePreference NOTIFY
96                    stylePreferenceChanged FINAL)
97     Q_PROPERTY(QString timestampFormat READ getTimestampFormat WRITE setTimestampFormat NOTIFY
98                    timestampFormatChanged FINAL)
99     Q_PROPERTY(QString dateFormat READ getDateFormat WRITE setDateFormat NOTIFY dateFormatChanged FINAL)
100     Q_PROPERTY(bool statusChangeNotificationEnabled READ getStatusChangeNotificationEnabled WRITE
101                    setStatusChangeNotificationEnabled NOTIFY statusChangeNotificationEnabledChanged FINAL)
102     Q_PROPERTY(bool spellCheckingEnabled READ getSpellCheckingEnabled WRITE setSpellCheckingEnabled
103                    NOTIFY spellCheckingEnabledChanged FINAL)
104 
105     // Privacy
106     Q_PROPERTY(bool typingNotification READ getTypingNotification WRITE setTypingNotification NOTIFY
107                    typingNotificationChanged FINAL)
108     Q_PROPERTY(QStringList blackList READ getBlackList WRITE setBlackList NOTIFY blackListChanged FINAL)
109 
110     // Audio
111     Q_PROPERTY(QString inDev READ getInDev WRITE setInDev NOTIFY inDevChanged FINAL)
112     Q_PROPERTY(bool audioInDevEnabled READ getAudioInDevEnabled WRITE setAudioInDevEnabled NOTIFY
113                    audioInDevEnabledChanged FINAL)
114     Q_PROPERTY(qreal audioInGainDecibel READ getAudioInGainDecibel WRITE setAudioInGainDecibel
115                    NOTIFY audioInGainDecibelChanged FINAL)
116     Q_PROPERTY(qreal audioThreshold READ getAudioThreshold WRITE setAudioThreshold NOTIFY
117                    audioThresholdChanged FINAL)
118     Q_PROPERTY(QString outDev READ getOutDev WRITE setOutDev NOTIFY outDevChanged FINAL)
119     Q_PROPERTY(bool audioOutDevEnabled READ getAudioOutDevEnabled WRITE setAudioOutDevEnabled NOTIFY
120                    audioOutDevEnabledChanged FINAL)
121     Q_PROPERTY(int outVolume READ getOutVolume WRITE setOutVolume NOTIFY outVolumeChanged FINAL)
122     Q_PROPERTY(int audioBitrate READ getAudioBitrate WRITE setAudioBitrate NOTIFY audioBitrateChanged FINAL)
123 
124     // Video
125     Q_PROPERTY(QString videoDev READ getVideoDev WRITE setVideoDev NOTIFY videoDevChanged FINAL)
126     Q_PROPERTY(QRect camVideoRes READ getCamVideoRes WRITE setCamVideoRes NOTIFY camVideoResChanged FINAL)
127     Q_PROPERTY(QRect screenRegion READ getScreenRegion WRITE setScreenRegion NOTIFY screenRegionChanged FINAL)
128     Q_PROPERTY(bool screenGrabbed READ getScreenGrabbed WRITE setScreenGrabbed NOTIFY screenGrabbedChanged FINAL)
129     Q_PROPERTY(float camVideoFPS READ getCamVideoFPS WRITE setCamVideoFPS NOTIFY camVideoFPSChanged FINAL)
130 
131 public:
132     enum class StyleType
133     {
134         NONE = 0,
135         WITH_CHARS = 1,
136         WITHOUT_CHARS = 2
137     };
138 
139     enum class FriendListSortingMode
140     {
141         Name,
142         Activity,
143     };
144 
145 public:
146     static Settings& getInstance();
147     static void destroyInstance();
148     QString getSettingsDirPath() const;
149     QString getAppDataDirPath() const;
150     QString getAppCacheDirPath() const;
151 
152     void createSettingsDir();
153     void createPersonal(QString basename);
154 
155     void savePersonal();
156 
157     void loadGlobal();
158     bool isToxPortable();
159     void loadPersonal(QString profileName, const ToxEncrypt* passKey);
160 
161     void resetToDefault();
162 
163     struct Request
164     {
165         QString address;
166         QString message;
167         bool read;
168     };
169 
170 public slots:
171     void saveGlobal();
172     void sync();
173     void setAutoLogin(bool state);
174     void updateProfileData(Profile* profile, const QCommandLineParser* parser);
175 
176 signals:
177     // General
178     void autorunChanged(bool enabled);
179     void autoSaveEnabledChanged(bool enabled);
180     void autostartInTrayChanged(bool enabled);
181     void closeToTrayChanged(bool enabled);
182     void lightTrayIconChanged(bool enabled);
183     void minimizeToTrayChanged(bool enabled);
184     void notifyChanged(bool enabled);
185     void desktopNotifyChanged(bool enabled);
186     void showWindowChanged(bool enabled);
187     void makeToxPortableChanged(bool enabled);
188     void busySoundChanged(bool enabled);
189     void notifySoundChanged(bool enabled);
190     void notifyHideChanged(bool enabled);
191     void groupAlwaysNotifyChanged(bool enabled);
192     void translationChanged(const QString& translation);
193     void currentProfileIdChanged(quint32 id);
194     void enableLoggingChanged(bool enabled);
195     void autoAwayTimeChanged(int minutes);
196     void globalAutoAcceptDirChanged(const QString& path);
197     void autoAcceptMaxSizeChanged(size_t size);
198     void checkUpdatesChanged(bool enabled);
199     void widgetDataChanged(const QString& key);
200 
201     // GUI
202     void autoLoginChanged(bool enabled);
203     void nameColorsChanged(bool enabled);
204     void separateWindowChanged(bool enabled);
205     void showSystemTrayChanged(bool enabled);
206     bool minimizeOnCloseChanged(bool enabled);
207     void windowGeometryChanged(const QByteArray& rect);
208     void windowStateChanged(const QByteArray& state);
209     void splitterStateChanged(const QByteArray& state);
210     void dialogGeometryChanged(const QByteArray& rect);
211     void dialogSplitterStateChanged(const QByteArray& state);
212     void dialogSettingsGeometryChanged(const QByteArray& rect);
213     void styleChanged(const QString& style);
214     void themeColorChanged(int color);
215     void compactLayoutChanged(bool enabled);
216     void sortingModeChanged(FriendListSortingMode mode);
217     void showIdenticonsChanged(bool enabled);
218 
219     // ChatView
220     void useEmoticonsChanged(bool enabled);
221     void smileyPackChanged(const QString& name);
222     void emojiFontPointSizeChanged(int size);
223     void dontGroupWindowsChanged(bool enabled);
224     void groupchatPositionChanged(bool enabled);
225     void chatMessageFontChanged(const QFont& font);
226     void stylePreferenceChanged(StyleType type);
227     void timestampFormatChanged(const QString& format);
228     void dateFormatChanged(const QString& format);
229     void statusChangeNotificationEnabledChanged(bool enabled);
230     void spellCheckingEnabledChanged(bool enabled);
231 
232     // Privacy
233     void typingNotificationChanged(bool enabled);
234     void dbSyncTypeChanged(Db::syncType type);
235     void blackListChanged(QStringList& blist);
236 
237 public:
238     bool applyCommandLineOptions(const QCommandLineParser& parser);
239     static bool verifyProxySettings(const QCommandLineParser& parser);
240 
241     bool getMakeToxPortable() const;
242     void setMakeToxPortable(bool newValue);
243 
244     bool getAutorun() const;
245     void setAutorun(bool newValue);
246 
247     bool getAutostartInTray() const;
248     void setAutostartInTray(bool newValue);
249 
250     bool getCloseToTray() const;
251     void setCloseToTray(bool newValue);
252 
253     bool getMinimizeToTray() const;
254     void setMinimizeToTray(bool newValue);
255 
256     bool getLightTrayIcon() const;
257     void setLightTrayIcon(bool newValue);
258 
259     QString getStyle() const;
260     void setStyle(const QString& newValue);
261 
262     bool getShowSystemTray() const;
263     void setShowSystemTray(bool newValue);
264 
265     bool getUseEmoticons() const;
266     void setUseEmoticons(bool newValue);
267 
268     QString getCurrentProfile() const;
269     uint32_t getCurrentProfileId() const;
270     void setCurrentProfile(const QString& profile);
271 
272     QString getTranslation() const;
273     void setTranslation(const QString& newValue);
274 
275     void setAutoSaveEnabled(bool newValue);
276     bool getAutoSaveEnabled() const;
277 
278     // ICoreSettings
279     bool getEnableIPv6() const override;
280     void setEnableIPv6(bool enabled) override;
281 
282     bool getForceTCP() const override;
283     void setForceTCP(bool enabled) override;
284 
285     bool getEnableLanDiscovery() const override;
286     void setEnableLanDiscovery(bool enabled) override;
287 
288     QString getProxyAddr() const override;
289     void setProxyAddr(const QString& address) override;
290 
291     ICoreSettings::ProxyType getProxyType() const override;
292     void setProxyType(ICoreSettings::ProxyType type) override;
293 
294     quint16 getProxyPort() const override;
295     void setProxyPort(quint16 port) override;
296 
297     QNetworkProxy getProxy() const override;
298 
299     SIGNAL_IMPL(Settings, enableIPv6Changed, bool enabled)
300     SIGNAL_IMPL(Settings, forceTCPChanged, bool enabled)
301     SIGNAL_IMPL(Settings, enableLanDiscoveryChanged, bool enabled)
302     SIGNAL_IMPL(Settings, proxyTypeChanged, ICoreSettings::ProxyType type)
303     SIGNAL_IMPL(Settings, proxyAddressChanged, const QString& address)
304     SIGNAL_IMPL(Settings, proxyPortChanged, quint16 port)
305 
306     bool getEnableLogging() const;
307     void setEnableLogging(bool newValue);
308 
309     Db::syncType getDbSyncType() const;
310     void setDbSyncType(Db::syncType newValue);
311 
312     int getAutoAwayTime() const;
313     void setAutoAwayTime(int newValue);
314 
315     bool getCheckUpdates() const;
316     void setCheckUpdates(bool newValue);
317 
318     bool getNotify() const;
319     void setNotify(bool newValue);
320 
321     bool getShowWindow() const;
322     void setShowWindow(bool newValue);
323 
324     bool getDesktopNotify() const;
325     void setDesktopNotify(bool enabled);
326 
327     bool getNotifySound() const;
328     void setNotifySound(bool newValue);
329 
330     bool getNotifyHide() const;
331     void setNotifyHide(bool newValue);
332 
333     bool getBusySound() const;
334     void setBusySound(bool newValue);
335 
336     bool getGroupAlwaysNotify() const override;
337     void setGroupAlwaysNotify(bool newValue) override;
338 
339     QString getInDev() const override;
340     void setInDev(const QString& deviceSpecifier) override;
341 
342     bool getAudioInDevEnabled() const override;
343     void setAudioInDevEnabled(bool enabled) override;
344 
345     QString getOutDev() const override;
346     void setOutDev(const QString& deviceSpecifier) override;
347 
348     bool getAudioOutDevEnabled() const override;
349     void setAudioOutDevEnabled(bool enabled) override;
350 
351     qreal getAudioInGainDecibel() const override;
352     void setAudioInGainDecibel(qreal dB) override;
353 
354     qreal getAudioThreshold() const override;
355     void setAudioThreshold(qreal percent) override;
356 
357     int getOutVolume() const override;
getOutVolumeMin()358     int getOutVolumeMin() const override
359     {
360         return 0;
361     }
getOutVolumeMax()362     int getOutVolumeMax() const override
363     {
364         return 100;
365     }
366     void setOutVolume(int volume) override;
367 
368     int getAudioBitrate() const override;
369     void setAudioBitrate(int bitrate) override;
370 
371     bool getEnableTestSound() const override;
372     void setEnableTestSound(bool newValue) override;
373 
374     SIGNAL_IMPL(Settings, inDevChanged, const QString& device)
375     SIGNAL_IMPL(Settings, audioInDevEnabledChanged, bool enabled)
376 
377     SIGNAL_IMPL(Settings, outDevChanged, const QString& device)
378     SIGNAL_IMPL(Settings, audioOutDevEnabledChanged, bool enabled)
379 
380     SIGNAL_IMPL(Settings, audioInGainDecibelChanged, qreal dB)
381     SIGNAL_IMPL(Settings, audioThresholdChanged, qreal percent)
382     SIGNAL_IMPL(Settings, outVolumeChanged, int volume)
383     SIGNAL_IMPL(Settings, audioBitrateChanged, int bitrate)
384     SIGNAL_IMPL(Settings, enableTestSoundChanged, bool newValue)
385 
386     QString getVideoDev() const override;
387     void setVideoDev(const QString& deviceSpecifier) override;
388 
389     QRect getScreenRegion() const override;
390     void setScreenRegion(const QRect& value) override;
391 
392     bool getScreenGrabbed() const override;
393     void setScreenGrabbed(bool value) override;
394 
395     QRect getCamVideoRes() const override;
396     void setCamVideoRes(QRect newValue) override;
397 
398     float getCamVideoFPS() const override;
399     void setCamVideoFPS(float newValue) override;
400 
401     SIGNAL_IMPL(Settings, videoDevChanged, const QString& device)
402     SIGNAL_IMPL(Settings, screenRegionChanged, const QRect& region)
403     SIGNAL_IMPL(Settings, screenGrabbedChanged, bool enabled)
404     SIGNAL_IMPL(Settings, camVideoResChanged, const QRect& region)
405     SIGNAL_IMPL(Settings, camVideoFPSChanged, unsigned short fps)
406 
407     bool isAnimationEnabled() const;
408     void setAnimationEnabled(bool newValue);
409 
410     QString getSmileyPack() const;
411     void setSmileyPack(const QString& value);
412 
413     int getThemeColor() const;
414     void setThemeColor(int value);
415 
416     StyleType getStylePreference() const;
417     void setStylePreference(StyleType newValue);
418 
419     bool isCurstomEmojiFont() const;
420     void setCurstomEmojiFont(bool value);
421 
422     int getEmojiFontPointSize() const;
423     void setEmojiFontPointSize(int value);
424 
425     QString getContactNote(const ToxPk& id) const override;
426     void setContactNote(const ToxPk& id, const QString& note) override;
427 
428     QString getAutoAcceptDir(const ToxPk& id) const override;
429     void setAutoAcceptDir(const ToxPk& id, const QString& dir) override;
430 
431     AutoAcceptCallFlags getAutoAcceptCall(const ToxPk& id) const override;
432     void setAutoAcceptCall(const ToxPk& id, AutoAcceptCallFlags accept) override;
433 
434     QString getGlobalAutoAcceptDir() const;
435     void setGlobalAutoAcceptDir(const QString& dir);
436 
437     size_t getMaxAutoAcceptSize() const;
438     void setMaxAutoAcceptSize(size_t size);
439 
440     bool getAutoGroupInvite(const ToxPk& id) const override;
441     void setAutoGroupInvite(const ToxPk& id, bool accept) override;
442 
443     // ChatView
444     const QFont& getChatMessageFont() const;
445     void setChatMessageFont(const QFont& font);
446 
447     const QString& getTimestampFormat() const;
448     void setTimestampFormat(const QString& format);
449 
450     const QString& getDateFormat() const;
451     void setDateFormat(const QString& format);
452 
453     bool getMinimizeOnClose() const;
454     void setMinimizeOnClose(bool newValue);
455 
456     bool getStatusChangeNotificationEnabled() const;
457     void setStatusChangeNotificationEnabled(bool newValue);
458 
459     bool getSpellCheckingEnabled() const;
460     void setSpellCheckingEnabled(bool newValue);
461 
462     // Privacy
463     bool getTypingNotification() const;
464     void setTypingNotification(bool enabled);
465     QStringList getBlackList() const override;
466     void setBlackList(const QStringList& blist) override;
467 
468     // State
469     QByteArray getWindowGeometry() const;
470     void setWindowGeometry(const QByteArray& value);
471 
472     QByteArray getWindowState() const;
473     void setWindowState(const QByteArray& value);
474 
475     QByteArray getSplitterState() const;
476     void setSplitterState(const QByteArray& value);
477 
478     QByteArray getDialogGeometry() const;
479     void setDialogGeometry(const QByteArray& value);
480 
481     QByteArray getDialogSplitterState() const;
482     void setDialogSplitterState(const QByteArray& value);
483 
484     QByteArray getDialogSettingsGeometry() const;
485     void setDialogSettingsGeometry(const QByteArray& value);
486 
487     QString getFriendAddress(const QString& publicKey) const;
488     void updateFriendAddress(const QString& newAddr);
489 
490     QString getFriendAlias(const ToxPk& id) const override;
491     void setFriendAlias(const ToxPk& id, const QString& alias) override;
492 
493     int getFriendCircleID(const ToxPk& id) const override;
494     void setFriendCircleID(const ToxPk& id, int circleID) override;
495 
496     QDateTime getFriendActivity(const ToxPk& id) const override;
497     void setFriendActivity(const ToxPk& id, const QDateTime& date) override;
498 
499     void saveFriendSettings(const ToxPk& id) override;
500     void removeFriendSettings(const ToxPk& id) override;
501 
502     SIGNAL_IMPL(Settings, autoAcceptCallChanged, const ToxPk& id,
503                 IFriendSettings::AutoAcceptCallFlags accept)
504     SIGNAL_IMPL(Settings, autoGroupInviteChanged, const ToxPk& id, bool accept)
505     SIGNAL_IMPL(Settings, autoAcceptDirChanged, const ToxPk& id, const QString& dir)
506     SIGNAL_IMPL(Settings, contactNoteChanged, const ToxPk& id, const QString& note)
507 
508     bool getCompactLayout() const;
509     void setCompactLayout(bool compact);
510 
511     FriendListSortingMode getFriendSortingMode() const;
512     void setFriendSortingMode(FriendListSortingMode mode);
513 
514     bool getSeparateWindow() const;
515     void setSeparateWindow(bool value);
516 
517     bool getDontGroupWindows() const;
518     void setDontGroupWindows(bool value);
519 
520     bool getGroupchatPosition() const;
521     void setGroupchatPosition(bool value);
522 
523     bool getShowIdenticons() const;
524     void setShowIdenticons(bool value);
525 
526     bool getAutoLogin() const;
527     void setEnableGroupChatsColor(bool state);
528     bool getEnableGroupChatsColor() const;
529 
530     int getCircleCount() const;
531     int addCircle(const QString& name = QString());
532     int removeCircle(int id);
533     QString getCircleName(int id) const;
534     void setCircleName(int id, const QString& name);
535     bool getCircleExpanded(int id) const;
536     void setCircleExpanded(int id, bool expanded);
537 
538     bool addFriendRequest(const QString& friendAddress, const QString& message);
539     unsigned int getUnreadFriendRequests() const;
540     Request getFriendRequest(int index) const;
541     int getFriendRequestSize() const;
542     void clearUnreadFriendRequests();
543     void removeFriendRequest(int index);
544     void readFriendRequest(int index);
545 
546     QByteArray getWidgetData(const QString& uniqueName) const;
547     void setWidgetData(const QString& uniqueName, const QByteArray& data);
548 
549     // Wrappers around getWidgetData() and setWidgetData()
550     // Assume widget has a unique objectName set
551     template <class T>
restoreGeometryState(T * widget)552     void restoreGeometryState(T* widget) const
553     {
554         widget->restoreGeometry(getWidgetData(widget->objectName() + "Geometry"));
555         widget->restoreState(getWidgetData(widget->objectName() + "State"));
556     }
557     template <class T>
saveGeometryState(const T * widget)558     void saveGeometryState(const T* widget)
559     {
560         setWidgetData(widget->objectName() + "Geometry", widget->saveGeometry());
561         setWidgetData(widget->objectName() + "State", widget->saveState());
562     }
563 
564     static uint32_t makeProfileId(const QString& profile);
565 
566 private:
567     struct friendProp;
568 
569     Settings();
570     ~Settings();
571     Settings(Settings& settings) = delete;
572     Settings& operator=(const Settings&) = delete;
573     void savePersonal(QString profileName, const ToxEncrypt* passkey);
574     friendProp& getOrInsertFriendPropRef(const ToxPk& id);
575     ICoreSettings::ProxyType fixInvalidProxyType(ICoreSettings::ProxyType proxyType);
576 
577 public slots:
578     void savePersonal(Profile* profile);
579 
580 private:
581     bool loaded;
582 
583     bool useCustomDhtList;
584     int dhtServerId;
585     bool dontShowDhtDialog;
586 
587     bool autoLogin;
588     bool compactLayout;
589     FriendListSortingMode sortingMode;
590     bool groupchatPosition;
591     bool separateWindow;
592     bool dontGroupWindows;
593     bool showIdenticons;
594     bool enableIPv6;
595     QString translation;
596     bool makeToxPortable;
597     bool autostartInTray;
598     bool closeToTray;
599     bool minimizeToTray;
600     bool lightTrayIcon;
601     bool useEmoticons;
602     bool checkUpdates;
603     bool notify;
604     bool desktopNotify;
605     bool showWindow;
606     bool notifySound;
607     bool notifyHide;
608     bool busySound;
609     bool groupAlwaysNotify;
610     bool nameColors;
611 
612     bool forceTCP;
613     bool enableLanDiscovery;
614 
615     ICoreSettings::ProxyType proxyType;
616     QString proxyAddr;
617     quint16 proxyPort;
618 
619     QString currentProfile;
620     uint32_t currentProfileId;
621 
622     bool enableLogging;
623 
624     int autoAwayTime;
625 
626     QHash<QString, QByteArray> widgetSettings;
627     QHash<QString, QString> autoAccept;
628     bool autoSaveEnabled;
629     QString globalAutoAcceptDir;
630     size_t autoAcceptMaxSize;
631 
632     QList<Request> friendRequests;
633 
634     // GUI
635     QString smileyPack;
636     int emojiFontPointSize;
637     bool minimizeOnClose;
638     QByteArray windowGeometry;
639     QByteArray windowState;
640     QByteArray splitterState;
641     QByteArray dialogGeometry;
642     QByteArray dialogSplitterState;
643     QByteArray dialogSettingsGeometry;
644     QString style;
645     bool showSystemTray;
646 
647     // ChatView
648     QFont chatMessageFont;
649     StyleType stylePreference;
650     int firstColumnHandlePos;
651     int secondColumnHandlePosFromRight;
652     QString timestampFormat;
653     QString dateFormat;
654     bool statusChangeNotificationEnabled;
655     bool spellCheckingEnabled;
656 
657     // Privacy
658     bool typingNotification;
659     Db::syncType dbSyncType;
660     QStringList blackList;
661 
662     // Audio
663     QString inDev;
664     bool audioInDevEnabled;
665     qreal audioInGainDecibel;
666     qreal audioThreshold;
667     QString outDev;
668     bool audioOutDevEnabled;
669     int outVolume;
670     int audioBitrate;
671     bool enableTestSound;
672 
673     // Video
674     QString videoDev;
675     QRect camVideoRes;
676     QRect screenRegion;
677     bool screenGrabbed;
678     float camVideoFPS;
679 
680     struct friendProp
681     {
682         friendProp() = delete;
friendPropfriendProp683         friendProp(QString addr)
684             : addr(addr)
685         {}
686         QString alias = "";
687         QString addr = "";
688         QString autoAcceptDir = "";
689         QString note = "";
690         int circleID = -1;
691         QDateTime activity = QDateTime();
692         AutoAcceptCallFlags autoAcceptCall;
693         bool autoGroupInvite = false;
694     };
695 
696     struct circleProp
697     {
698         QString name;
699         bool expanded;
700     };
701 
702     QHash<QByteArray, friendProp> friendLst;
703 
704     QVector<circleProp> circleLst;
705 
706     int themeColor;
707 
708     static CompatibleRecursiveMutex bigLock;
709     static Settings* settings;
710     static const QString globalSettingsFile;
711     static QThread* settingsThread;
712 };
713 
714 #endif // SETTINGS_HPP
715