summaryrefslogtreecommitdiffstats
path: root/ksirc/ksopts.h
blob: 5739f6fd67e070a874fbe4d3fb8fa2d0c3a4111c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218

#ifndef _KSOPTS_H_
#define _KSOPTS_H_
#include <qmap.h>
#include <qdict.h>
#include <qstring.h>
#include <qstringlist.h>
#include <qcolor.h>
#include <qfont.h>
#include <qrect.h>
#include <qpixmap.h>
#include <qdatetime.h>

#define IRC_SAFE_MAX_LINE 450

#include "boundscheckingarray.h"
#include "ksircchannel.h"
#include "ksircserver.h"

// Central place to hold KSirc's options
// and manage default values. The base classes
// are only used directly by the prefs dialog.
// The constructors initialize all options with default values.
class KSOGeneral
{
public:
    KSOGeneral();

    enum { SDI, MDI } displayMode;
    bool autoCreateWin : 1;
    bool autoCreateWinForNotice : 1;
    bool nickCompletion : 1;
    bool displayTopic : 1;
    bool oneLineEntry : 1;
    bool runDocked : 1;
//    bool timeStamp : 1;
//    bool beepNotify : 1;
    bool colorPicker : 1;
    bool autoRejoin : 1;
//    bool beepOnMsg : 1;
//    bool logging : 1;
    bool publicAway : 1;
    bool useColourNickList : 1;
    //    bool topicShow : 1;
    bool dockPopups : 1;
    bool autoSaveHistory : 1;
    int windowLength;
    QString backgroundFile;

    QPixmap backgroundPixmap();

private:
    QPixmap m_backgroundPixmap;
};

class KSOChannel
{
public:
    KSOChannel();

    QString server;
    QString channel;

    bool timeStamp : 1;
    bool beepNotify : 1;
    bool beepOnMsg : 1;
    bool logging : 1;
    bool topicShow : 1;
    bool filterJoinPart : 1;
    QString encoding;

    QDateTime lastUsed;

    static bool applyGlobally;



};

class KSOServer
{
public:
    KSOServer();

    QString server;
    bool globalCopy;

    QString nick;
    QString altNick;
    QString realName;
    QString userID;
    QStringList notifyList;

    QDateTime lastUsed;
};

class KSOStartup
{
public:
    KSOStartup();

    QRect geometry;
//    QString nick;
//    QString altNick;
//    QString realName;
//    QString userID;
//    QStringList notifyList;
};

class KSOColors
{
public:
    enum { numColors = 16 };

    KSOColors();

    QColor textColor;
    QColor linkColor;
    QColor infoColor;
    QColor channelColor;
    QColor errorColor;
    QColor ownNickColor;
    bool ownNickBold : 1;
    bool ownNickUl : 1;
    bool ownNickRev : 1;

    QColor msgContainNick; // needs config + impl
    QColor msg1Contain;    // needs config
    QString msg1String;    // needs config
    bool   msg1Regex;
    QColor msg2Contain;    // need config
    QString msg2String;    // needs config
    bool   msg2Regex;

    QColor nickForeground;
    QColor nickBackground;
    QColor backgroundColor;
    QColor selBackgroundColor;
    QColor selForegroundColor;
    //QColor ircColors[numColors];
    BoundsCheckingArray<QColor, numColors> ircColors;
    BoundsCheckingArray<bool, numColors> nickHighlight;

    QString colourTheme;

    QFont defaultFont;
    bool ksircColors : 1;
    bool mircColors : 1;
    bool nickColourization : 1;

};

class KSORMBMenu
{
public:
    KSORMBMenu();
};

class KSOServChan
{
public:
    KSOServChan();
};

typedef QMap<QString, KSOChannel> ChannelOpMap;
typedef QMap<QString, ChannelOpMap> ServerChannelOpMap;
typedef QMap<QString, KSOServer> ServerOpMap;

class KSOptions
    : public KSOGeneral,
    public KSOStartup,
    public KSOColors,
    public KSORMBMenu,
    public KSOServChan
{
public:
    KSOptions() { s_options = this; }

    void load( int sections = -1 );
    void save( int sections = -1 );

    static KSOptions *options() { return s_options; }

    ServerChannelOpMap channel;
    ServerOpMap server;

    KSOChannel &chan( const KSircChannel &chanInfo )
    {
        return channel[chanInfo.server()][chanInfo.channel()];
    }

    KSOServer &serv( const KSircServer &servInfo )
    {
        return server[servInfo.server()];
    }

    void channelSetup(QString serv, QString chan);
    void applyChannelGlobal(void);

    void serverSetup(QString server);
    void serverSetup( const KSircServer &servInfo )
    {
        serverSetup(servInfo.server());
    }

    enum {
        All = -1, General = 1, Startup = 2,
        Colors = 4, RMBMenu = 8, ServChan = 16,
        Channels = 32, Servers = 64
    };

private:
    static KSOptions *s_options;
};

#define ksopts (KSOptions::options())

#endif