mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-14 20:12:29 -04:00
-added new Preferences Dialog for Appearance
-moved some Settings from General to Appearance ( Language, Style, stylesheet -added checkbox for Start RetroShare with System start in GeneralDialog -moved Rsharesettings to Preferences folder to find bether -added new RSettings source -clean uped some old code stuff in MainWindow which is not more needed -replaced in MainWindow PreferencesWindows open function with new one. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@684 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
4e43cb2f09
commit
c84f34e916
28 changed files with 1779 additions and 490 deletions
95
retroshare-gui/src/gui/Preferences/rsettings.cpp
Normal file
95
retroshare-gui/src/gui/Preferences/rsettings.cpp
Normal file
|
@ -0,0 +1,95 @@
|
|||
/****************************************************************
|
||||
* This file is distributed under the following license:
|
||||
*
|
||||
* Copyright (c) 2008, crypton
|
||||
* Copyright (c) 2008, Matt Edman, Justin Hipple
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include <rshare.h>
|
||||
|
||||
#include "rsettings.h"
|
||||
|
||||
/** The file in which all settings will read and written. */
|
||||
#define SETTINGS_FILE (Rshare::dataDirectory() + "/RetroShare.conf")
|
||||
|
||||
/** Constructor */
|
||||
RSettings::RSettings(const QString settingsGroup)
|
||||
: QSettings(SETTINGS_FILE, QSettings::IniFormat)
|
||||
{
|
||||
if (!settingsGroup.isEmpty())
|
||||
beginGroup(settingsGroup);
|
||||
}
|
||||
|
||||
/** Returns the saved value associated with <b>key</b>. If no value has been
|
||||
* set, the default value is returned.
|
||||
* \sa setDefault
|
||||
*/
|
||||
QVariant
|
||||
RSettings::value(const QString &key, const QVariant &defaultVal) const
|
||||
{
|
||||
return QSettings::value(key, defaultVal.isNull() ? defaultValue(key)
|
||||
: defaultVal);
|
||||
}
|
||||
|
||||
/** Sets the value associated with <b>key</b> to <b>val</b>. */
|
||||
void
|
||||
RSettings::setValue(const QString &key, const QVariant &val)
|
||||
{
|
||||
if (val == defaultValue(key))
|
||||
QSettings::remove(key);
|
||||
else if (val != value(key))
|
||||
QSettings::setValue(key, val);
|
||||
}
|
||||
|
||||
/** Sets the default setting for <b>key</b> to <b>val</b>. */
|
||||
void
|
||||
RSettings::setDefault(const QString &key, const QVariant &val)
|
||||
{
|
||||
_defaults.insert(key, val);
|
||||
}
|
||||
|
||||
/** Returns the default setting value associated with <b>key</b>. If
|
||||
* <b>key</b> has no default value, then an empty QVariant is returned. */
|
||||
QVariant
|
||||
RSettings::defaultValue(const QString &key) const
|
||||
{
|
||||
if (_defaults.contains(key))
|
||||
return _defaults.value(key);
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
/** Resets all of Vidalia's settings. */
|
||||
void
|
||||
RSettings::reset()
|
||||
{
|
||||
/* Static method, so we have to create a QSettings object. */
|
||||
QSettings settings(SETTINGS_FILE, QSettings::IniFormat);
|
||||
settings.clear();
|
||||
}
|
||||
|
||||
/** Returns a map of all currently saved settings at the last appyl() point. */
|
||||
/*QMap<QString, QVariant>
|
||||
RSettings::allSettings() const
|
||||
{
|
||||
QMap<QString, QVariant> settings;
|
||||
foreach (QString key, allKeys()) {
|
||||
settings.insert(key, value(key));
|
||||
}
|
||||
return settings;
|
||||
}*/
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue