ircconfig.h
1 //------------------------------------------------------------------------------
2 // ircconfig.h
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library 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 GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2010 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef __IRCCONFIG_H__
24 #define __IRCCONFIG_H__
25 
26 #define gIRCConfig IRCConfig::config()
27 
28 #include "ini/ini.h"
29 #include "irc/entities/ircnetworkentity.h"
30 #include <QFont>
31 #include <QScopedPointer>
32 #include <QSettings>
33 
34 class SettingsProviderQt;
35 
44 class IRCConfig
45 {
46  public:
48  {
49  public:
50  static const QString SECTION_NAME;
51 
52  QString backgroundColor;
53  QString channelActionColor;
54  QString ctcpColor;
55  QString defaultTextColor;
56  QString errorColor;
57  QFont mainFont;
58  QString networkActionColor;
59  bool timestamps;
60  QString urlColor;
61  QFont userListFont;
62  QString userListSelectedTextColor;
63  QString userListSelectedBackgroundColor;
64  bool windowAlertOnImportantChatEvent;
65 
66  AppearanceCfg();
67 
68  void init(IniSection& section);
69  void load(IniSection& section);
70  void save(IniSection& section);
71  };
72 
73  class GeneralCfg
74  {
75  public:
76  static const QString SECTION_NAME;
77 
78  GeneralCfg();
79 
80  void load(IniSection& section);
81  void save(IniSection& section);
82  };
83 
85  {
86  public:
87  static const QString SECTION_NAME;
88 
89  QString alternativeNickname;
90  QString fullName;
91  QString nickname;
92  QString quitMessage;
93  QString userName;
94 
95  PersonalCfg();
96 
97  // This does not require a init since all values are meant
98  // to be empty by default.
99 
100  void load(IniSection& section);
101  void save(IniSection& section);
102  };
103 
104  class SoundsCfg
105  {
106  public:
107  static const QString SECTION_NAME;
108 
109  bool bUseNicknameUsedSound;
110  bool bUsePrivateMessageReceivedSound;
111  QString nicknameUsedSound;;
112  QString privateMessageReceivedSound;
113 
114  SoundsCfg();
115 
116  void load(IniSection& section);
117  void save(IniSection& section);
118  };
119 
123  static IRCConfig& config();
124 
132  static void dispose();
133 
134  AppearanceCfg appearance;
135  GeneralCfg general;
136  PersonalCfg personal;
137  SoundsCfg sounds;
138 
139  Ini* ini() { return this->pIni.data(); }
140 
145  bool readFromFile();
146 
151  bool saveToFile();
152 
161  bool setIniFile(const QString& filePath);
162 
163 
164  private:
165  static IRCConfig* instance;
166 
167  QScopedPointer<QSettings> settings;
168  QScopedPointer<SettingsProviderQt> settingsProvider;
169  QScopedPointer<Ini> pIni;
170 
171  IRCConfig();
172  ~IRCConfig();
173 
174  void loadNetworksFromPlugins();
175 };
176 
177 #endif
static IRCConfig & config()
Returns the Singleton.
Definition: ircconfig.cpp:45
This Singleton holds most of Doomseeker IRC configuration in memory.
Definition: ircconfig.h:44
bool saveToFile()
Saves current settings to ini file. This file must be previously set by setIniFile() method...
Definition: ircconfig.cpp:139
Configuration handler.
Definition: ini.h:69
bool readFromFile()
Reads settings from ini file. This file must be previously set by setIniFile() method.
Definition: ircconfig.cpp:113
static void dispose()
Disposes of the Singleton.
Definition: ircconfig.cpp:55
INI section representation.
Definition: inisection.h:40
bool setIniFile(const QString &filePath)
Initializes the Ini class instance to point to a file.
Definition: ircconfig.cpp:168