[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r1979: Make VidaliaSettings inherit from VSettings instead of direc (in trunk: . src/config)
Author: edmanm
Date: 2007-10-09 23:37:44 -0400 (Tue, 09 Oct 2007)
New Revision: 1979
Modified:
trunk/
trunk/src/config/vidaliasettings.cpp
trunk/src/config/vidaliasettings.h
Log:
r2011@lysithea: edmanm | 2007-10-09 23:09:08 -0400
Make VidaliaSettings inherit from VSettings instead of directly from QSettings
and remove some duplicate code.
Property changes on: trunk
___________________________________________________________________
svk:merge ticket from /local/vidalia/trunk [r2011] on dc66be73-d13e-47ba-a267-8dc7cda68c65
Modified: trunk/src/config/vidaliasettings.cpp
===================================================================
--- trunk/src/config/vidaliasettings.cpp 2007-10-10 03:37:12 UTC (rev 1978)
+++ trunk/src/config/vidaliasettings.cpp 2007-10-10 03:37:44 UTC (rev 1979)
@@ -37,7 +37,6 @@
#include <util/win32.h>
#endif
-
#define SETTING_LANGUAGE "LanguageCode"
#define SETTING_STYLE "InterfaceStyle"
#define SETTING_RUN_TOR_AT_START "RunTorAtStart"
@@ -49,13 +48,9 @@
#define VIDALIA_REG_KEY "Vidalia"
#endif
-/** The location of Vidalia's settings and configuration file. */
-#define SETTINGS_FILE (Vidalia::dataDirectory() + "/vidalia.conf")
-
/** Default Constructor */
VidaliaSettings::VidaliaSettings()
-: QSettings(SETTINGS_FILE, QSettings::IniFormat)
{
#if defined(Q_WS_MAC)
setDefault(SETTING_STYLE, "macintosh (aqua)");
@@ -79,57 +74,6 @@
setDefault(SETTING_SHOW_MAINWINDOW_AT_START, true);
}
-/** Sets the default value of <b>key</b> to be <b>val</b>. */
-void
-VidaliaSettings::setDefault(QString key, QVariant val)
-{
- _defaults.insert(key, val);
-}
-
-/** Returns the default value for <b>key</b>. */
-QVariant
-VidaliaSettings::defaultValue(QString key)
-{
- if (_defaults.contains(key)) {
- return _defaults.value(key);
- }
- return QVariant();
-}
-
-/** Save <b>val</b> to the configuration file for the setting <b>key</b>, if
- * <b>val</b> is different than <b>key</b>'s current value. */
-void
-VidaliaSettings::setValue(QString key, QVariant val)
-{
- if (value(key) != val) {
- QSettings::setValue(key, val);
- }
-}
-
-/** Returns the value for <b>key</b>. If no value is currently saved, then the
- * default value for <b>key</b> will be returned. */
-QVariant
-VidaliaSettings::value(QString key)
-{
- return value(key, defaultValue(key));
-}
-
-/** Returns the value for <b>key</b>. If no value is currently saved, then
- * <b>defaultValue</b> will be returned. */
-QVariant
-VidaliaSettings::value(QString key, QVariant defaultValue)
-{
- return QSettings::value(key, defaultValue);
-}
-
-/** Resets all of Vidalia's settings. */
-void
-VidaliaSettings::reset()
-{
- QSettings settings(SETTINGS_FILE, QSettings::IniFormat);
- settings.clear();
-}
-
/** Gets the currently preferred language code for Vidalia. */
QString
VidaliaSettings::getLanguageCode()
Modified: trunk/src/config/vidaliasettings.h
===================================================================
--- trunk/src/config/vidaliasettings.h 2007-10-10 03:37:12 UTC (rev 1978)
+++ trunk/src/config/vidaliasettings.h 2007-10-10 03:37:44 UTC (rev 1979)
@@ -28,9 +28,7 @@
#ifndef _VIDALIASETTINGS_H
#define _VIDALIASETTINGS_H
-#include <QHash>
-#include <QSettings>
-#include <control/logevent.h>
+#include "vsettings.h"
/** Handles saving and restoring Vidalia's settings, such as the
@@ -40,30 +38,13 @@
* "very fast", so we shouldn't need to create a global instance of this
* class.
*/
-class VidaliaSettings : public QSettings
+class VidaliaSettings : public VSettings
{
public:
/** Default constructor. */
VidaliaSettings();
- /** Resets all of Vidalia's settings. */
- static void reset();
-
- /** Sets the default value of <b>key</b> to be <b>val</b>. */
- void setDefault(QString key, QVariant val);
- /** Returns the default value for <b>key</b>. */
- QVariant defaultValue(QString key);
- /** Save <b>val</b> to the configuration file for the setting <b>key</b>, if
- * <b>val</b> is different than <b>key</b>'s current value. */
- void setValue(QString key, QVariant val);
- /** Returns the value for <b>key</b>. If no value is currently saved, then
- * the default value for <b>key</b> will be returned. */
- QVariant value(QString key);
- /** Returns the value for <b>key</b>. If no value is currently saved, then
- * <b>defaultValue</b> will be returned. */
- QVariant value(QString key, QVariant defaultValue);
-
/** Gets the currently preferred language code for Vidalia. */
QString getLanguageCode();
/** Saves the preferred language code. */
@@ -89,9 +70,6 @@
bool runVidaliaOnBoot();
/** Set whether to run Vidalia on system boot. */
void setRunVidaliaOnBoot(bool run);
-
-private:
- QHash<QString,QVariant> _defaults;
};
#endif