doomseekerconfig.h
1 //------------------------------------------------------------------------------
2 // doomseekerconfig.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 __DOOMSEEKERCONFIG_H__
24 #define __DOOMSEEKERCONFIG_H__
25 
26 #include "customservers.h"
27 #include "dptr.h"
28 #include "gui/entity/serverlistfilterinfo.h"
29 #include "serverapi/buddyinfo.h"
30 #include <QScopedPointer>
31 #include <QSettings>
32 #include <QString>
33 #include <QStringList>
34 #include <QVector>
35 
36 #define gConfig DoomseekerConfig::config()
37 
38 class ColumnSort;
39 class Ini;
40 class EnginePlugin;
41 class FileAlias;
42 class FileSearchPath;
43 class QuerySpeed;
44 class SettingsProviderQt;
45 
55 {
56  public:
58  {
59  public:
60  static const QString SECTION_NAME;
61 
62 
63  bool bBotsAreNotPlayers;
64  bool bCloseToTrayIcon;
65  bool bColorizeServerConsole;
66  bool bDrawGridInServerTable;
67  bool bHidePasswords;
68  bool bGroupServersWithPlayersAtTheTopOfTheList;
69  bool bIP2CountryAutoUpdate;
70  bool bLookupHosts;
71  bool bMarkServersWithBuddies;
72  bool bQueryAutoRefreshDontIfActive;
73  bool bQueryAutoRefreshEnabled;
74  bool bQueryBeforeLaunch;
75  bool bQueryOnStartup;
76  bool bRecordDemo;
77  bool bTellMeWhereAreTheWADsWhenIHoverCursorOverWADSColumn;
78  QVector<BuddyInfo> buddiesList;
79  bool bUseTrayIcon;
80  QString buddyServersColor;
81  QVector<CustomServerInfo> customServers;
82  QString customServersColor;
83  QString localization;
84  unsigned ip2CountryDatabaseMaximumAge;
85  QString ip2CountryUrl;
86  QString mainWindowState;
87  QByteArray mainWindowGeometry;
88  unsigned queryAutoRefreshEverySeconds;
89  QString previousCreateServerConfigDir;
90  QString previousCreateServerExecDir;
91  QString previousCreateServerWadDir;
92  QString serverListColumnState;
93  int serverListSortIndex;
94  int serverListSortDirection;
95  int slotStyle;
96  QList<FileSearchPath> wadPaths;
97 
98  DoomseekerCfg();
99  ~DoomseekerCfg();
100 
101  QList<ColumnSort> additionalSortColumns() const;
102  void setAdditionalSortColumns(const QList<ColumnSort> &val);
103 
104  const QuerySpeed &querySpeed() const;
105  void setQuerySpeed(const QuerySpeed &val);
106 
107  QList<FileAlias> wadAliases();
108  void setWadAliases(const QList<FileAlias> &val);
109 
110  QStringList wadPathsOnly() const;
111 
118  void init(IniSection& section);
119  void initWadAlias();
120  void load(IniSection& section);
121  void save(IniSection& section);
122 
123  private:
125  };
126 
128  {
129  public:
131  {
145  };
146 
147  static const QString SECTION_NAME;
148 
156  QMap<QString, unsigned long long> lastKnownUpdateRevisions;
157  UpdateMode updateMode;
162  bool bPerformUpdateOnNextRun;
163 
164  void init(IniSection& section);
165  void load(IniSection& section);
166  void save(IniSection& section);
167  };
168 
170  {
171  public:
172  static const QString SECTION_NAME;
173 
175 
176  void init(IniSection& section);
177  void load(IniSection& section);
178  void save(IniSection& section);
179  };
180 
182  {
183  public:
184  static const QString SECTION_NAME;
185 
186  bool bSearchInIdgames;
187  bool bSearchInWadArchive;
188  QString colorMessageCriticalError;
189  QString colorMessageError;
190  QString colorMessageNotice;
191  int connectTimeoutSeconds;
192  int downloadTimeoutSeconds;
193  int maxConcurrentSiteDownloads;
194  int maxConcurrentWadDownloads;
195  QString idgamesURL;
196  QStringList searchURLs;
197  QString targetDirectory;
198 
199  WadseekerCfg();
200 
207  void init(IniSection& section);
208  void load(IniSection& section);
209  void save(IniSection& section);
210  };
211 
215  static DoomseekerConfig& config();
216 
224  static void dispose();
225 
226  DoomseekerCfg doomseeker;
227  AutoUpdates autoUpdates;
228  ServerFilter serverFilter;
229  WadseekerCfg wadseeker;
230 
231  Ini* ini() { return this->pIni.data(); }
232 
248  IniSection iniSectionForPlugin(const QString& pluginName);
250 
255  bool readFromFile();
256 
261  bool saveToFile();
262 
271  bool setIniFile(const QString& filePath);
272 
273 
274  private:
275  static DoomseekerConfig* instance;
276 
277  bool isValidPluginName(const QString& pluginName) const;
278 
283  IniSection* dummySection;
284 
285  QScopedPointer<QSettings> settings;
286  QScopedPointer<SettingsProviderQt> settingsProvider;
287  QScopedPointer<Ini> pIni;
288 
290  ~DoomseekerConfig();
291 };
292 
293 #endif
294 
QString updateChannelName
Pass this to UpdateChannel::fromName() .
Structure describing server filter.
void init(IniSection &section)
Initializes values that are not present in the section yet.
QMap< QString, unsigned long long > lastKnownUpdateRevisions
Used to check if there are new updates since last reject.
bool saveToFile()
Saves current settings to ini file. This file must be previously set by setIniFile() method...
This Singleton holds entire Doomseeker configuration in memory.
IniSection iniSectionForPlugin(const QString &pluginName)
This will assume that the .ini file is initialized.
void init(IniSection &section)
Initializes values that are not present in the section yet.
Configuration handler.
Definition: ini.h:69
bool readFromFile()
Reads settings from ini file. This file must be previously set by setIniFile() method.
static DoomseekerConfig & config()
Returns the Singleton.
INI section representation.
Definition: inisection.h:40
bool setIniFile(const QString &filePath)
Initializes the Ini class instance to point to a file.
static void dispose()
Disposes of the Singleton.
Definition: dptr.h:54
User is only notified of the update and decides if it should be installed.