doomseekerconfig.h
1 //------------------------------------------------------------------------------
2 // doomseekerconfig.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 __DOOMSEEKERCONFIG_H__
24 #define __DOOMSEEKERCONFIG_H__
25 
26 #include "customservers.h"
27 #include "dptr.h"
28 #include "gui/entity/serverlistfilterinfo.h"
29 #include "patternlist.h"
30 #include <QScopedPointer>
31 #include <QSettings>
32 #include <QString>
33 #include <QStringList>
34 
35 #define gConfig DoomseekerConfig::config()
36 
37 class ColumnSort;
38 class Ini;
39 class EnginePlugin;
40 class FileAlias;
41 class FileSearchPath;
42 struct QuerySpeed;
43 class SettingsProviderQt;
44 
54 {
55 public:
57  {
58  public:
59  static const QString SECTION_NAME;
60 
61 
62  bool bBotsAreNotPlayers;
63  bool bCloseToTrayIcon;
64  bool bColorizeServerConsole;
65  bool bDrawGridInServerTable;
66  bool bHidePasswords;
67  bool bHonorServerCountries;
68  bool bGroupServersWithPlayersAtTheTopOfTheList;
69  bool bIP2CountryAutoUpdate;
70  bool bLogCreatedServer;
71  bool bLookupHosts;
72  bool bMarkServersWithBuddies;
73  bool bQueryAutoRefreshDontIfActive;
74  bool bQueryAutoRefreshEnabled;
75  bool bQueryBeforeLaunch;
76  bool bQueryOnStartup;
77  bool bRecordDemo;
78  bool bTellMeWhereAreTheWADsWhenIHoverCursorOverWADSColumn;
79  bool bCheckTheIntegrityOfWads;
80  PatternList buddies;
81  bool bUseTrayIcon;
82  QString buddyServersColor;
83  QVector<CustomServerInfo> customServers;
84  QString customServersColor;
85  QString lanServersColor;
86  QString localization;
87  QString mainWindowState;
88  QByteArray mainWindowGeometry;
89  unsigned queryAutoRefreshEverySeconds;
90  QString previousCreateServerConfigDir;
91  QString previousCreateServerExecDir;
92  QString previousCreateServerLogDir;
93  QString previousCreateServerWadDir;
94  QString serverListColumnState;
95  int serverListSortIndex;
96  int serverListSortDirection;
97  QString slotStyle;
98  QList<FileSearchPath> wadPaths;
99 
100  DoomseekerCfg();
101  ~DoomseekerCfg();
102 
103  QList<ColumnSort> additionalSortColumns() const;
104  void setAdditionalSortColumns(const QList<ColumnSort> &val);
105 
106  void enableFreedoomInstallation(const QString &dir);
107 
108  const QuerySpeed &querySpeed() const;
109  void setQuerySpeed(const QuerySpeed &val);
110 
111  QList<FileAlias> wadAliases() const;
112  void setWadAliases(const QList<FileAlias> &val);
113 
114  QStringList wadPathsOnly() const;
115 
122  void init(IniSection &section);
123  void initWadAlias();
124  void load(IniSection &section);
125  void save(IniSection &section);
126 
127  private:
129  };
130 
132  {
133  public:
135  {
149  };
150 
151  static const QString SECTION_NAME;
152 
160  QMap<QString, QString> lastKnownUpdateRevisions;
161  UpdateMode updateMode;
166  bool bPerformUpdateOnNextRun;
167 
168  void init(IniSection &section);
169  void load(IniSection &section);
170  void save(IniSection &section);
171  };
172 
174  {
175  public:
176  static const QString SECTION_NAME;
177 
179 
180  void init(IniSection &section);
181  void load(IniSection &section);
182  void save(IniSection &section);
183  };
184 
186  {
187  public:
188  static const QString SECTION_NAME;
189 
190  bool bAlwaysUseDefaultSites;
191  bool bSearchInIdgames;
192  bool bSearchInWadArchive;
193  QString colorMessageCriticalError;
194  QString colorMessageError;
195  QString colorMessageNotice;
196  int maxConcurrentSiteDownloads;
197  int maxConcurrentWadDownloads;
198  QString idgamesURL;
199  QStringList searchURLs;
200  QString targetDirectory;
201 
202  WadseekerCfg();
203 
210  void init(IniSection &section);
211  void load(IniSection &section);
212  void save(IniSection &section);
213  };
214 
218  static DoomseekerConfig &config();
219 
227  static void dispose();
228 
229  DoomseekerCfg doomseeker;
230  AutoUpdates autoUpdates;
231  ServerFilter serverFilter;
232  WadseekerCfg wadseeker;
233 
234  Ini *ini()
235  {
236  return this->pIni.data();
237  }
238 
254  IniSection iniSectionForPlugin(const QString &pluginName);
256 
261  bool readFromFile();
262 
267  bool saveToFile();
268 
277  bool setIniFile(const QString &filePath);
278 
279  QList<FileSearchPath> combinedWadseekPaths() const;
280 
281 
282 private:
283  static DoomseekerConfig *instance;
284 
285  bool isValidPluginName(const QString &pluginName) const;
286 
291  IniSection *dummySection;
292 
293  QScopedPointer<QSettings> settings;
294  QScopedPointer<SettingsProviderQt> settingsProvider;
295  QScopedPointer<Ini> pIni;
296 
298  ~DoomseekerConfig();
299 };
300 
301 #endif