From 2e1e0c77eef98fcc04d406c090d0ff3f83f04433 Mon Sep 17 00:00:00 2001 From: Anmol Gautam Date: Sun, 24 Jun 2018 00:25:29 +0530 Subject: [PATCH] Added documentation for Settings API --- .../plugins/qml/api/settings/qmlsettings.cpp | 28 +++++++++++++++++++ .../plugins/qml/api/settings/qmlsettings.h | 8 ++++++ 2 files changed, 36 insertions(+) diff --git a/src/lib/plugins/qml/api/settings/qmlsettings.cpp b/src/lib/plugins/qml/api/settings/qmlsettings.cpp index 3ef529937..55bd648f1 100644 --- a/src/lib/plugins/qml/api/settings/qmlsettings.cpp +++ b/src/lib/plugins/qml/api/settings/qmlsettings.cpp @@ -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) { diff --git a/src/lib/plugins/qml/api/settings/qmlsettings.h b/src/lib/plugins/qml/api/settings/qmlsettings.h index 48c15a800..8e3e05591 100644 --- a/src/lib/plugins/qml/api/settings/qmlsettings.h +++ b/src/lib/plugins/qml/api/settings/qmlsettings.h @@ -20,9 +20,17 @@ #include #include +/** + * @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: