mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
Added documentation for Settings API
This commit is contained in:
parent
c8a1bad5af
commit
2e1e0c77ee
@ -26,6 +26,13 @@ QmlSettings::QmlSettings(QObject *parent)
|
||||
m_settingsPath = DataPaths::currentProfilePath() + QL1S("/extensions");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the value for a given key.
|
||||
* @param A JavaScript object containing
|
||||
* - key: QString representing the key
|
||||
* - value: QVariant representing the value for the key
|
||||
* @return true if value is set, else false
|
||||
*/
|
||||
bool QmlSettings::setValue(const QVariantMap &map)
|
||||
{
|
||||
if (!m_settings) {
|
||||
@ -42,6 +49,13 @@ bool QmlSettings::setValue(const QVariantMap &map)
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the value for a given key.
|
||||
* @param A JavaScript object containing
|
||||
* - key: QString representing the key
|
||||
* - defaultValue: QVariant representing the default value for the key
|
||||
* @return QVariant representing value
|
||||
*/
|
||||
QVariant QmlSettings::value(const QVariantMap &map)
|
||||
{
|
||||
if (!m_settings) {
|
||||
@ -58,6 +72,11 @@ QVariant QmlSettings::value(const QVariantMap &map)
|
||||
return m_settings->value(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks if a given key exists.
|
||||
* @param QString representing the key
|
||||
* @return true if key exists, else false
|
||||
*/
|
||||
bool QmlSettings::contains(const QString &key)
|
||||
{
|
||||
if (!m_settings) {
|
||||
@ -67,6 +86,11 @@ bool QmlSettings::contains(const QString &key)
|
||||
return m_settings->contains(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Removes the given key-value from the settings.
|
||||
* @param QString representing the key
|
||||
* @return true if key-value pair is removed, else false
|
||||
*/
|
||||
bool QmlSettings::remove(const QString &key)
|
||||
{
|
||||
if (!m_settings) {
|
||||
@ -77,6 +101,10 @@ bool QmlSettings::remove(const QString &key)
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief syncs the settings
|
||||
* @return true if success, else false
|
||||
*/
|
||||
bool QmlSettings::sync()
|
||||
{
|
||||
if (!m_settings) {
|
||||
|
@ -20,9 +20,17 @@
|
||||
#include <QObject>
|
||||
#include <QSettings>
|
||||
|
||||
/**
|
||||
* @brief The class exposing Settings API to QML
|
||||
*/
|
||||
class QmlSettings : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
/**
|
||||
* @brief name of the folder in which settings.ini file is located
|
||||
* on the standard extension path.
|
||||
*/
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user