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 bGroupServersWithPlayersAtTheTopOfTheList;
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  PatternList buddies;
80  bool bUseTrayIcon;
81  QString buddyServersColor;
82  QVector<CustomServerInfo> customServers;
83  QString customServersColor;
84  QString lanServersColor;
85  QString localization;
86  QString mainWindowState;
87  QByteArray mainWindowGeometry;
88  unsigned queryAutoRefreshEverySeconds;
89  QString previousCreateServerConfigDir;
90  QString previousCreateServerExecDir;
91  QString previousCreateServerLogDir;
92  QString previousCreateServerWadDir;
93  QString serverListColumnState;
94  int serverListSortIndex;
95  int serverListSortDirection;
96  QString slotStyle;
97  QList<FileSearchPath> wadPaths;
98 
99  DoomseekerCfg();
100  ~DoomseekerCfg();
101 
102  QList<ColumnSort> additionalSortColumns() const;
103  void setAdditionalSortColumns(const QList<ColumnSort> &val);
104 
105  void enableFreedoomInstallation(const QString &dir);
106 
107  const QuerySpeed &querySpeed() const;
108  void setQuerySpeed(const QuerySpeed &val);
109 
110  QList<FileAlias> wadAliases() const;
111  void setWadAliases(const QList<FileAlias> &val);
112 
113  QStringList wadPathsOnly() const;
114 
121  void init(IniSection &section);
122  void initWadAlias();
123  void load(IniSection &section);
124  void save(IniSection &section);
125 
126  private:
128  };
129 
131  {
132  public:
134  {
138  UM_Disabled = 0,
143  UM_NotifyOnly = 1,
147  UM_FullAuto = 2
148  };
149 
150  static const QString SECTION_NAME;
151 
159  QMap<QString, QString> lastKnownUpdateRevisions;
160  UpdateMode updateMode;
165  bool bPerformUpdateOnNextRun;
166 
167  void init(IniSection &section);
168  void load(IniSection &section);
169  void save(IniSection &section);
170  };
171 
173  {
174  public:
175  static const QString SECTION_NAME;
176 
178 
179  void init(IniSection &section);
180  void load(IniSection &section);
181  void save(IniSection &section);
182  };
183 
185  {
186  public:
187  static const QString SECTION_NAME;
188 
189  bool bAlwaysUseDefaultSites;
190  bool bSearchInIdgames;
191  bool bSearchInWadArchive;
192  QString colorMessageCriticalError;
193  QString colorMessageError;
194  QString colorMessageNotice;
195  int connectTimeoutSeconds;
196  int downloadTimeoutSeconds;
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
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.
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.
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.
QMap< QString, QString > lastKnownUpdateRevisions
Used to check if there are new updates since last reject.
Definition: dptr.h:54