ircconfig.h
1 //------------------------------------------------------------------------------
2 // ircconfig.h
3 //------------------------------------------------------------------------------
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
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 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 
94  PersonalCfg();
95 
96  // This does not require a init since all values are meant
97  // to be empty by default.
98 
99  void load(IniSection& section);
100  void save(IniSection& section);
101  };
102 
103  class SoundsCfg
104  {
105  public:
106  static const QString SECTION_NAME;
107 
108  bool bUseNicknameUsedSound;
109  bool bUsePrivateMessageReceivedSound;
110  QString nicknameUsedSound;;
111  QString privateMessageReceivedSound;
112 
113  SoundsCfg();
114 
115  void load(IniSection& section);
116  void save(IniSection& section);
117  };
118 
122  static IRCConfig& config();
123 
131  static void dispose();
132 
133  AppearanceCfg appearance;
134  GeneralCfg general;
135  PersonalCfg personal;
136  SoundsCfg sounds;
137 
138  Ini* ini() { return this->pIni.data(); }
139 
144  bool readFromFile();
145 
150  bool saveToFile();
151 
160  bool setIniFile(const QString& filePath);
161 
162 
163  private:
164  static IRCConfig* instance;
165 
166  QScopedPointer<QSettings> settings;
167  QScopedPointer<SettingsProviderQt> settingsProvider;
168  QScopedPointer<Ini> pIni;
169 
170  IRCConfig();
171  ~IRCConfig();
172 
173  void loadNetworksFromPlugins();
174 };
175 
176 #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