Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Feb 5, 2017
1 parent f190db8 commit f6fec0a
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 51 deletions.
6 changes: 3 additions & 3 deletions doomsday/apps/client/src/configprofiles.cpp
Expand Up @@ -76,11 +76,11 @@ DENG2_PIMPL(ConfigProfiles)
case ConfigVariable:
if (!qstrcmp(val.typeName(), "QString"))
{
App::config()[name].set(TextValue(val.toString()));
Config::get(name).set(TextValue(val.toString()));
}
else
{
App::config()[name].set(NumberValue(val.toDouble()));
Config::get(name).set(NumberValue(val.toDouble()));
}
break;
}
Expand Down Expand Up @@ -268,7 +268,7 @@ DENG2_PIMPL(ConfigProfiles)
break;

case ConfigVariable: {
Value const &cfgValue = App::config()[st.name].value();
Value const &cfgValue = Config::get(st.name).value();
if (cfgValue.is<NumberValue>())
{
val = cfgValue.asNumber();
Expand Down
6 changes: 3 additions & 3 deletions doomsday/apps/client/src/ui/dialogs/logsettingsdialog.cpp
Expand Up @@ -127,21 +127,21 @@ DENG2_PIMPL(LogSettingsDialog)

// Minimum level for log entries.
parent->add(wgt.level =
new VariableChoiceWidget(App::config()[String("log.filter.%1.minLevel").arg(dom.name)]));
new VariableChoiceWidget(Config::get(String("log.filter.%1.minLevel").arg(dom.name))));
wgt.level->setItems(levels);
wgt.level->updateFromVariable();
QObject::connect(wgt.level, SIGNAL(selectionChangedByUser(uint)),
thisPublic, SLOT(updateLogFilter()));

// Developer messages?
parent->add(wgt.dev =
new VariableToggleWidget(tr("Dev"), App::config()[String("log.filter.%1.allowDev").arg(dom.name)]));
new VariableToggleWidget(tr("Dev"), Config::get(String("log.filter.%1.allowDev").arg(dom.name))));
QObject::connect(wgt.dev, SIGNAL(stateChangedByUser(ToggleWidget::ToggleState)),
thisPublic, SLOT(updateLogFilter()));

// Raise alerts?
parent->add(wgt.alert =
new VariableToggleWidget(tr("Alerts"), App::config()[String("alert.") + dom.name]));
new VariableToggleWidget(tr("Alerts"), Config::get(String("alert.") + dom.name)));
wgt.alert->setActiveValue(LogEntry::Warning);
wgt.alert->setInactiveValue(LogEntry::HighestLogLevel + 1);

Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/client/src/ui/home/gamecolumnwidget.cpp
Expand Up @@ -145,7 +145,7 @@ DENG_GUI_PIMPL(GameColumnWidget)

DoomsdayApp::games().audienceForReadiness() += this;
DoomsdayApp::gameProfiles().audienceForAddition() += this;
Config::get()["home.showUnplayableGames"].audienceForChange() += this;
Config::get("home.showUnplayableGames").audienceForChange() += this;
}

ui::Item const *findProfileItem(GameProfile const &profile) const
Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/client/src/ui/home/headerwidget.cpp
Expand Up @@ -68,7 +68,7 @@ DENG_GUI_PIMPL(HeaderWidget)

static Variable const &showDescriptionVar()
{
return Config::get()["home.showColumnDescription"];
return Config::get("home.showColumnDescription");
}
};

Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/client/src/ui/home/packagescolumnwidget.cpp
Expand Up @@ -40,7 +40,7 @@ using namespace de;

static PopupWidget *makePackageFoldersDialog()
{
Variable &pkgFolders = Config::get()["resource.packageFolder"];
Variable &pkgFolders = Config::get("resource.packageFolder");

auto *dlg = new DirectoryListDialog;
dlg->title().setFont("heading");
Expand Down
10 changes: 1 addition & 9 deletions doomsday/apps/client/src/ui/styledlogsinkformatter.cpp
Expand Up @@ -43,18 +43,10 @@ DENG2_PIMPL(StyledLogSinkFormatter)
if (observe)
{
showMetadata = App::config().getb(VAR_METADATA);
App::config()[VAR_METADATA].audienceForChange() += this;
Config::get(VAR_METADATA).audienceForChange() += this;
}
}

