File indexing completed on 2025-02-16 04:25:46
0001 #pragma once 0002 #include <QObject> 0003 #include <QString> 0004 #include <QVariant> 0005 #include "mauiman_export.h" 0006 0007 class QSettings; 0008 0009 namespace MauiMan 0010 { 0011 0012 /** 0013 * @brief The SettingsStore class 0014 * Allows to store and read settings for MauiMan from the local conf file. 0015 */ 0016 class MAUIMAN_EXPORT SettingsStore : public QObject 0017 { 0018 Q_OBJECT 0019 public: 0020 0021 /** 0022 * @brief SettingsStore 0023 * @param parent 0024 */ 0025 explicit SettingsStore(QObject *parent = nullptr); 0026 ~SettingsStore(); 0027 0028 /** 0029 * @brief Load the value of a conf entry, with a possible default value 0030 * @param key the key name of the value 0031 * @param defaultValue the default fallback value in case the value with the given key does not exists 0032 * @return 0033 */ 0034 QVariant load(const QString &key, const QVariant &defaultValue); 0035 0036 /** 0037 * @brief Save a conf value entry to the local file 0038 * @param key the key name of the value 0039 * @param value the entry value 0040 */ 0041 void save(const QString &key, const QVariant &value); 0042 0043 /** 0044 * @brief Set up the module section to write to 0045 * @param module the module name 0046 */ 0047 void beginModule(const QString &module); 0048 0049 /** 0050 * @brief Finish writing or reading from a module section. 0051 */ 0052 void endModule(); 0053 0054 private: 0055 QSettings *m_settings; 0056 }; 0057 } 0058