Fix crash on logout
[kdenetwork.git] / ksirc / ksopts.h
blobac7aaec3aabc260aac255f70e9e0a6d251a92cbd
2 #ifndef _KSOPTS_H_
3 #define _KSOPTS_H_
4 #include <qmap.h>
5 #include <q3dict.h>
6 #include <qstring.h>
7 #include <qstringlist.h>
8 #include <qcolor.h>
9 #include <qfont.h>
10 #include <qrect.h>
11 #include <qpixmap.h>
12 #include <qdatetime.h>
14 #define IRC_SAFE_MAX_LINE 450
16 #include "boundscheckingarray.h"
17 #include "ksircchannel.h"
18 #include "ksircserver.h"
20 // Central place to hold KSirc's options
21 // and manage default values. The base classes
22 // are only used directly by the prefs dialog.
23 // The constructors initialize all options with default values.
24 class KSOGeneral
26 public:
27 KSOGeneral();
29 enum { SDI, MDI } displayMode;
30 bool autoCreateWin : 1;
31 bool autoCreateWinForNotice : 1;
32 bool nickCompletion : 1;
33 bool displayTopic : 1;
34 bool oneLineEntry : 1;
35 bool runDocked : 1;
36 // bool timeStamp : 1;
37 // bool beepNotify : 1;
38 bool colorPicker : 1;
39 bool autoRejoin : 1;
40 // bool beepOnMsg : 1;
41 // bool logging : 1;
42 bool publicAway : 1;
43 bool useColourNickList : 1;
44 // bool topicShow : 1;
45 bool dockPopups : 1;
46 bool autoSaveHistory : 1;
47 int windowLength;
48 QString backgroundFile;
50 QPixmap backgroundPixmap();
52 private:
53 QPixmap m_backgroundPixmap;
56 class KSOChannel
58 public:
59 KSOChannel();
61 QString server;
62 QString channel;
64 bool timeStamp : 1;
65 bool beepNotify : 1;
66 bool beepOnMsg : 1;
67 bool logging : 1;
68 bool topicShow : 1;
69 bool filterJoinPart : 1;
70 QString encoding;
72 QDateTime lastUsed;
74 static bool applyGlobally;
80 class KSOServer
82 public:
83 KSOServer();
85 QString server;
86 bool globalCopy;
88 QString nick;
89 QString altNick;
90 QString realName;
91 QString userID;
92 QStringList notifyList;
94 QDateTime lastUsed;
97 class KSOStartup
99 public:
100 KSOStartup();
102 QRect geometry;
103 // QString nick;
104 // QString altNick;
105 // QString realName;
106 // QString userID;
107 // QStringList notifyList;
110 class KSOColors
112 public:
113 enum { numColors = 16 };
115 KSOColors();
117 QColor textColor;
118 QColor linkColor;
119 QColor infoColor;
120 QColor channelColor;
121 QColor errorColor;
122 QColor ownNickColor;
123 bool ownNickBold : 1;
124 bool ownNickUl : 1;
125 bool ownNickRev : 1;
127 QColor msgContainNick; // needs config + impl
128 QColor msg1Contain; // needs config
129 QString msg1String; // needs config
130 bool msg1Regex;
131 QColor msg2Contain; // need config
132 QString msg2String; // needs config
133 bool msg2Regex;
135 QColor nickForeground;
136 QColor nickBackground;
137 QColor backgroundColor;
138 QColor selBackgroundColor;
139 QColor selForegroundColor;
140 //QColor ircColors[numColors];
141 BoundsCheckingArray<QColor, numColors> ircColors;
142 BoundsCheckingArray<bool, numColors> nickHighlight;
144 QString colourTheme;
146 QFont defaultFont;
147 bool ksircColors : 1;
148 bool mircColors : 1;
149 bool nickColourization : 1;
153 class KSORMBMenu
155 public:
156 KSORMBMenu();
159 class KSOServChan
161 public:
162 KSOServChan();
165 typedef QMap<QString, KSOChannel> ChannelOpMap;
166 typedef QMap<QString, ChannelOpMap> ServerChannelOpMap;
167 typedef QMap<QString, KSOServer> ServerOpMap;
169 class KSOptions
170 : public KSOGeneral,
171 public KSOStartup,
172 public KSOColors,
173 public KSORMBMenu,
174 public KSOServChan
176 public:
177 KSOptions() { s_options = this; }
179 void load( int sections = -1 );
180 void save( int sections = -1 );
182 static KSOptions *options() { return s_options; }
184 ServerChannelOpMap channel;
185 ServerOpMap server;
187 KSOChannel &chan( const KSircChannel &chanInfo )
189 return channel[chanInfo.server()][chanInfo.channel()];
192 KSOServer &serv( const KSircServer &servInfo )
194 return server[servInfo.server()];
197 void channelSetup(QString serv, QString chan);
198 void applyChannelGlobal(void);
200 void serverSetup(QString server);
201 void serverSetup( const KSircServer &servInfo )
203 serverSetup(servInfo.server());
206 enum {
207 All = -1, General = 1, Startup = 2,
208 Colors = 4, RMBMenu = 8, ServChan = 16,
209 Channels = 32, Servers = 64
212 private:
213 static KSOptions *s_options;
216 #define ksopts (KSOptions::options())
218 #endif