twainui添加依赖文件

This commit is contained in:
yangjiaxuan 2023-05-20 19:43:37 +08:00
parent d6d15811b8
commit c1c4d0734c
4 changed files with 114 additions and 0 deletions

View File

@ -0,0 +1,20 @@
#include "HGUIGlobal.h"
#include "base/HGDef.h"
#include "base/HGInc.h"
#include "base/HGUtility.h"
QString getStdFileName(const QString &fileName)
{
char result[512] = {0};
HGBase_StandardiseFileName(fileName.toStdString().c_str(), result, 512);
return result;
}
std::string getStdString(const QString &str)
{
#ifdef HG_CMP_MSC
return str.toLocal8Bit().data();
#else
return str.toStdString();
#endif
}

View File

@ -0,0 +1,10 @@
#ifndef __HGUIGLOBAL_H__
#define __HGUIGLOBAL_H__
#include <QString>
QString getStdFileName(const QString &fileName);
std::string getStdString(const QString &str);
#endif /* __HGUIGLOBAL_H__ */

View File

@ -0,0 +1,70 @@
#include "app_cfg.h"
#include "base/HGDef.h"
#include "base/HGInc.h"
#include "base/HGUtility.h"
#include "base/HGIni.h"
#include "HGUIGlobal.h"
#include "HGString.h"
QString getCfgValue(const char *appName, const char *key, const QString &def)
{
HGChar cfgPath[512];
HGBase_GetConfigPath(cfgPath, 512);
strcat(cfgPath, "config.ini");
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);
strcat(cfgPath, "config.ini");
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);
strcat(cfgPath, "config.ini");
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);
HGBase_CreateDir(cfgPath);
strcat(cfgPath, "config.ini");
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);
HGBase_CreateDir(cfgPath);
strcat(cfgPath, "config.ini");
HGBase_SetProfileInt(cfgPath, appName, key, value);
}
void saveCfgValue(const char *appName, const char *key, bool value)
{
HGChar cfgPath[512];
HGBase_GetConfigPath(cfgPath, 512);
HGBase_CreateDir(cfgPath);
strcat(cfgPath, "config.ini");
HGBase_SetProfileInt(cfgPath, appName, key, (HGInt)value);
}

14
modules/twainui/app_cfg.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef __APP_CFG_H__
#define __APP_CFG_H__
#include <QString>
QString getCfgValue(const char *appName, const char *key, const QString &def);
int getCfgValue(const char *appName, const char *key, int def);
bool getCfgValue(const char *appName, const char *key, bool def);
void saveCfgValue(const char *appName, const char *key, const QString &value);
void saveCfgValue(const char *appName, const char *key, int value);
void saveCfgValue(const char *appName, const char *key, bool value);
#endif /* __APP_CFG_H__ */