Skip to content

Commit

Permalink
Refactor|App|Client: More convenient method for accessing a Config va…
Browse files Browse the repository at this point in the history
…riable
  • Loading branch information
skyjake committed Oct 19, 2014
1 parent 70488ff commit bc1591c
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion doomsday/client/src/ui/dialogs/inputsettingsdialog.cpp
Expand Up @@ -49,7 +49,7 @@ DENG_GUI_PIMPL(InputSettingsDialog)
{
ScrollAreaWidget &area = self.area();

area.add(syncMouse = new VariableToggleWidget(App::config()["input.mouse.syncSensitivity"]));
area.add(syncMouse = new VariableToggleWidget(App::config("input.mouse.syncSensitivity")));
area.add(syncInput = new CVarToggleWidget("input-sharp"));
area.add(mouseSensiX = new CVarSliderWidget("input-mouse-x-scale"));
area.add(mouseSensiY = new CVarSliderWidget("input-mouse-y-scale"));
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/ui/dialogs/logsettingsdialog.cpp
Expand Up @@ -70,7 +70,7 @@ DENG2_PIMPL(LogSettingsDialog)

self.area().add(separately =
new VariableToggleWidget(tr("Filter by Subsystem"),
App::config()["log.filterBySubsystem"]));
App::config("log.filterBySubsystem")));

levels << new ChoiceItem( tr("1 - X.Verbose"), LogEntry::XVerbose)
<< new ChoiceItem( tr("2 - Verbose"), LogEntry::Verbose )
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/ui/dialogs/networksettingsdialog.cpp
Expand Up @@ -41,7 +41,7 @@ DENG_GUI_PIMPL(NetworkSettingsDialog)
{
ScrollAreaWidget &area = self.area();

area.add(masterApi = new VariableLineEditWidget(App::config()["masterServer.apiUrl"]));
area.add(masterApi = new VariableLineEditWidget(App::config("masterServer.apiUrl")));

// Developer options.
self.add(devPopup = new GridPopupWidget);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/ui/dialogs/vrsettingsdialog.cpp
Expand Up @@ -77,7 +77,7 @@ DENG_GUI_PIMPL(VRSettingsDialog)

if(vrCfg().oculusRift().isReady())
{
area.add(riftDensity = new VariableSliderWidget(App::config()["vr.oculusRift.pixelDensity"],
area.add(riftDensity = new VariableSliderWidget(App::config("vr.oculusRift.pixelDensity"),
Ranged(0.5, 1.0), .01));
riftDensity->setPrecision(2);

Expand Down
10 changes: 5 additions & 5 deletions doomsday/client/src/ui/widgets/consolewidget.cpp
Expand Up @@ -89,12 +89,12 @@ DENG2_OBSERVES(Variable, Change)

grabWidth = style().rules().rule("gap").valuei();

App::config()["console.script"].audienceForChange() += this;
App::config("console.script").audienceForChange() += this;
}

~Instance()
{
App::config()["console.script"].audienceForChange() -= this;
App::config("console.script").audienceForChange() -= this;

releaseRef(horizShift);
releaseRef(width);
Expand Down Expand Up @@ -271,7 +271,7 @@ static PopupWidget *advancedFeaturesPopup()
"the OS clipboard."))
<< new ui::Item(ui::Item::Separator)
<< new ui::VariableToggleItem(QObject::tr("Doomsday Script"),
App::config()["console.script"])
App::config("console.script"))
<< new ui::Item(ui::Item::Annotation,
QObject::tr("The command prompt becomes an interactive script "
"process with access to all the runtime modules."));
Expand Down Expand Up @@ -326,8 +326,8 @@ ConsoleWidget::ConsoleWidget() : GuiWidget("console"), d(new Instance(this))
<< new ui::ActionItem(tr("Clear Log"), new CommandAction("clear"))
<< new ui::ActionItem(tr("Show Full Log"), new SignalAction(this, SLOT(showFullLog())))
<< new ui::ActionItem(tr("Scroll to Bottom"), new SignalAction(d->log, SLOT(scrollToBottom())))
<< new ui::VariableToggleItem(tr("Go to Bottom on Enter"), App::config()["console.snap"])
<< new ui::VariableToggleItem(tr("Show Metadata"), App::config()["log.showMetadata"])
<< new ui::VariableToggleItem(tr("Go to Bottom on Enter"), App::config("console.snap"))
<< new ui::VariableToggleItem(tr("Show Metadata"), App::config("log.showMetadata"))
<< new ui::Item(ui::Item::Annotation, tr("Time and subsystem of each entry is printed."))
<< new ui::Item(ui::Item::Separator)
<< new ui::Item(ui::Item::Separator, tr("Behavior"))
Expand Down
4 changes: 2 additions & 2 deletions doomsday/libappfw/src/vr/oculusrift.cpp
Expand Up @@ -226,7 +226,7 @@ DENG2_PIMPL(OculusRift)
// If there is no Oculus Rift connected, do nothing.
if(!hmd) return;

App::config()["vr.oculusRift.pixelDensity"].audienceForChange() += this;
App::config("vr.oculusRift.pixelDensity").audienceForChange() += this;

DENG2_GUARD(this);

Expand Down Expand Up @@ -349,7 +349,7 @@ DENG2_PIMPL(OculusRift)

LOG_GL_MSG("Stopping Oculus Rift rendering");

App::config()["vr.oculusRift.pixelDensity"].audienceForChange() -= this;
App::config("vr.oculusRift.pixelDensity").audienceForChange() -= this;

if(hmd)
{
Expand Down
9 changes: 9 additions & 0 deletions doomsday/libcore/include/de/core/app.h
Expand Up @@ -320,6 +320,15 @@ class DENG2_PUBLIC App : DENG2_OBSERVES(Clock, TimeChange)
*/
static Config &config();

/**
* Returns a configuration variable.
*
* @param name Name of the variable.
*
* @return Variable.
*/
static Variable &config(String const &name);

/**
* Returns the Unix system-level configuration preferences.
*/
Expand Down
5 changes: 5 additions & 0 deletions doomsday/libcore/src/core/app.cpp
Expand Up @@ -777,6 +777,11 @@ Config &App::config()
return *DENG2_APP->d->config;
}

Variable &App::config(String const &name)
{
return config()[name];
}

UnixInfo &App::unixInfo()
{
return *DENG2_APP->d->unixInfo;
Expand Down

0 comments on commit bc1591c

Please sign in to comment.