// ~Impl()
// {
// if (observe)
// {
// App::config()[VAR_METADATA].audienceForChange() -= this;
// }
// }

void variableValueChanged(Variable &, Value const &newValue)
{
showMetadata = newValue.isTrue();
Expand Down
Expand Up @@ -72,12 +72,12 @@ DENG_GUI_PIMPL(PackageContentOptionsWidget)

DictionaryValue &conf()
{
return Config::get()["fs.selectedPackages"].value<DictionaryValue>();
return Config::get("fs.selectedPackages").value<DictionaryValue>();
}

DictionaryValue const &conf() const
{
return Config::get()["fs.selectedPackages"].value<DictionaryValue>();
return Config::get("fs.selectedPackages").value<DictionaryValue>();
}

bool isSelected() const
Expand Down
54 changes: 25 additions & 29 deletions doomsday/apps/client/src/updater/updatersettings.cpp
Expand Up @@ -23,65 +23,61 @@
#include <QDateTime>
#include <QDesktopServices>
#include <de/Record>
#include <de/App>
#include <de/Config>
#include <de/TextValue>
#include <de/NumberValue>
#include <de/TimeValue>

using namespace de;

#define VAR_FREQUENCY "frequency"
#define VAR_CHANNEL "channel"
#define VAR_LAST_CHECKED "lastChecked"
#define VAR_ONLY_MANUAL "onlyManually"
#define VAR_DELETE "delete"
#define VAR_DOWNLOAD_PATH "downloadPath"
#define VAR_DELETE_PATH "deleteAtStartup"
#define VAR_AUTO_DOWNLOAD "autoDownload"
static String const VAR_FREQUENCY ("updater.frequency");
static String const VAR_CHANNEL ("updater.channel");
static String const VAR_LAST_CHECKED ("updater.lastChecked");
static String const VAR_ONLY_MANUAL ("updater.onlyManually");
static String const VAR_DELETE ("updater.delete");
static String const VAR_DOWNLOAD_PATH ("updater.downloadPath");
static String const VAR_DELETE_PATH ("updater.deleteAtStartup");
static String const VAR_AUTO_DOWNLOAD ("updater.autoDownload");

#define SUBREC_NAME "updater"
#define CONF(name) SUBREC_NAME "." name

#define SYMBOL_DEFAULT_DOWNLOAD "${DEFAULT}"
static String const SYMBOL_DEFAULT_DOWNLOAD("${DEFAULT}");

UpdaterSettings::UpdaterSettings()
{}

UpdaterSettings::Frequency UpdaterSettings::frequency() const
{
return Frequency(App::config().geti(CONF(VAR_FREQUENCY)));
return Frequency(Config::get().geti(VAR_FREQUENCY));
}

UpdaterSettings::Channel UpdaterSettings::channel() const
{
return Channel(App::config().geti(CONF(VAR_CHANNEL)));
return Channel(Config::get().geti(VAR_CHANNEL));
}

de::Time UpdaterSettings::lastCheckTime() const
{
// Note that the variable has only AllowTime as the mode.
return App::config().getAs<TimeValue>(CONF(VAR_LAST_CHECKED)).time();
return Config::get().getAs<TimeValue>(VAR_LAST_CHECKED).time();
}

bool UpdaterSettings::onlyCheckManually() const
{
return App::config().getb(CONF(VAR_ONLY_MANUAL));
return Config::get().getb(VAR_ONLY_MANUAL);
}

bool UpdaterSettings::autoDownload() const
{
return App::config().getb(CONF(VAR_AUTO_DOWNLOAD));
return Config::get().getb(VAR_AUTO_DOWNLOAD);
}

bool UpdaterSettings::deleteAfterUpdate() const
{
return App::config().getb(CONF(VAR_DELETE));
return Config::get().getb(VAR_DELETE);
}

de::NativePath UpdaterSettings::pathToDeleteAtStartup() const
{
de::NativePath p = App::config().gets(CONF(VAR_DELETE_PATH));
de::NativePath p = Config::get().gets(VAR_DELETE_PATH);
de::String ext = p.toString().fileNameExtension();
if (p.fileName().startsWith("doomsday") && (ext == ".exe" || ext == ".deb" || ext == ".dmg"))
{
Expand All @@ -98,7 +94,7 @@ bool UpdaterSettings::isDefaultDownloadPath() const

de::NativePath UpdaterSettings::downloadPath() const
{
de::NativePath dir = App::config().gets(CONF(VAR_DOWNLOAD_PATH));
de::NativePath dir = Config::get().gets(VAR_DOWNLOAD_PATH);
if (dir.toString() == SYMBOL_DEFAULT_DOWNLOAD)
{
dir = defaultDownloadPath();
Expand All @@ -112,37 +108,37 @@ void UpdaterSettings::setDownloadPath(de::NativePath downloadPath)
{
downloadPath = SYMBOL_DEFAULT_DOWNLOAD;
}
App::config().set(CONF(VAR_DOWNLOAD_PATH), downloadPath.toString());
Config::get().set(VAR_DOWNLOAD_PATH, downloadPath.toString());
}

void UpdaterSettings::setFrequency(UpdaterSettings::Frequency freq)
{
App::config().set(CONF(VAR_FREQUENCY), dint(freq));
Config::get().set(VAR_FREQUENCY, dint(freq));
}

void UpdaterSettings::setChannel(UpdaterSettings::Channel channel)
{
App::config().set(CONF(VAR_CHANNEL), dint(channel));
Config::get().set(VAR_CHANNEL, dint(channel));
}

void UpdaterSettings::setLastCheckTime(de::Time const &time)
{
App::config()[CONF(VAR_LAST_CHECKED)] = new TimeValue(time);
Config::get(VAR_LAST_CHECKED) = new TimeValue(time);
}

void UpdaterSettings::setOnlyCheckManually(bool onlyManually)
{
App::config().set(CONF(VAR_ONLY_MANUAL), onlyManually);
Config::get().set(VAR_ONLY_MANUAL, onlyManually);
}

void UpdaterSettings::setAutoDownload(bool autoDl)
{
App::config().set(CONF(VAR_AUTO_DOWNLOAD), autoDl);
Config::get().set(VAR_AUTO_DOWNLOAD, autoDl);
}

void UpdaterSettings::setDeleteAfterUpdate(bool deleteAfter)
{
App::config().set(CONF(VAR_DELETE), deleteAfter);
Config::get().set(VAR_DELETE, deleteAfter);
}

void UpdaterSettings::useDefaultDownloadPath()
Expand All @@ -152,7 +148,7 @@ void UpdaterSettings::useDefaultDownloadPath()

void UpdaterSettings::setPathToDeleteAtStartup(de::NativePath deletePath)
{
App::config().set(CONF(VAR_DELETE_PATH), deletePath.toString());
Config::get().set(VAR_DELETE_PATH, deletePath.toString());
}

de::NativePath UpdaterSettings::defaultDownloadPath()
Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/libdoomsday/src/console/cmd.cpp
Expand Up @@ -412,7 +412,7 @@ D_CMD(MappedConfigVariable)
auto const found = mappedConfigVariables.constFind(argv[0]);
DENG2_ASSERT(found != mappedConfigVariables.constEnd()); // mapping must be defined

Variable &var = App::config()[found.value()];
Variable &var = Config::get(found.value());

if (argc == 1)
{
Expand Down
2 changes: 1 addition & 1 deletion doomsday/sdk/libcore/src/filesys/packageloader.cpp
Expand Up @@ -309,7 +309,7 @@ DENG2_PIMPL(PackageLoader)
std::function<void (String const &)> callback) const
{
// Packages enabled/disabled for use.
DictionaryValue const &selPkgs = Config::get()["fs.selectedPackages"]
DictionaryValue const &selPkgs = Config::get("fs.selectedPackages")
.value<DictionaryValue>();

Record const &meta = Package::metadata(packageFile);
Expand Down

0 comments on commit f6fec0a

Please sign in to comment.