modernize: Require member function pointers for Settings::notify()
[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     QList<AccountId> knownAccounts() const;
58     AccountId lastAccount() const;
59     void setLastAccount(AccountId);
60     AccountId autoConnectAccount() const;
61     void setAutoConnectAccount(AccountId);
62     bool autoConnectOnStartup() const;
63     void setAutoConnectOnStartup(bool);
64     bool autoConnectToFixedAccount() const;
65     void setAutoConnectToFixedAccount(bool);
66
67     void clearAccounts();
68
69     void storeAccountData(AccountId id, const QVariantMap &data);
70     QVariantMap retrieveAccountData(AccountId) const;
71     void removeAccount(AccountId);
72
73     void setJumpKeyMap(const QHash<int, BufferId> &keyMap);
74     QHash<int, BufferId> jumpKeyMap() const;
75
76     void setBufferViewOverlay(const QSet<int> &viewIds);
77     QSet<int> bufferViewOverlay() const;
78
79     void setAccountValue(const QString &key, const QVariant &data);
80     QVariant accountValue(const QString &key, const QVariant &def = QVariant()) const;
81
82 protected:
83     QString keyForNotify(const QString &key) const override;
84
85 private:
86     QString _subgroup;
87 };
88
89
90 // ========================================
91 //  NotificationSettings
92 // ========================================
93 class CLIENT_EXPORT NotificationSettings : public ClientSettings
94 {
95 public:
96     enum HighlightNickType {
97         NoNick = 0x00,
98         CurrentNick = 0x01,
99         AllNicks = 0x02
100     };
101
102     NotificationSettings();
103
104     void setValue(const QString &key, const QVariant &data);
105     QVariant value(const QString &key, const QVariant &def = {}) const;
106     void remove(const QString &key);
107
108     void setHighlightList(const QVariantList &highlightList);
109     QVariantList highlightList() const;
110
111     void setHighlightNick(HighlightNickType);
112     HighlightNickType highlightNick() const;
113
114     void setNicksCaseSensitive(bool);
115     bool nicksCaseSensitive() const;
116 };
117
118
119 // ========================================
120 // CoreConnectionSettings
121 // ========================================
122
123 class CLIENT_EXPORT CoreConnectionSettings : public ClientSettings
124 {
125 public:
126     enum NetworkDetectionMode {
127         UseQNetworkConfigurationManager = 1, // UseSolid is gone
128         UsePingTimeout,
129         NoActiveDetection
130     };
131
132     CoreConnectionSettings();
133
134     void setNetworkDetectionMode(NetworkDetectionMode mode);
135     NetworkDetectionMode networkDetectionMode() const;
136
137     void setAutoReconnect(bool autoReconnect);
138     bool autoReconnect() const;
139
140     void setPingTimeoutInterval(int interval);
141     int pingTimeoutInterval() const;
142
143     void setReconnectInterval(int interval);
144     int reconnectInterval() const;
145 };
146
147
148 // ========================================
149 // TabCompletionSettings
150 // ========================================
151
152 class CLIENT_EXPORT TabCompletionSettings : public ClientSettings
153 {
154 public:
155     enum SortMode {
156         Alphabetical,
157         LastActivity
158     };
159
160     TabCompletionSettings();
161
162     void setCompletionSuffix(const QString &);
163     QString completionSuffix() const;
164
165     void setAddSpaceMidSentence(bool);
166     bool addSpaceMidSentence() const;
167
168     void setSortMode(SortMode);
169     SortMode sortMode() const;
170
171     void setCaseSensitivity(Qt::CaseSensitivity);
172     Qt::CaseSensitivity caseSensitivity() const;
173
174     void setUseLastSpokenTo(bool);
175     bool useLastSpokenTo() const;
176 };
177
178
179 // ========================================
180 // ItemViewSettings
181 // ========================================
182 class CLIENT_EXPORT ItemViewSettings : public ClientSettings
183 {
184 public:
185     ItemViewSettings(const QString &group = "ItemViews");
186
187     bool displayTopicInTooltip() const;
188     bool mouseWheelChangesBuffer() const;
189 };