modernize: Pass arguments by value and move in constructors
[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 public:
35     ~ClientSettings() override;
36
37 protected:
38     ClientSettings(QString group = "General");
39 };
40
41
42 // ========================================
43 //  CoreAccountSettings
44 // ========================================
45
46 // Deriving from CoreAccountSettings:
47 // MySettings() : CoreAccountSettings("MyGroup") {};
48 // Then use accountValue() / setAccountValue() to retrieve/store data associated to the currently
49 // connected account. This is stored in CoreAccounts/$ACCID/MyGroup/$KEY) then.
50 //
51 // Note that you'll get invalid data (and setting is ignored) if you are not connected to a core!
52
53 class CLIENT_EXPORT CoreAccountSettings : public ClientSettings
54 {
55 public:
56     // stores account-specific data in CoreAccounts/$ACCID/$SUBGROUP/$KEY)
57     CoreAccountSettings(QString subgroup = "General");
58
59     void notify(const QString &key, QObject *receiver, const char *slot) override;
60
61     QList<AccountId> knownAccounts();
62     AccountId lastAccount();
63     void setLastAccount(AccountId);
64     AccountId autoConnectAccount();
65     void setAutoConnectAccount(AccountId);
66     bool autoConnectOnStartup();
67     void setAutoConnectOnStartup(bool);
68     bool autoConnectToFixedAccount();
69     void setAutoConnectToFixedAccount(bool);
70
71     void clearAccounts();
72
73     void storeAccountData(AccountId id, const QVariantMap &data);
74     QVariantMap retrieveAccountData(AccountId);
75     void removeAccount(AccountId);
76
77     void setJumpKeyMap(const QHash<int, BufferId> &keyMap);
78     QHash<int, BufferId> jumpKeyMap();
79
80     void setBufferViewOverlay(const QSet<int> &viewIds);
81     QSet<int> bufferViewOverlay();
82
83     void setAccountValue(const QString &key, const QVariant &data);
84     QVariant accountValue(const QString &key, const QVariant &def = QVariant());
85
86 private:
87     QString _subgroup;
88 };
89
90
91 // ========================================
92 //  NotificationSettings
93 // ========================================
94 class CLIENT_EXPORT NotificationSettings : public ClientSettings
95 {
96 public:
97     enum HighlightNickType {
98         NoNick = 0x00,
99         CurrentNick = 0x01,
100         AllNicks = 0x02
101     };
102
103     NotificationSettings();
104
105     inline void setValue(const QString &key, const QVariant &data) { setLocalValue(key, data); }
106     inline QVariant value(const QString &key, const QVariant &def = QVariant()) { return localValue(key, def); }
107     inline void remove(const QString &key) { removeLocalKey(key); }
108
109     void setHighlightList(const QVariantList &highlightList);
110     QVariantList highlightList();
111
112     void setHighlightNick(HighlightNickType);
113     HighlightNickType highlightNick();
114
115     void setNicksCaseSensitive(bool);
116     bool nicksCaseSensitive();
117 };
118
119
120 // ========================================
121 // CoreConnectionSettings
122 // ========================================
123
124 class CLIENT_EXPORT CoreConnectionSettings : public ClientSettings
125 {
126 public:
127     enum NetworkDetectionMode {
128         UseQNetworkConfigurationManager = 1, // UseSolid is gone
129         UsePingTimeout,
130         NoActiveDetection
131     };
132
133     CoreConnectionSettings();
134
135     void setNetworkDetectionMode(NetworkDetectionMode mode);
136     NetworkDetectionMode networkDetectionMode();
137
138     void setAutoReconnect(bool autoReconnect);
139     bool autoReconnect();
140
141     void setPingTimeoutInterval(int interval);
142     int pingTimeoutInterval();
143
144     void setReconnectInterval(int interval);
145     int reconnectInterval();
146 };
147
148
149 // ========================================
150 // TabCompletionSettings
151 // ========================================
152
153 class CLIENT_EXPORT TabCompletionSettings : public ClientSettings
154 {
155 public:
156     enum SortMode {
157         Alphabetical,
158         LastActivity
159     };
160
161     TabCompletionSettings();
162
163     void setCompletionSuffix(const QString &);
164     QString completionSuffix();
165
166     void setAddSpaceMidSentence(bool);
167     bool addSpaceMidSentence();
168
169     void setSortMode(SortMode);
170     SortMode sortMode();
171
172     void setCaseSensitivity(Qt::CaseSensitivity);
173     Qt::CaseSensitivity caseSensitivity();
174
175     void setUseLastSpokenTo(bool);
176     bool useLastSpokenTo();
177 };
178
179
180 // ========================================
181 // ItemViewSettings
182 // ========================================
183 class CLIENT_EXPORT ItemViewSettings : public ClientSettings
184 {
185 public:
186     ItemViewSettings(const QString &group = "ItemViews");
187
188     bool displayTopicInTooltip();
189     bool mouseWheelChangesBuffer();
190 };