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 OS_USERNAME_TMPL;
60  static const QString SECTION_NAME;
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  QByteArray demoManagerGeometry;
90  QByteArray demoManagerSplitterState;
91  unsigned queryAutoRefreshEverySeconds;
92  QString playerName;
93  QString previousCreateServerConfigDir;
94  QString previousCreateServerExecDir;
95  QString previousCreateServerLogDir;
96  QString previousCreateServerWadDir;
97  QString previousDemoExportDir;
98  QString serverListColumnState;
99  int serverListSortIndex;
100  int serverListSortDirection;
101  QString slotStyle;
102  QList<FileSearchPath> wadPaths;
103 
104  DoomseekerCfg();
105  ~DoomseekerCfg();
106 
107  QList<ColumnSort> additionalSortColumns() const;
108  void setAdditionalSortColumns(const QList<ColumnSort> &val);
109 
110  void enableFreedoomInstallation(const QString &dir);
111 
112  const QuerySpeed &querySpeed() const;
113  void setQuerySpeed(const QuerySpeed &val);
114 
122  QString realPlayerName() const;
123 
124  QList<FileAlias> wadAliases() const;
125  void setWadAliases(const QList<FileAlias> &val);
126 
127  QStringList wadPathsOnly() const;
128 
135  void init(IniSection &section);
136  void initWadAlias();
137  void load(IniSection &section);
138  void save(IniSection &section);
139 
140  private:
142  };
143 
145  {
146  public:
148  {
162  };
163 
164  static const QString SECTION_NAME;
165 
173  QMap<QString, QString> lastKnownUpdateRevisions;
174  UpdateMode updateMode;
179  bool bPerformUpdateOnNextRun;
180 
181  void init(IniSection &section);
182  void load(IniSection &section);
183  void save(IniSection &section);
184  };
185 
187  {
188  public:
189  static const QString SECTION_NAME;
190 
192  QString currentPreset;
193  QVariantMap presets;
194 
195  void init(IniSection &section);
196  void load(IniSection &section);
197  void save(IniSection &section);
198  };
199 
201  {
202  public:
203  static const QString SECTION_NAME;
204 
205  bool bAlwaysUseDefaultSites;
206  bool bSearchInIdgames;
207  QString colorMessageCriticalError;
208  QString colorMessageError;
209  QString colorMessageNotice;
210  QString colorMessageNavigation;
211  int maxConcurrentSiteDownloads;
212  int maxConcurrentWadDownloads;
213  QString idgamesURL;
214  QStringList searchURLs;
215  QString targetDirectory;
216 
217  WadseekerCfg();
218 
225  void init(IniSection &section);
226  void load(IniSection &section);
227  void save(IniSection &section);
228  };
229 
233  static DoomseekerConfig &config();
234 
242  static void dispose();
243 
244  DoomseekerCfg doomseeker;
245  AutoUpdates autoUpdates;
246  ServerFilter serverFilter;
247  WadseekerCfg wadseeker;
248 
249  Ini *ini()
250  {
251  return this->pIni.data();
252  }
253 
269  IniSection iniSectionForPlugin(const QString &pluginName);
271 
276  bool readFromFile();
277 
282  bool saveToFile();
283 
292  bool setIniFile(const QString &filePath);
293 
294  QList<FileSearchPath> combinedWadseekPaths() const;
295 
296 private:
297  static DoomseekerConfig *instance;
298 
299  bool isValidPluginName(const QString &pluginName) const;
300 
305  IniSection *dummySection;
306 
307  QScopedPointer<QSettings> settings;
308  QScopedPointer<SettingsProviderQt> settingsProvider;
309  QScopedPointer<Ini> pIni;
310 
312  ~DoomseekerConfig();
313 };
314 
315 #endif