c22eef8cf48b4119e5fd6e3d3e7c49e1456d8b60
[quassel.git] / src / client / clientsettings.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2018 by the Quassel Project                        *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) version 3.                                           *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
19  ***************************************************************************/
20
21 #pragma once
22
23 #include "client-export.h"
24
25 #include "settings.h"
26
27 #include "types.h"
28
29 class QHostAddress;
30 class QSslSocket;
31
32 class CLIENT_EXPORT ClientSettings : public Settings
33 {
34
35 protected:
36     ClientSettings(QString group = "General");
37 };
38
39
40 // ========================================
41 //  CoreAccountSettings
42 // ========================================
43
44 // Deriving from CoreAccountSettings:
45 // MySettings() : CoreAccountSettings("MyGroup") {};
46 // Then use accountValue() / setAccountValue() to retrieve/store data associated to the currently
47 // connected account. This is stored in CoreAccounts/$ACCID/MyGroup/$KEY) then.
48 //
49 // Note that you'll get invalid data (and setting is ignored) if you are not connected to a core!
50
51 class CLIENT_EXPORT CoreAccountSettings : public ClientSettings
52 {
53 public:
54     // stores account-specific data in CoreAccounts/$ACCID/$SUBGROUP/$KEY)
55     CoreAccountSettings(QString subgroup = "General");
56
57     void notify(const QString &key, QObject *receiver, const char *slot) override;
58
59     QList<AccountId> knownAccounts();
60     AccountId lastAccount();
61     void setLastAccount(AccountId);
62     AccountId autoConnectAccount();
63     void setAutoConnectAccount(AccountId);
64     bool autoConnectOnStartup();
65     void setAutoConnectOnStartup(bool);
66     bool autoConnectToFixedAccount();
67     void setAutoConnectToFixedAccount(bool);
68
69     void clearAccounts();
70
71     void storeAccountData(AccountId id, const QVariantMap &data);
72     QVariantMap retrieveAccountData(AccountId);
73     void removeAccount(AccountId);
74
75     void setJumpKeyMap(const QHash<int, BufferId> &keyMap);
76     QHash<int, BufferId> jumpKeyMap();
77
78     void setBufferViewOverlay(const QSet<int> &viewIds);
79     QSet<int> bufferViewOverlay();
80
81     void setAccountValue(const QString &key, const QVariant &data);
82     QVariant accountValue(const QString &key, const QVariant &def = QVariant());
83
84 private:
85     QString _subgroup;
86 };
87
88
89 // ========================================
90 //  NotificationSettings
91 // ========================================
92 class CLIENT_EXPORT NotificationSettings : public ClientSettings
93 {
94 public:
95     enum HighlightNickType {
96         NoNick = 0x00,
97         CurrentNick = 0x01,
98         AllNicks = 0x02
99     };
100
101     NotificationSettings();
102
103     inline void setValue(const QString &key, const QVariant &data) { setLocalValue(key, data); }
104     inline QVariant value(const QString &key, const QVariant &def = QVariant()) { return localValue(key, def); }
105     inline void remove(const QString &key) { removeLocalKey(key); }
106
107     void setHighlightList(const QVariantList &highlightList);
108     QVariantList highlightList();
109
110     void setHighlightNick(HighlightNickType);
111     HighlightNickType highlightNick();
112
113     void setNicksCaseSensitive(bool);
114     bool nicksCaseSensitive();
115 };
116
117
118 // ========================================
119 // CoreConnectionSettings
120 // ========================================
121
122 class CLIENT_EXPORT CoreConnectionSettings : public ClientSettings
123 {
124 public:
125     enum NetworkDetectionMode {
126         UseQNetworkConfigurationManager = 1, // UseSolid is gone
127         UsePingTimeout,
128         NoActiveDetection
129     };
130
131     CoreConnectionSettings();
132
133     void setNetworkDetectionMode(NetworkDetectionMode mode);
134     NetworkDetectionMode networkDetectionMode();
135
136     void setAutoReconnect(bool autoReconnect);
137     bool autoReconnect();
138
139     void setPingTimeoutInterval(int interval);
140     int pingTimeoutInterval();
141
142     void setReconnectInterval(int interval);
143     int reconnectInterval();
144 };
145
146
147 // ========================================
148 // TabCompletionSettings
149 // ========================================
150
151 class CLIENT_EXPORT TabCompletionSettings : public ClientSettings
152 {
153 public:
154     enum SortMode {
155         Alphabetical,
156         LastActivity
157     };
158
159     TabCompletionSettings();
160
161     void setCompletionSuffix(const QString &);
162     QString completionSuffix();
163
164     void setAddSpaceMidSentence(bool);
165     bool addSpaceMidSentence();
166
167     void setSortMode(SortMode);
168     SortMode sortMode();
169
170     void setCaseSensitivity(Qt::CaseSensitivity);
171     Qt::CaseSensitivity caseSensitivity();
172
173     void setUseLastSpokenTo(bool);
174     bool useLastSpokenTo();
175 };
176
177
178 // ========================================
179 // ItemViewSettings
180 // ========================================
181 class CLIENT_EXPORT ItemViewSettings : public ClientSettings
182 {
183 public:
184     ItemViewSettings(const QString &group = "ItemViews");
185
186     bool displayTopicInTooltip();
187     bool mouseWheelChangesBuffer();
188 };