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 "patternlist.h"
29 #include "gui/entity/serverlistfilterinfo.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 bLookupHosts;
70  bool bMarkServersWithBuddies;
71  bool bQueryAutoRefreshDontIfActive;
72  bool bQueryAutoRefreshEnabled;
73  bool bQueryBeforeLaunch;
74  bool bQueryOnStartup;
75  bool bRecordDemo;
76  bool bTellMeWhereAreTheWADsWhenIHoverCursorOverWADSColumn;
77  PatternList buddies;
78  bool bUseTrayIcon;
79  QString buddyServersColor;
80  QVector<CustomServerInfo> customServers;
81  QString customServersColor;
82  QString lanServersColor;
83  QString localization;
84  QString mainWindowState;
85  QByteArray mainWindowGeometry;
86  unsigned queryAutoRefreshEverySeconds;
87  QString previousCreateServerConfigDir;
88  QString previousCreateServerExecDir;
89  QString previousCreateServerWadDir;
90  QString serverListColumnState;
91  int serverListSortIndex;
92  int serverListSortDirection;
93  QString slotStyle;
94  QList<FileSearchPath> wadPaths;
95 
96  DoomseekerCfg();
97  ~DoomseekerCfg();
98 
99  QList<ColumnSort> additionalSortColumns() const;
100  void setAdditionalSortColumns(const QList<ColumnSort> &val);
101 
102  void enableFreedoomInstallation(const QString &dir);
103 
104  const QuerySpeed &querySpeed() const;
105  void setQuerySpeed(const QuerySpeed &val);
106 
107  QList<FileAlias> wadAliases() const;
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  {
135  UM_Disabled = 0,
140  UM_NotifyOnly = 1,
144  UM_FullAuto = 2
145  };
146 
147  static const QString SECTION_NAME;
148 
156  QMap<QString, QString> 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 bAlwaysUseDefaultSites;
187  bool bSearchInIdgames;
188  bool bSearchInWadArchive;
189  QString colorMessageCriticalError;
190  QString colorMessageError;
191  QString colorMessageNotice;
192  int connectTimeoutSeconds;
193  int downloadTimeoutSeconds;
194  int maxConcurrentSiteDownloads;
195  int maxConcurrentWadDownloads;
196  QString idgamesURL;
197  QStringList searchURLs;
198  QString targetDirectory;
199 
200  WadseekerCfg();
201 
208  void init(IniSection& section);
209  void load(IniSection& section);
210  void save(IniSection& section);
211  };
212 
216  static DoomseekerConfig& config();
217 
225  static void dispose();
226 
227  DoomseekerCfg doomseeker;
228  AutoUpdates autoUpdates;
229  ServerFilter serverFilter;
230  WadseekerCfg wadseeker;
231 
232  Ini* ini() { return this->pIni.data(); }
233 
249  IniSection iniSectionForPlugin(const QString& pluginName);
251 
256  bool readFromFile();
257 
262  bool saveToFile();
263 
272  bool setIniFile(const QString& filePath);
273 
274  QList<FileSearchPath> combinedWadseekPaths() const;
275 
276 
277  private:
278  static DoomseekerConfig* instance;
279 
280  bool isValidPluginName(const QString& pluginName) const;
281 
286  IniSection* dummySection;
287 
288  QScopedPointer<QSettings> settings;
289  QScopedPointer<SettingsProviderQt> settingsProvider;
290  QScopedPointer<Ini> pIni;
291 
293  ~DoomseekerConfig();
294 };
295 
296 #endif
297 
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