2022-05-03 10:25:52 +00:00
|
|
|
|
#include "app_cfg.h"
|
|
|
|
|
#include "base/HGDef.h"
|
|
|
|
|
#include "base/HGInc.h"
|
|
|
|
|
#include "base/HGUtility.h"
|
|
|
|
|
#include "HGUIGlobal.h"
|
2022-05-18 03:39:16 +00:00
|
|
|
|
#include "HGString.h"
|
2022-05-03 10:25:52 +00:00
|
|
|
|
|
|
|
|
|
QString getCfgValue(const char *appName, const char *key, const QString &def)
|
|
|
|
|
{
|
|
|
|
|
HGChar cfgPath[512];
|
|
|
|
|
HGBase_GetConfigPath(cfgPath, 512);
|
2022-05-17 03:59:09 +00:00
|
|
|
|
strcat(cfgPath, "config.ini");
|
2022-05-03 10:25:52 +00:00
|
|
|
|
|
|
|
|
|
HGChar value[512] = {0};
|
|
|
|
|
HGBase_GetProfileString(cfgPath, appName, key, getStdString(def).c_str(), value, 512);
|
|
|
|
|
return StdStringToUtf8(value).c_str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int getCfgValue(const char *appName, const char *key, int def)
|
|
|
|
|
{
|
|
|
|
|
HGChar cfgPath[512];
|
|
|
|
|
HGBase_GetConfigPath(cfgPath, 512);
|
2022-05-17 03:59:09 +00:00
|
|
|
|
strcat(cfgPath, "config.ini");
|
2022-05-03 10:25:52 +00:00
|
|
|
|
|
|
|
|
|
HGInt value = 0;
|
|
|
|
|
HGBase_GetProfileInt(cfgPath, appName, key, def, &value);
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool getCfgValue(const char *appName, const char *key, bool def)
|
|
|
|
|
{
|
|
|
|
|
HGChar cfgPath[512];
|
|
|
|
|
HGBase_GetConfigPath(cfgPath, 512);
|
2022-05-17 03:59:09 +00:00
|
|
|
|
strcat(cfgPath, "config.ini");
|
2022-05-03 10:25:52 +00:00
|
|
|
|
|
|
|
|
|
HGInt value = 0;
|
|
|
|
|
HGBase_GetProfileInt(cfgPath, appName, key, (HGInt)def, &value);
|
|
|
|
|
return (bool)value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void saveCfgValue(const char *appName, const char *key, const QString &value)
|
|
|
|
|
{
|
|
|
|
|
HGChar cfgPath[512];
|
|
|
|
|
HGBase_GetConfigPath(cfgPath, 512);
|
2022-05-14 08:38:09 +00:00
|
|
|
|
HGBase_CreateDir(cfgPath);
|
2022-05-17 03:59:09 +00:00
|
|
|
|
strcat(cfgPath, "config.ini");
|
2022-05-03 10:25:52 +00:00
|
|
|
|
|
|
|
|
|
HGBase_SetProfileString(cfgPath, appName, key, getStdString(value).c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void saveCfgValue(const char *appName, const char *key, int value)
|
|
|
|
|
{
|
|
|
|
|
HGChar cfgPath[512];
|
|
|
|
|
HGBase_GetConfigPath(cfgPath, 512);
|
2022-05-14 08:38:09 +00:00
|
|
|
|
HGBase_CreateDir(cfgPath);
|
2022-05-17 03:59:09 +00:00
|
|
|
|
strcat(cfgPath, "config.ini");
|
2022-05-03 10:25:52 +00:00
|
|
|
|
|
|
|
|
|
HGBase_SetProfileInt(cfgPath, appName, key, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void saveCfgValue(const char *appName, const char *key, bool value)
|
|
|
|
|
{
|
|
|
|
|
HGChar cfgPath[512];
|
|
|
|
|
HGBase_GetConfigPath(cfgPath, 512);
|
2022-05-14 08:38:09 +00:00
|
|
|
|
HGBase_CreateDir(cfgPath);
|
2022-05-17 03:59:09 +00:00
|
|
|
|
strcat(cfgPath, "config.ini");
|
2022-05-03 10:25:52 +00:00
|
|
|
|
|
|
|
|
|
HGBase_SetProfileInt(cfgPath, appName, key, (HGInt)value);
|
|
|
|
|
}
|