This repository was archived by the owner on Mar 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathappsettings.h
More file actions
65 lines (52 loc) · 1.37 KB
/
Copy pathappsettings.h
File metadata and controls
65 lines (52 loc) · 1.37 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
//
// SmartServer
// Copyright (C) 2021 АО "Нефтеавтоматика"
//
// Разработчик
// Ананьев А.А. <Ananev-AA@nefteavtomatika.ru>
//
#ifndef APPSETTINGS_H
#define APPSETTINGS_H
#include <map>
#include <mutex>
#include <QSettings>
struct Setting
{
const char* Name;
QVariant DefaultValue;
};
///
/// \brief Настройки приложения
///
class AppSettings
{
public:
static const Setting SmartCardReader;
static const Setting SerialPortSettings;
static const Setting ModbusAddressType;
static const Setting ModbusStartAddress;
static const Setting ModbusBufferSize;
static const Setting ModbusServerAddress;
static const Setting ModbusServerRestartTimeout;
public:
static AppSettings* instance();
QVariant GetSetting(const Setting& setting);
void SetSetting(const Setting& setting, const QVariant& value);
private:
AppSettings() = default;
~AppSettings() = default;
AppSettings(AppSettings const&) = delete;
void operator=(AppSettings const&) = delete;
private:
static AppSettings& getInstance()
{
static AppSettings instance;
return instance;
}
QSettings settings;
std::mutex mutex;
std::map<QString, QVariant> variantSettings;
};
Q_DECLARE_OPAQUE_POINTER(AppSettings*)
Q_DECLARE_METATYPE(AppSettings*)
#endif // APPSETTINGS_H