settings.h 1.18 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#ifndef EXTENSIONSYSTEM_SETTINGS_H
#define EXTENSIONSYSTEM_SETTINGS_H

#include <QtGlobal>
#include <QVariant>
#include <QString>
#include <QMutex>
#include <QSettings>
#include <QScopedPointer>
#include <QSharedPointer>

#ifdef EXTENSIONSYSTEM_LIBRARY
#define EXTENSIONSYSTEM_EXPORT Q_DECL_EXPORT
#else
#define EXTENSIONSYSTEM_EXPORT Q_DECL_IMPORT
#endif

namespace ExtensionSystem {

class EXTENSIONSYSTEM_EXPORT Settings
{
22 23 24
	friend class PluginManager;
	friend struct PluginManagerImpl;
	friend class KPlugin;
25 26
public:

27 28 29 30 31
	QVariant value(const QString & key, const QVariant & default_ = QVariant()) const;
	void setValue(const QString & key, const QVariant & value_);
	QString locationDirectory() const;
	QString settingsFilePath() const;
	void flush();
32

33
	~Settings();
34

35
protected:
36 37
	explicit Settings(const QString & pluginName_);
	void changeWorkingDirectory(const QString & workDirPath);
38 39

private:
40 41 42 43 44
	QString pluginName_;
	QString workDirPath_;
	QScopedPointer<QMutex> mutex_;
	QScopedPointer<QSettings> qsettings_;
	QString settingsFile_;
45 46
};

Alexander A. Maly's avatar
Alexander A. Maly committed
47
typedef QSharedPointer<Settings> SettingsPtr;
48
EXTENSIONSYSTEM_EXPORT QString defaultSettingsScope();
Alexander A. Maly's avatar
Alexander A. Maly committed
49

50 51 52
} // namespace ExtensionSystem

#endif // EXTENSIONSYSTEM_SETTINGS_H