-
Notifications
You must be signed in to change notification settings - Fork 263
/
globaldef.hpp
88 lines (80 loc) · 2.15 KB
/
globaldef.hpp
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
80
81
82
83
84
85
86
87
88
#ifndef GLOBALDEF_HPP
#define GLOBALDEF_HPP
#include <QString>
#include <QDebug>
#include <QFile>
#ifndef LOADQSS
#define LOADQSS(qssFile) \
{ \
QFile file(qssFile); \
file.open(QFile::ReadOnly); \
if(file.isOpen()) \
{ \
qApp->setStyleSheet(file.readAll()); \
file.close(); \
} \
}
#endif
#ifndef SAFEDELETE
#define SAFEDELETE(pointer) \
{ \
if(pointer) \
{ \
delete pointer; \
} \
pointer = nullptr; \
}
#endif
enum WidgetTabType
{
TAB_BANNA,
TAB_CYLINDER,
TAB_PROGRESS,
TAB_FRAME,
TAB_LIST,
TAB_CUSTOM_PLOT,
TAB_MOVE_BUTTON,
TAB_TABLE_WIDGET,
TAB_SLIDER,
TAB_PROCESS,
TAB_OPENGL,
TAB_MAX,
};
namespace GlobalSpace
{
const QString STYLE_QSS_FILE_PATH = ":/res/res/stylesheet/stylesheet.qss";
const QString LOGO_PATH = ":/res/res/image/image.png";
const int INT_DOUBLE_TIMES = 2;
const float FLOAT_DOUBLE_TIMES = 2.0f;
// 根据控件位置获取控件中心点位置
inline QPoint GetCenterPosition(const QWidget *controlWidget)
{
QPoint centerPos;
if(nullptr != controlWidget)
{
centerPos.setX(controlWidget->x() + controlWidget->width() / INT_DOUBLE_TIMES);
centerPos.setY(controlWidget->y() + controlWidget->height() / INT_DOUBLE_TIMES);
}
return centerPos;
}
// 获取控件中心点位置
inline QPointF GetCenterPoint(const QWidget *controlWidget)
{
QPointF centerPoint;
if(nullptr != controlWidget)
{
centerPoint.setX(controlWidget->width() / 2.0);
centerPoint.setY(controlWidget->height() / 2.0);
}
return centerPoint;
}
// 获取图片中心点位置
inline QPointF GetCenterPoint(const QImage &image)
{
QPointF centerPoint;
centerPoint.setX(image.width() / 2.0);
centerPoint.setY(image.height() / 2.0);
return centerPoint;
}
}
#endif // GLOBALDEF_HPP