doomseekerconfig.h
1 //------------------------------------------------------------------------------
2 // doomseekerconfig.h
3 //------------------------------------------------------------------------------
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program 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
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; 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 "serverapi/buddyinfo.h"
30 #include <QScopedPointer>
31 #include <QSettings>
32 #include <QString>
33 #include <QStringList>
34 #include <QVector>
35 
36 #define gConfig DoomseekerConfig::config()
37 
38 class ColumnSort;
39 class Ini;
40 class EnginePlugin;
41 class FileAlias;
42 class FileSearchPath;
43 struct QuerySpeed;
44 class SettingsProviderQt;
45 
55 {
56  public:
58  {
59  public:
60  static const QString SECTION_NAME;
61 
62 
63  bool bBotsAreNotPlayers;
64  bool bCloseToTrayIcon;
65  bool bColorizeServerConsole;
66  bool bDrawGridInServerTable;
67  bool bHidePasswords;
68  bool bGroupServersWithPlayersAtTheTopOfTheList;
69  bool bIP2CountryAutoUpdate;
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  QVector<BuddyInfo> buddiesList;
79  bool bUseTrayIcon;
80  QString buddyServersColor;
81  QVector<CustomServerInfo> customServers;
82  QString customServersColor;
83  QString lanServersColor;
84  QString localization;
85  QString mainWindowState;
86  QByteArray mainWindowGeometry;
87  unsigned queryAutoRefreshEverySeconds;
88  QString previousCreateServerConfigDir;
89  QString previousCreateServerExecDir;
90  QString previousCreateServerWadDir;
91  QString serverListColumnState;
92  int serverListSortIndex;
93  int serverListSortDirection;
94  int slotStyle;
95  QList<FileSearchPath> wadPaths;
96 
97  DoomseekerCfg();
98  ~DoomseekerCfg();
99 
100  QList<ColumnSort> additionalSortColumns() const;
101  void setAdditionalSortColumns(const QList<ColumnSort> &val);
102 
103  void enableFreedoomInstallation(const QString &dir);
104 
105  const QuerySpeed &querySpeed() const;
106  void setQuerySpeed(const QuerySpeed &val);
107 
108  QList<FileAlias> wadAliases() const;
109  void setWadAliases(const QList<FileAlias> &val);
110 
111  QStringList wadPathsOnly() const;
112 
119  void init(IniSection& section);
120  void initWadAlias();
121  void load(IniSection& section);
122  void save(IniSection& section);
123 
124  private:
126  };
127 
129  {
130  public:
132  {
136  UM_Disabled = 0,
141  UM_NotifyOnly = 1,
145  UM_FullAuto = 2
146  };
147 
148  static const QString SECTION_NAME;
149 
157  QMap<QString, QString> lastKnownUpdateRevisions;
158  UpdateMode updateMode;
163  bool bPerformUpdateOnNextRun;
164 
165  void init(IniSection& section);
166  void load(IniSection& section);
167  void save(IniSection& section);
168  };
169 
171  {
172  public:
173  static const QString SECTION_NAME;
174 
176 
177  void init(IniSection& section);
178  void load(IniSection& section);
179  void save(IniSection& section);
180  };
181 
183  {
184  public:
185  static const QString SECTION_NAME;
186 
187  bool bAlwaysUseDefaultSites;
188  bool bSearchInIdgames;
189  bool bSearchInWadArchive;
190  QString colorMessageCriticalError;
191  QString colorMessageError;
192  QString colorMessageNotice;
193  int connectTimeoutSeconds;
194  int downloadTimeoutSeconds;
195  int maxConcurrentSiteDownloads;
196  int maxConcurrentWadDownloads;
197  QString idgamesURL;
198  QStringList searchURLs;
199  QString targetDirectory;
200 
201  WadseekerCfg();
202 
209  void init(IniSection& section);
210  void load(IniSection& section);
211  void save(IniSection& section);
212  };
213 
217  static DoomseekerConfig& config();
218 
226  static void dispose();
227 
228  DoomseekerCfg doomseeker;
229  AutoUpdates autoUpdates;
230  ServerFilter serverFilter;
231  WadseekerCfg wadseeker;
232 
233  Ini* ini() { return this->pIni.data(); }
234 
250  IniSection iniSectionForPlugin(const QString& pluginName);
252 
257  bool readFromFile();
258 
263  bool saveToFile();
264 
273  bool setIniFile(const QString& filePath);
274 
275  QList<FileSearchPath> combinedWadseekPaths() const;
276 
277 
278  private:
279  static DoomseekerConfig* instance;
280 
281  bool isValidPluginName(const QString& pluginName) const;
282 
287  IniSection* dummySection;
288 
289  QScopedPointer<QSettings> settings;
290  QScopedPointer<SettingsProviderQt> settingsProvider;
291  QScopedPointer<Ini> pIni;
292 
294  ~DoomseekerConfig();
295 };
296 
297 #endif
298 
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