Skip to content

Commit

Permalink
Client|Log: Resetting Log filter and alert settings to defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jan 8, 2014
1 parent 263ff46 commit cb7ef36
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions doomsday/client/include/clientapp.h
Expand Up @@ -64,6 +64,7 @@ class ClientApp : public de::GuiApp
public:
static ClientApp &app();
static Updater &updater();
static SettingsRegister &logSettings();
static SettingsRegister &audioSettings(); ///< @todo Belongs in AudioSystem.
static ServerLink &serverLink();
static InputSystem &inputSystem();
Expand Down
3 changes: 3 additions & 0 deletions doomsday/client/include/settingsregister.h
Expand Up @@ -74,6 +74,9 @@ class SettingsRegister
/**
* Defines a new setting in the profile.
*
* The default values of Config variables are taken from Config (so it must already
* be initialized).
*
* @param type Type of setting.
* @param settingName Name of the setting.
* @param defaultValue Default value of the setting (for cvars).
Expand Down
20 changes: 18 additions & 2 deletions doomsday/client/src/clientapp.cpp
Expand Up @@ -127,6 +127,7 @@ DENG2_PIMPL(ClientApp)
{
QScopedPointer<Updater> updater;
SettingsRegister audioSettings;
SettingsRegister logSettings;
QMenuBar *menuBar;
InputSystem *inputSys;
QScopedPointer<WidgetActions> widgetActions;
Expand Down Expand Up @@ -240,7 +241,17 @@ DENG2_PIMPL(ClientApp)

void initSettings()
{
typedef SettingsRegister SReg;
typedef SettingsRegister SReg; // convenience

// Log filter and alert settings.
for(int i = LogEntry::FirstDomainBit; i <= LogEntry::LastDomainBit; ++i)
{
String const name = LogFilter::domainRecordName(LogEntry::Context(1 << i));
logSettings
.define(SReg::ConfigVariable, String("log.filter.%1.minLevel").arg(name))
.define(SReg::ConfigVariable, String("log.filter.%1.allowDev").arg(name))
.define(SReg::ConfigVariable, String("alert.%1").arg(name));
}

/// @todo These belong in their respective subsystems.

Expand Down Expand Up @@ -332,7 +343,7 @@ void ClientApp::initialize()

initSubsystems(); // loads Config

// Set up the log alerts.
// Set up the log alerts (observes Config variables).
d->logAlarm.alertMask.init();

// Create the user's configurations and settings folder, if it doesn't exist.
Expand Down Expand Up @@ -439,6 +450,11 @@ Updater &ClientApp::updater()
return *app().d->updater;
}

SettingsRegister &ClientApp::logSettings()
{
return app().d->logSettings;
}

SettingsRegister &ClientApp::audioSettings()
{
return app().d->audioSettings;
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/ui/dialogs/logsettingsdialog.cpp
Expand Up @@ -21,8 +21,7 @@
#include "ui/widgets/variabletogglewidget.h"
#include "ui/widgets/foldpanelwidget.h"
#include "SignalAction"

#include <de/App>
#include "clientapp.h"

using namespace de;

Expand Down Expand Up @@ -245,6 +244,7 @@ LogSettingsDialog::LogSettingsDialog(String const &name)

void LogSettingsDialog::resetToDefaults()
{
ClientApp::logSettings().resetToDefaults();
}

void LogSettingsDialog::updateLogFilter()
Expand Down

0 comments on commit cb7ef36

Please sign in to comment.