vidaliasettings.h

Go to the documentation of this file.
00001 /****************************************************************
00002  *  Vidalia is distributed under the following license:
00003  *
00004  *  Copyright (C) 2006,  Matt Edman, Justin Hipple
00005  *
00006  *  This program is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU General Public License
00008  *  as published by the Free Software Foundation; either version 2
00009  *  of the License, or (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, 
00019  *  Boston, MA  02110-1301, USA.
00020  ****************************************************************/
00021 
00022 /** 
00023  * \file vidaliasettings.h
00024  * \version $Id: vidaliasettings.h 1680 2007-03-19 02:42:30Z edmanm $
00025  * \brief General Vidalia settings, such as language and interface style
00026  */
00027 
00028 #ifndef _VIDALIASETTINGS_H
00029 #define _VIDALIASETTINGS_H
00030 
00031 #include <QHash>
00032 #include <QSettings>
00033 #include <control/logevent.h>
00034 
00035 
00036 /** Handles saving and restoring Vidalia's settings, such as the
00037  * location of Tor, the control port, etc.
00038  *
00039  * NOTE: Qt 4.1 documentation states that constructing a QSettings object is
00040  * "very fast", so we shouldn't need to create a global instance of this
00041  * class.
00042  */
00043 class VidaliaSettings : public QSettings
00044 {
00045   
00046 public:
00047   /** Default constructor. */
00048   VidaliaSettings();
00049 
00050   /** Resets all of Vidalia's settings. */
00051   static void reset();
00052   
00053   /** Sets the default value of <b>key</b> to be <b>val</b>. */
00054   void setDefault(QString key, QVariant val);
00055   /** Returns the default value for <b>key</b>. */
00056   QVariant defaultValue(QString key);
00057   /** Save <b>val</b> to the configuration file for the setting <b>key</b>, if
00058    * <b>val</b> is different than <b>key</b>'s current value. */
00059   void setValue(QString key, QVariant val);
00060   /** Returns the value for <b>key</b>. If no value is currently saved, then
00061    * the default value for <b>key</b> will be returned. */
00062   QVariant value(QString key);
00063   /** Returns the value for <b>key</b>. If no value is currently saved, then
00064    * <b>defaultValue</b> will be returned. */
00065   QVariant value(QString key, QVariant defaultValue);
00066   
00067   /** Gets the currently preferred language code for Vidalia. */
00068   QString getLanguageCode();
00069   /** Saves the preferred language code. */
00070   void setLanguageCode(QString languageCode);
00071  
00072   /** Gets the interface style key (e.g., "windows", "motif", etc.) */
00073   QString getInterfaceStyle();
00074   /** Sets the interface style key. */
00075   void setInterfaceStyle(QString styleKey);
00076   
00077   /** Returns true if Vidalia should start Tor when it starts. */
00078   bool runTorAtStart();
00079   /** Set whether to run Tor when Vidalia starts. */
00080   void setRunTorAtStart(bool run);
00081 
00082   /** Returns true if Vidalia's main window should be visible when the
00083    * application starts. */
00084   bool showMainWindowAtStart();
00085   /** Sets whether to show Vidalia's main window when the application starts. */
00086   void setShowMainWindowAtStart(bool show);
00087   
00088   /** Returns true if Vidalia should start on system boot. */
00089   bool runVidaliaOnBoot();
00090   /** Set whether to run Vidalia on system boot. */
00091   void setRunVidaliaOnBoot(bool run);
00092 
00093 private:
00094   QHash<QString,QVariant> _defaults;
00095 };
00096 
00097 #endif
00098 

Generated on Wed Sep 5 15:49:28 2007 for Vidalia by  doxygen 1.5.3