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 bIP2CountryAutoUpdate;
69  bool bLogCreatedServer;
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  bool bCheckTheIntegrityOfWads;
79  bool bResolveTemplatedPathsPlaceholders;
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  QString currentPreset;
180  QVariantMap presets;
181 
182  void init(IniSection &section);
183  void load(IniSection &section);
184  void save(IniSection &section);
185  };
186 
188  {
189  public:
190  static const QString SECTION_NAME;
191 
192  bool bAlwaysUseDefaultSites;
193  bool bSearchInIdgames;
194  QString colorMessageCriticalError;
195  QString colorMessageError;
196  QString colorMessageNotice;
197  int maxConcurrentSiteDownloads;
198  int maxConcurrentWadDownloads;
199  QString idgamesURL;
200  QStringList searchURLs;
201  QString targetDirectory;
202 
203  WadseekerCfg();
204 
211  void init(IniSection &section);
212  void load(IniSection &section);
213  void save(IniSection &section);
214  };
215 
219  static DoomseekerConfig &config();
220 
228  static void dispose();
229 
230  DoomseekerCfg doomseeker;
231  AutoUpdates autoUpdates;
232  ServerFilter serverFilter;
233  WadseekerCfg wadseeker;
234 
235  Ini *ini()
236  {
237  return this->pIni.data();
238  }
239 
255  IniSection iniSectionForPlugin(const QString &pluginName);
257 
262  bool readFromFile();
263 
268  bool saveToFile();
269 
278  bool setIniFile(const QString &filePath);
279 
280  QList<FileSearchPath> combinedWadseekPaths() const;
281 
282 
283 private:
284  static DoomseekerConfig *instance;
285 
286  bool isValidPluginName(const QString &pluginName) const;
287 
292  IniSection *dummySection;
293 
294  QScopedPointer<QSettings> settings;
295  QScopedPointer<SettingsProviderQt> settingsProvider;
296  QScopedPointer<Ini> pIni;
297 
299  ~DoomseekerConfig();
300 };
301 
302 #endif