You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

118 lines
2.9 KiB
C

/**
*
* @file FITKAPPSettings.h
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-04-06
*
*/
#ifndef __FITKAPP_SETTINGS_H__
#define __FITKAPP_SETTINGS_H__
#include "FITKAppFrameworkAPI.h"
#include <QVariant>
#include <QString>
class QSettings;
namespace AppFrame
{
/**
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-04-06
*/
class FITKAppFrameworkAPI FITKAppSettings
{
public:
/**
* @brief Construct a new FITKAppSettings object
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-04-06
*/
explicit FITKAppSettings();
/**
* @brief Destroy the FITKAppSettings object
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-04-06
*/
virtual ~FITKAppSettings();
/**
* @brief
* @param[i] key
* @param[i] varient
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-04-06
*/
void setValue(const QString& key, const QVariant& varient);
template<typename T>
/**
* @brief
* @param[i] key
* @return T
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-04-06
*/
T getValue(const QString& key)
{
QVariant v = this->getVarient(key);
return v.value<T>();
}
/**
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-04-06
*/
virtual void read() = 0;
/**
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-04-06
*/
virtual void write();
/**
* @brief
* @param[i] k
* @return QVariant
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-04-06
*/
QVariant getVarient(const QString& k);
/**
* @brief
* @return QString
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-04-06
*/
virtual QString getWorkingDir();
/**
* @brief
* @param[i] wd
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-04-06
*/
void setWorkingDir(const QString& wd);
protected:
/**
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-04-06
*/
QString _appDir{};
/**
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-04-06
*/
QSettings* _settings{};
};
}
#endif