-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfig.h
More file actions
79 lines (57 loc) · 1.45 KB
/
config.h
File metadata and controls
79 lines (57 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* @Description: 配置文件读取
* @Author: taowentao
* @Date: 2019-01-14 13:45:22
* @LastEditors: taowentao
* @LastEditTime: 2019-01-17 17:39:03
*/
#ifndef CONFIG_H
#define CONFIG_H
#include <string>
#include <unordered_map>
#include <vector>
#include <QColor>
#include <QRgb>
//调试消息等级
namespace INFOLEVEL
{
}
class Config
{
public:
Config();
~Config();
//从字符串读取配置
bool LoadFromString(const std::string &str);
private:
//检查正确性
bool check();
//处理一行,返回false停止
bool handleline(const std::string &line);
public:
//初始化
static bool Init(const std::string &cf = "config.ini", bool show=false);
static Config *GetInstance();
//保存
static int Save(const std::string &cf = "config.ini");
public:
//充电颜色
QColor color_charging=QColor(0xaf,0xff,0xaf,250);
//使用电池的颜色
QColor color_us_bt=QColor(0xff,0xff,0xff,250);
//用电池时字体颜色
QColor color_font_u=QColor(0x00,0x00,0x00,0xff);
//用充电时字体颜色
QColor color_font_c=QColor(0x00,0x00,0x00,0xff);
//背景不透明度
// unsigned char background_transparency=0;
//其它配置项,key都会变成小写
std::unordered_map<std::string, std::string> kvmap;
//显示调试消息等级
int infolevel = 0;
private:
static Config *is_;
public:
static int CleanUp();
};
#endif // CONFIG_H