23 #include "doomseekerconfig.h"
25 #include "configuration/queryspeed.h"
26 #include "datapaths.h"
27 #include "fileutils.h"
28 #include "gui/models/serverlistproxymodel.h"
30 #include "ini/inisection.h"
31 #include "ini/inivariable.h"
32 #include "ini/settingsproviderqt.h"
33 #include "localizationinfo.h"
35 #include "pathfinder/filealias.h"
36 #include "pathfinder/filesearchpath.h"
37 #include "plugins/engineplugin.h"
38 #include "templatedpathresolver.h"
40 #include "strings.hpp"
41 #include "updater/updatechannel.h"
43 #include "wadseeker/wadseeker.h"
49 static PatternList readPre1Point2BuddiesList(
const QString &configEntry)
53 Scanner listReader(configEntry.toUtf8().constData(), configEntry.length());
55 while (listReader.tokensLeft())
57 if (!listReader.checkToken(TK_Identifier))
60 Pattern::Syntax syntax;
61 if (listReader->str().compare(
"basic") == 0)
62 syntax = Pattern::Wildcard;
64 syntax = Pattern::RegExp;
66 if (!listReader.checkToken(TK_StringConst))
69 Pattern pattern(listReader->str(), QRegularExpression::CaseInsensitiveOption, syntax);
70 if (pattern.isValid())
73 if (!listReader.checkToken(
';'))
81 DoomseekerConfig::DoomseekerConfig()
83 this->dummySection =
new IniSection(
nullptr, QString());
86 DoomseekerConfig::~DoomseekerConfig()
88 delete this->dummySection;
93 if (instance ==
nullptr)
101 if (instance !=
nullptr)
110 if (pluginName.isEmpty())
112 gLog << QObject::tr(
"DoomseekerConfig.iniSectionForPlugin(): empty plugin name has been specified, returning dummy IniSection.");
113 return *dummySection;
116 if (!isValidPluginName(pluginName))
118 gLog << QObject::tr(
"DoomseekerConfig.iniSectionForPlugin(): plugin name is invalid: %1").arg(pluginName);
119 return *dummySection;
122 if (this->pIni ==
nullptr)
125 QString sectionName = pluginName;
126 sectionName = sectionName.replace(
' ',
"");
127 return this->pIni->section(sectionName);
135 bool DoomseekerConfig::isValidPluginName(
const QString &pluginName)
const
137 QString invalids[] = {
"doomseeker",
"wadseeker",
"" };
139 for (
int i = 0; !invalids[i].isEmpty(); ++i)
141 if (pluginName.compare(invalids[i], Qt::CaseInsensitive) == 0)
153 IniSection sectionDoomseeker = pIni->section(doomseeker.SECTION_NAME);
154 doomseeker.load(sectionDoomseeker);
156 IniSection sectionServerFilter = pIni->section(serverFilter.SECTION_NAME);
157 serverFilter.load(sectionServerFilter);
159 IniSection sectionWadseeker = pIni->section(wadseeker.SECTION_NAME);
160 wadseeker.load(sectionWadseeker);
162 IniSection sectionAutoUpdates = pIni->section(autoUpdates.SECTION_NAME);
163 autoUpdates.load(sectionAutoUpdates);
183 IniSection sectionDoomseeker = pIni->section(doomseeker.SECTION_NAME);
184 doomseeker.save(sectionDoomseeker);
186 IniSection sectionServerFilter = pIni->section(serverFilter.SECTION_NAME);
187 serverFilter.save(sectionServerFilter);
189 IniSection sectionWadseeker = pIni->section(wadseeker.SECTION_NAME);
190 wadseeker.save(sectionWadseeker);
192 IniSection sectionAutoUpdates = pIni->section(autoUpdates.SECTION_NAME);
193 autoUpdates.save(sectionAutoUpdates);
196 if (this->settings->isWritable())
198 this->settings->sync();
208 this->settingsProvider.reset();
209 this->settings.reset();
211 gLog << QObject::tr(
"Setting INI file: %1").arg(filePath);
213 this->settings.reset(
new QSettings(filePath, QSettings::IniFormat));
215 this->pIni.reset(
new Ini(this->settingsProvider.data()));
220 section = this->pIni->section(doomseeker.SECTION_NAME);
221 doomseeker.
init(section);
223 section = this->pIni->section(serverFilter.SECTION_NAME);
224 serverFilter.init(section);
226 section = this->pIni->section(wadseeker.SECTION_NAME);
227 wadseeker.
init(section);
229 section = this->pIni->section(autoUpdates.SECTION_NAME);
230 autoUpdates.init(section);
235 QList<FileSearchPath> DoomseekerConfig::combinedWadseekPaths()
const
237 QList<FileSearchPath> paths = doomseeker.wadPaths;
238 paths << wadseeker.targetDirectory;
243 DClass<DoomseekerConfig::DoomseekerCfg>
249 QString slotStyle()
const
254 const int NUM_SLOTSTYLES = 2;
255 const char *indexedSlotStyles[NUM_SLOTSTYLES] = {
"marines",
"blocks" };
257 int numeric = section[
"SlotStyle"].
value().toInt(&isInt);
258 if (isInt && numeric >= 0 && numeric < NUM_SLOTSTYLES)
259 return indexedSlotStyles[numeric];
261 return section[
"SlotStyle"].valueString();
271 this->bBotsAreNotPlayers =
true;
272 this->bCloseToTrayIcon =
false;
273 this->bColorizeServerConsole =
true;
274 this->bDrawGridInServerTable =
false;
275 this->bHidePasswords =
true;
276 this->bHonorServerCountries =
true;
277 this->bIP2CountryAutoUpdate =
true;
278 this->bLogCreatedServer =
false;
279 this->bLookupHosts =
true;
280 this->bQueryAutoRefreshDontIfActive =
true;
281 this->bQueryAutoRefreshEnabled =
false;
282 this->bQueryBeforeLaunch =
true;
283 this->bQueryOnStartup =
true;
284 this->bRecordDemo =
false;
285 this->bTellMeWhereAreTheWADsWhenIHoverCursorOverWADSColumn =
true;
286 this->bCheckTheIntegrityOfWads =
true;
287 this->bResolveTemplatedPathsPlaceholders =
false;
288 this->bUseTrayIcon =
false;
289 this->bMarkServersWithBuddies =
true;
290 this->buddyServersColor =
"#5ecf75";
291 this->customServersColor =
"#ffaa00";
292 this->lanServersColor =
"#92ebe5";
294 this->mainWindowState =
"";
295 this->mainWindowGeometry =
"";
296 this->queryAutoRefreshEverySeconds = 180;
297 setQuerySpeed(QuerySpeed::aggressive());
298 this->previousCreateServerConfigDir =
"";
299 this->previousCreateServerExecDir =
"";
300 this->previousCreateServerLogDir =
"";
301 this->previousCreateServerWadDir =
"";
302 this->slotStyle =
"blocks";
303 this->serverListSortIndex = -1;
304 this->serverListSortDirection = Qt::DescendingOrder;
305 this->wadPaths = FileSearchPath::fromStringList(gDefaultDataPaths->defaultWadPaths());
308 DoomseekerConfig::DoomseekerCfg::~DoomseekerCfg()
312 QList<ColumnSort> DoomseekerConfig::DoomseekerCfg::additionalSortColumns()
const
314 QList<ColumnSort> list;
315 QVariantList varList = d->section.value(
"AdditionalSortColumns").toList();
316 for (
const QVariant &var : varList)
318 list << ColumnSort::deserializeQVariant(var);
323 void DoomseekerConfig::DoomseekerCfg::setAdditionalSortColumns(
const QList<ColumnSort> &val)
325 QVariantList varList;
328 varList << elem.serializeQVariant();
330 d->section.setValue(
"AdditionalSortColumns", varList);
336 d->section = section;
338 section.
createSetting(
"BotsAreNotPlayers", this->bBotsAreNotPlayers);
339 section.
createSetting(
"CloseToTrayIcon", this->bCloseToTrayIcon);
340 section.
createSetting(
"ColorizeServerConsole", this->bColorizeServerConsole);
341 section.
createSetting(
"DrawGridInServerTable", this->bDrawGridInServerTable);
342 section.
createSetting(
"HidePasswords", this->bHidePasswords);
343 section.
createSetting(
"HonorServerCountries", this->bHonorServerCountries);
344 section.
createSetting(
"IP2CAutoUpdate", this->bIP2CountryAutoUpdate);
345 section.
createSetting(
"LogCreatedServers", this->bLogCreatedServer);
347 section.
createSetting(
"QueryAutoRefreshDontIfActive", this->bQueryAutoRefreshDontIfActive);
348 section.
createSetting(
"QueryAutoRefreshEnabled", this->bQueryAutoRefreshEnabled);
349 section.
createSetting(
"QueryOnStartup", this->bQueryOnStartup);
351 section.
createSetting(
"TellMeWhereAreTheWADsWhenIHoverCursorOverWADSColumn", this->bTellMeWhereAreTheWADsWhenIHoverCursorOverWADSColumn);
352 section.
createSetting(
"CheckTheIntegrityOfWads", this->bCheckTheIntegrityOfWads);
353 section.
createSetting(
"ResolveTemplatedPathsPlaceholders", bResolveTemplatedPathsPlaceholders);
355 section.
createSetting(
"MarkServersWithBuddies", this->bMarkServersWithBuddies);
356 section.
createSetting(
"BuddyServersColor", this->buddyServersColor);
357 section.
createSetting(
"CustomServersColor", this->customServersColor);
358 section.
createSetting(
"LanServersColor", this->lanServersColor);
359 section.
createSetting(
"QueryAutoRefreshEverySeconds", this->queryAutoRefreshEverySeconds);
360 section.
createSetting(
"QueryServerInterval", this->querySpeed().intervalBetweenServers);
361 section.
createSetting(
"QueryServerTimeout", this->querySpeed().delayBetweenSingleServerAttempts);
362 section.
createSetting(
"QueryAttemptsPerServer", this->querySpeed().attemptsPerServer);
364 section.
createSetting(
"ServerListSortIndex", this->serverListSortIndex);
365 section.
createSetting(
"ServerListSortDirection", this->serverListSortDirection);
366 section.
createSetting(
"WadPaths", FileSearchPath::toVariantList(this->wadPaths));
371 void DoomseekerConfig::DoomseekerCfg::initWadAlias()
373 if (!d->section.hasSetting(
"WadAliases"))
377 void DoomseekerConfig::DoomseekerCfg::load(
IniSection §ion)
379 this->localization = (
const QString &)section[
"Localization"];
380 this->bBotsAreNotPlayers = section[
"BotsAreNotPlayers"];
381 this->bCloseToTrayIcon = section[
"CloseToTrayIcon"];
382 this->bColorizeServerConsole = section[
"ColorizeServerConsole"];
383 this->bDrawGridInServerTable = section[
"DrawGridInServerTable"];
384 this->bHidePasswords = section[
"HidePasswords"];
385 this->bHonorServerCountries = section[
"HonorServerCountries"];
386 this->bIP2CountryAutoUpdate = section[
"IP2CAutoUpdate"];
387 this->bLogCreatedServer = section[
"LogCreatedServers"];
388 this->bLookupHosts = section[
"LookupHosts"];
389 this->bQueryAutoRefreshDontIfActive = section[
"QueryAutoRefreshDontIfActive"];
390 this->bQueryAutoRefreshEnabled = section[
"QueryAutoRefreshEnabled"];
391 this->bQueryBeforeLaunch = section[
"QueryBeforeLaunch"];
392 this->bQueryOnStartup = section[
"QueryOnStartup"];
393 this->bRecordDemo = section[
"RecordDemo"];
394 this->bTellMeWhereAreTheWADsWhenIHoverCursorOverWADSColumn = section[
"TellMeWhereAreTheWADsWhenIHoverCursorOverWADSColumn"];
395 this->bCheckTheIntegrityOfWads = section[
"CheckTheIntegrityOfWads"];
396 this->bResolveTemplatedPathsPlaceholders = section[
"ResolveTemplatedPathsPlaceholders"];
397 this->bUseTrayIcon = section[
"UseTrayIcon"];
398 this->bMarkServersWithBuddies = section[
"MarkServersWithBuddies"];
399 this->buddyServersColor = (
const QString &)section[
"BuddyServersColor"];
400 this->customServersColor = (
const QString &)section[
"CustomServersColor"];
401 this->lanServersColor = (
const QString &)section[
"LanServersColor"];
402 this->mainWindowState = (
const QString &)section[
"MainWindowState"];
403 this->mainWindowGeometry = section.
value(
"MainWindowGeometry",
"").toByteArray();
404 this->queryAutoRefreshEverySeconds = section[
"QueryAutoRefreshEverySeconds"];
405 d->querySpeed.intervalBetweenServers = section[
"QueryServerInterval"];
406 d->querySpeed.delayBetweenSingleServerAttempts = section[
"QueryServerTimeout"];
407 d->querySpeed.attemptsPerServer = section[
"QueryAttemptsPerServer"];
408 this->previousCreateServerConfigDir = (
const QString &)section[
"PreviousCreateServerConfigDir"];
409 this->previousCreateServerExecDir = (
const QString &)section[
"PreviousCreateServerExecDir"];
410 this->previousCreateServerLogDir = (
const QString &)section[
"PreviousCreateServerLogDir"];
411 this->previousCreateServerWadDir = (
const QString &)section[
"PreviousCreateServerWadDir"];
412 this->serverListColumnState = (
const QString &)section[
"ServerListColumnState"];
413 this->serverListSortIndex = section[
"ServerListSortIndex"];
414 this->serverListSortDirection = section[
"ServerListSortDirection"];
415 this->slotStyle = d->slotStyle();
425 QList<CustomServerInfo> customServersList;
427 QList<CustomServerInfo> backwardCompatibleServers;
429 for (
const CustomServerInfo &backwardCompatibleServer : backwardCompatibleServers)
434 if (knownServer.isSameServer(backwardCompatibleServer))
441 customServersList << backwardCompatibleServer;
443 this->customServers = customServersList.toVector();
447 QVariant variantWadPaths = section[
"WadPaths"].
value();
448 if (variantWadPaths.isValid() && variantWadPaths.toList().isEmpty())
452 QStringList paths = variantWadPaths.toString().split(
";");
453 for (
const QString &path : paths)
461 wadPaths = FileSearchPath::fromVariantList(section[
"WadPaths"].value().toList());
467 this->buddies = PatternList::deserializeQVariant(section.
value(
"Buddies"));
471 this->buddies = readPre1Point2BuddiesList(section[
"BuddiesList"]);
475 void DoomseekerConfig::DoomseekerCfg::save(
IniSection §ion)
477 section[
"Localization"] = this->localization;
478 section[
"BotsAreNotPlayers"] = this->bBotsAreNotPlayers;
479 section[
"CloseToTrayIcon"] = this->bCloseToTrayIcon;
480 section[
"ColorizeServerConsole"] = this->bColorizeServerConsole;
481 section[
"DrawGridInServerTable"] = this->bDrawGridInServerTable;
482 section[
"HidePasswords"] = this->bHidePasswords;
483 section[
"HonorServerCountries"] = this->bHonorServerCountries;
484 section[
"IP2CAutoUpdate"] = this->bIP2CountryAutoUpdate;
485 section[
"LogCreatedServers"] = this->bLogCreatedServer;
486 section[
"LookupHosts"] = this->bLookupHosts;
487 section[
"QueryAutoRefreshDontIfActive"] = this->bQueryAutoRefreshDontIfActive;
488 section[
"QueryAutoRefreshEnabled"] = this->bQueryAutoRefreshEnabled;
489 section[
"QueryBeforeLaunch"] = this->bQueryBeforeLaunch;
490 section[
"QueryOnStartup"] = this->bQueryOnStartup;
491 section[
"RecordDemo"] = this->bRecordDemo;
492 section[
"TellMeWhereAreTheWADsWhenIHoverCursorOverWADSColumn"] = this->bTellMeWhereAreTheWADsWhenIHoverCursorOverWADSColumn;
493 section[
"CheckTheIntegrityOfWads"] = this->bCheckTheIntegrityOfWads;
494 section[
"ResolveTemplatedPathsPlaceholders"] = this->bResolveTemplatedPathsPlaceholders;
495 section[
"UseTrayIcon"] = this->bUseTrayIcon;
496 section[
"MarkServersWithBuddies"] = this->bMarkServersWithBuddies;
497 section[
"BuddyServersColor"] = this->buddyServersColor;
498 section[
"CustomServersColor"] = this->customServersColor;
499 section[
"LanServersColor"] = this->lanServersColor;
500 section[
"MainWindowState"] = this->mainWindowState;
501 section.
setValue(
"MainWindowGeometry", this->mainWindowGeometry);
502 section[
"QueryAutoRefreshEverySeconds"] = this->queryAutoRefreshEverySeconds;
503 section[
"QueryServerInterval"] = this->querySpeed().intervalBetweenServers;
504 section[
"QueryServerTimeout"] = this->querySpeed().delayBetweenSingleServerAttempts;
505 section[
"QueryAttemptsPerServer"] = this->querySpeed().attemptsPerServer;
506 section[
"PreviousCreateServerConfigDir"] = this->previousCreateServerConfigDir;
507 section[
"PreviousCreateServerExecDir"] = this->previousCreateServerExecDir;
508 section[
"PreviousCreateServerLogDir"] = this->previousCreateServerLogDir;
509 section[
"PreviousCreateServerWadDir"] = this->previousCreateServerWadDir;
510 section[
"ServerListColumnState"] = this->serverListColumnState;
511 section[
"ServerListSortIndex"] = this->serverListSortIndex;
512 section[
"ServerListSortDirection"] = this->serverListSortDirection;
513 section[
"SlotStyle"] = this->slotStyle;
518 QStringList allCustomServers;
519 QStringList allCustomServers2;
522 QString engineName = QUrl::toPercentEncoding(customServer.engine,
"",
"()");
523 QString address = QUrl::toPercentEncoding(customServer.host,
"",
"()");
525 QString customServerStringPrefix = QString(
"(%1;%2;%3")
526 .arg(engineName).arg(address)
527 .arg(customServer.port);
528 QString customServerString2 = QString(
"%1;%2)")
529 .arg(customServerStringPrefix)
530 .arg(customServer.enabled ? 1 : 0);
532 allCustomServers << customServerStringPrefix +
")";
533 allCustomServers2 << customServerString2;
535 section[
"CustomServers"] = allCustomServers.join(
";");
536 section[
"CustomServers2"] = allCustomServers2.join(
";");
538 section[
"WadPaths"].
setValue(FileSearchPath::toVariantList(this->wadPaths));
539 section[
"Buddies"].
setValue(this->buddies.serializeQVariant());
542 const QuerySpeed &DoomseekerConfig::DoomseekerCfg::querySpeed()
const
544 return d->querySpeed;
547 void DoomseekerConfig::DoomseekerCfg::setQuerySpeed(
const QuerySpeed &val)
552 QList<FileAlias> DoomseekerConfig::DoomseekerCfg::wadAliases()
const
554 QList<FileAlias> list;
555 QVariantList varList = d->section.value(
"WadAliases").toList();
556 for (
const QVariant &var : varList)
558 list << FileAlias::deserializeQVariant(var);
560 return FileAliasList::mergeDuplicates(list);
563 void DoomseekerConfig::DoomseekerCfg::setWadAliases(
const QList<FileAlias> &val)
565 QVariantList varList;
568 varList << elem.serializeQVariant();
570 d->section.setValue(
"WadAliases", varList);
573 void DoomseekerConfig::DoomseekerCfg::enableFreedoomInstallation(
const QString &dir)
579 wadPaths.prepend(dir);
581 QList<FileAlias> aliases = wadAliases();
582 aliases << FileAlias::freeDoom1Aliases();
583 aliases << FileAlias::freeDoom2Aliases();
584 aliases = FileAliasList::mergeDuplicates(aliases);
585 setWadAliases(aliases);
588 QStringList DoomseekerConfig::DoomseekerCfg::wadPathsOnly()
const
593 result << path.path();
598 const QString DoomseekerConfig::AutoUpdates::SECTION_NAME =
"Doomseeker_AutoUpdates";
600 void DoomseekerConfig::AutoUpdates::init(
IniSection §ion)
604 section.
createSetting(
"LastKnownUpdateRevisions", QVariant());
608 void DoomseekerConfig::AutoUpdates::load(
IniSection §ion)
610 updateChannelName = (
const QString &)section[
"UpdateChannelName"];
611 updateMode = (UpdateMode)section[
"UpdateMode"].value().toInt();
612 QVariantMap lastKnownUpdateRevisionsVariant = section[
"LastKnownUpdateRevisions"].
value().toMap();
613 lastKnownUpdateRevisions.clear();
614 for (
const QString &package : lastKnownUpdateRevisionsVariant.keys())
616 QVariant revisionVariant = lastKnownUpdateRevisionsVariant[package];
617 lastKnownUpdateRevisions.insert(package, revisionVariant.toString());
619 bPerformUpdateOnNextRun = section[
"bPerformUpdateOnNextRun"].
value().toBool();
622 void DoomseekerConfig::AutoUpdates::save(
IniSection §ion)
624 section[
"UpdateChannelName"] = updateChannelName;
625 section[
"UpdateMode"] = updateMode;
626 QVariantMap revisionsVariantMap;
627 for (
const QString &package : lastKnownUpdateRevisions.keys())
629 revisionsVariantMap.insert(package, lastKnownUpdateRevisions[package]);
631 section[
"LastKnownUpdateRevisions"].
setValue(revisionsVariantMap);
632 section[
"bPerformUpdateOnNextRun"].
setValue(bPerformUpdateOnNextRun);
635 const QString DoomseekerConfig::ServerFilter::SECTION_NAME =
"ServerFilter";
637 void DoomseekerConfig::ServerFilter::init(
IniSection §ion)
649 section.
createSetting(
"LockedServers", Doomseeker::Indifferent);
651 section.
createSetting(
"TestingServers", Doomseeker::Indifferent);
657 void DoomseekerConfig::ServerFilter::load(
IniSection §ion)
659 info.bEnabled = section[
"bEnabled"];
660 info.bShowEmpty = section[
"bShowEmpty"];
661 info.bShowFull = section[
"bShowFull"];
662 info.bShowOnlyValid = section[
"bShowOnlyValid"];
663 info.bShowBannedServers = section[
"bShowBannedServers"];
664 info.bShowTooSoonServers = section[
"bShowTooSoonServers"];
665 info.bShowNotRespondingServers = section[
"bShowNotRespondingServers"];
667 info.gameModesExcluded = section[
"GameModesExcluded"].
value().toStringList();
668 info.lockedServers =
static_cast<Doomseeker::ShowMode
>(section.
value(
"LockedServers").toInt());
669 info.maxPing = section[
"MaxPing"];
670 info.serverName =
static_cast<const QString &
>(section[
"ServerName"]);
671 info.testingServers =
static_cast<Doomseeker::ShowMode
>(section.
value(
"TestingServers").toInt());
672 info.wads = section[
"WADs"].
value().toStringList();
673 info.wadsExcluded = section[
"WADsExcluded"].
value().toStringList();
674 info.bPopulatedServersOnTop = section[
"bPopulatedServersOnTop"];
675 currentPreset =
static_cast<const QString &
>(section[
"CurrentPreset"]);
676 presets = section[
"Presets"].
value().toMap();
679 void DoomseekerConfig::ServerFilter::save(
IniSection §ion)
681 section[
"bEnabled"] = info.bEnabled;
682 section[
"bShowEmpty"] = info.bShowEmpty;
683 section[
"bShowFull"] = info.bShowFull;
684 section[
"bShowOnlyValid"] = info.bShowOnlyValid;
685 section[
"bShowBannedServers"] = info.bShowBannedServers;
686 section[
"bShowTooSoonServers"] = info.bShowTooSoonServers;
687 section[
"bShowNotRespondingServers"] = info.bShowNotRespondingServers;
689 section[
"GameModesExcluded"].
setValue(info.gameModesExcluded);
690 section[
"LockedServers"] = info.lockedServers;
691 section[
"MaxPing"] = info.maxPing;
692 section[
"ServerName"] = info.serverName;
693 section[
"TestingServers"] = info.testingServers;
694 section[
"WADs"].
setValue(info.wads);
695 section[
"WADsExcluded"].
setValue(info.wadsExcluded);
696 section[
"bPopulatedServersOnTop"] = info.bPopulatedServersOnTop;
697 section[
"CurrentPreset"] = currentPreset;
698 section[
"Presets"].
setValue(presets);
701 const QString DoomseekerConfig::WadseekerCfg::SECTION_NAME =
"Wadseeker";
703 DoomseekerConfig::WadseekerCfg::WadseekerCfg()
705 this->bAlwaysUseDefaultSites =
true;
706 this->bSearchInIdgames =
true;
707 this->colorMessageCriticalError =
"#ff0000";
708 this->colorMessageError =
"#ff0000";
709 this->colorMessageNotice =
"#000000";
711 this->idgamesURL = Wadseeker::defaultIdgamesUrl();
712 this->maxConcurrentSiteDownloads = 3;
713 this->maxConcurrentWadDownloads = 2;
714 this->targetDirectory = gDefaultDataPaths->localDataLocationPath();
723 section.
createSetting(
"AlwaysUseDefaultSites", this->bAlwaysUseDefaultSites);
724 section.
createSetting(
"SearchInIdgames", this->bSearchInIdgames);
725 section.
createSetting(
"ColorMessageCriticalError", this->colorMessageCriticalError);
726 section.
createSetting(
"ColorMessageError", this->colorMessageError);
727 section.
createSetting(
"ColorMessageNotice", this->colorMessageNotice);
729 section.
createSetting(
"MaxConcurrentSiteDownloads", this->maxConcurrentSiteDownloads);
730 section.
createSetting(
"MaxConcurrentWadDownloads", this->maxConcurrentWadDownloads);
731 section.
createSetting(
"SearchURLs", Wadseeker::defaultSitesListEncoded().join(
";"));
732 section.
createSetting(
"TargetDirectory", this->targetDirectory);
735 void DoomseekerConfig::WadseekerCfg::load(
IniSection §ion)
737 this->bAlwaysUseDefaultSites = section[
"AlwaysUseDefaultSites"];
738 this->bSearchInIdgames = section[
"SearchInIdgames"];
739 this->colorMessageCriticalError = (
const QString &)section[
"ColorMessageCriticalError"];
740 this->colorMessageError = (
const QString &)section[
"ColorMessageError"];
741 this->colorMessageNotice = (
const QString &)section[
"ColorMessageNotice"];
742 this->idgamesURL = (
const QString &)section[
"IdgamesApiURL"];
743 this->maxConcurrentSiteDownloads = section[
"MaxConcurrentSiteDownloads"];
744 this->maxConcurrentWadDownloads = section[
"MaxConcurrentWadDownloads"];
745 this->targetDirectory = (
const QString &)section[
"TargetDirectory"];
748 this->searchURLs.clear();
749 QStringList urlList = section[
"SearchURLs"].valueString().split(
";", Qt::SkipEmptyParts);
750 for (
const QString &url : urlList)
752 this->searchURLs << QUrl::fromPercentEncoding(url.toUtf8());
756 void DoomseekerConfig::WadseekerCfg::save(
IniSection §ion)
758 section[
"AlwaysUseDefaultSites"] = this->bAlwaysUseDefaultSites;
759 section[
"SearchInIdgames"] = this->bSearchInIdgames;
760 section[
"ColorMessageCriticalError"] = this->colorMessageCriticalError;
761 section[
"ColorMessageError"] = this->colorMessageError;
762 section[
"ColorMessageNotice"] = this->colorMessageNotice;
763 section[
"IdgamesApiURL"] = this->idgamesURL;
764 section[
"MaxConcurrentSiteDownloads"] = this->maxConcurrentSiteDownloads;
765 section[
"MaxConcurrentWadDownloads"] = this->maxConcurrentWadDownloads;
766 section[
"TargetDirectory"] = this->targetDirectory;
769 QStringList urlEncodedList;
770 for (
const QString &url : this->searchURLs)
772 urlEncodedList << QUrl::toPercentEncoding(url);
774 section[
"SearchURLs"] = urlEncodedList.join(
";");