From cb7ef360f564b1e6b2e7ba9d25cff2ce57197011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Ker=C3=A4nen?= Date: Wed, 8 Jan 2014 11:04:07 +0200 Subject: [PATCH] Client|Log: Resetting Log filter and alert settings to defaults --- doomsday/client/include/clientapp.h | 1 + doomsday/client/include/settingsregister.h | 3 +++ doomsday/client/src/clientapp.cpp | 20 +++++++++++++++++-- .../src/ui/dialogs/logsettingsdialog.cpp | 4 ++-- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/doomsday/client/include/clientapp.h b/doomsday/client/include/clientapp.h index b8947b1a8a..4824707bed 100644 --- a/doomsday/client/include/clientapp.h +++ b/doomsday/client/include/clientapp.h @@ -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(); diff --git a/doomsday/client/include/settingsregister.h b/doomsday/client/include/settingsregister.h index 48980e29d8..0b1006ad3c 100644 --- a/doomsday/client/include/settingsregister.h +++ b/doomsday/client/include/settingsregister.h @@ -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). diff --git a/doomsday/client/src/clientapp.cpp b/doomsday/client/src/clientapp.cpp index 461ac004bd..490e6a5cac 100644 --- a/doomsday/client/src/clientapp.cpp +++ b/doomsday/client/src/clientapp.cpp @@ -127,6 +127,7 @@ DENG2_PIMPL(ClientApp) { QScopedPointer updater; SettingsRegister audioSettings; + SettingsRegister logSettings; QMenuBar *menuBar; InputSystem *inputSys; QScopedPointer widgetActions; @@ -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. @@ -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. @@ -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; diff --git a/doomsday/client/src/ui/dialogs/logsettingsdialog.cpp b/doomsday/client/src/ui/dialogs/logsettingsdialog.cpp index 27aa4efb64..a4572e614a 100644 --- a/doomsday/client/src/ui/dialogs/logsettingsdialog.cpp +++ b/doomsday/client/src/ui/dialogs/logsettingsdialog.cpp @@ -21,8 +21,7 @@ #include "ui/widgets/variabletogglewidget.h" #include "ui/widgets/foldpanelwidget.h" #include "SignalAction" - -#include +#include "clientapp.h" using namespace de; @@ -245,6 +244,7 @@ LogSettingsDialog::LogSettingsDialog(String const &name) void LogSettingsDialog::resetToDefaults() { + ClientApp::logSettings().resetToDefaults(); } void LogSettingsDialog::updateLogFilter()