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