-
Notifications
You must be signed in to change notification settings - Fork 2
/
global.h
43 lines (33 loc) · 1.04 KB
/
global.h
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
#ifndef GLOBAL_H
#define GLOBAL_H
#include <QtGlobal>
#include <QVariant>
#include <atomic>
#include <mutex>
#define Q_DECLARE_STATIC_INSTANCE(classname)\
static classname *Instance(); \
Q_DISABLE_COPY(classname)\
friend struct QScopedPointerDeleter<classname>
#define Q_STATIC_INSTANCE(classname, ...) \
classname * classname::Instance() \
{\
static QScopedPointer<classname> instance{ nullptr };\
static std::once_flag oc;\
std::call_once(oc, [] { \
if(instance.isNull()) {\
instance.reset(new classname(__VA_ARGS__));\
}\
});\
return instance.data(); \
}
namespace Global {
QVariant loadSettings(const QString &key, const QVariant &val = QVariant(), const QString &group = QString());
void saveSettings(const QString &key, const QVariant &val, const QString &group = QString());
enum class GeoType {
Latitude,
Longitude
};
QString MakeGeoPrintable(double val, GeoType type);
QString MakeMeterPrintable(double val);
}
#endif // GLOBAL_H