Store defaults in Config.

This commit is contained in:
Felix Geyer 2012-05-27 20:05:57 +02:00
parent 4a2ca8c7c8
commit 7194a3d7a8
2 changed files with 11 additions and 1 deletions

View File

@ -21,6 +21,11 @@
#include <QtCore/QSettings>
#include <QtGui/QDesktopServices>
QVariant Config::get(const QString& key)
{
return m_settings->value(key, m_defaults.value(key));
}
QVariant Config::get(const QString& key, const QVariant& defaultValue)
{
return m_settings->value(key, defaultValue);
@ -61,6 +66,9 @@ Config::Config()
userPath += "keepassx2.ini";
m_settings.reset(new QSettings(userPath, QSettings::IniFormat));
m_defaults.insert("security/clearclipboard", true);
m_defaults.insert("security/clearclipboardtimeout", 10);
}
Config* config()

View File

@ -26,13 +26,15 @@ class QSettings;
class Config
{
public:
QVariant get(const QString& key, const QVariant& defaultValue = QVariant());
QVariant get(const QString& key);
QVariant get(const QString& key, const QVariant& defaultValue);
void set(const QString& key, const QVariant& value);
private:
Config();
QScopedPointer<QSettings> m_settings;
QHash<QString, QVariant> m_defaults;
Q_DISABLE_COPY(Config)