-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcapturescreen.h
More file actions
127 lines (104 loc) · 3.24 KB
/
capturescreen.h
File metadata and controls
127 lines (104 loc) · 3.24 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#ifndef CAPTURESCREEN_H
#define CAPTURESCREEN_H
#include <QWidget>
#include <QPainter>
#include <QRect>
/*
class CaptureScreen : public QWidget
{
Q_OBJECT
public:
explicit CaptureScreen(QWidget *parent = nullptr);
public:
~CaptureScreen();
signals:
void signalCompleteCature(QPixmap catureImage);
private:
void initWindow();
void loadBackgroundPixmap();
void initStretchRect();
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent *event);
void keyPressEvent(QKeyEvent *event);
void paintEvent(QPaintEvent *event);
QRect getRect(const QPoint &beginPoint, const QPoint &endPoint);
bool isPressPointInSelectRect(QPoint mousePressPoint);
QRect getSelectRect();
bool m_isMousePress;
QPixmap m_loadPixmap, m_capturePixmap;
int m_screenwidth;
int m_screenheight;
QPoint m_beginPoint, m_endPoint;
QPainter m_painter;
QRect m_stretchRectState,m_topLeftRect,m_topRightRect,m_bottomLeftRect,m_bottomRightRect;
QRect m_leftCenterRect,m_rightCenterRect,m_bottomCenterRect;
QRect NotSelect,m_currentCaptureState;
};
*/
enum CaptureState{
InitCapture = 0,
BeginCaptureImage,
FinishCaptureImage,
BeginMoveCaptureArea,
FinishMoveCaptureArea,
BeginMoveStretchRect,
FinishMoveStretchRect
}; //进行截屏的状态;
enum StretchRectState{
NotSelect = 0,
TopLeftRect,
TopRightRect,
BottomLeftRect,
BottomRightRect,
LeftCenterRect,
TopCenterRect,
RightCenterRect,
BottomCenterRect
};// 当前鼠标所在顶点状态;
class CaptureScreen : public QWidget
{
Q_OBJECT
public:
CaptureScreen(QPixmap imgin,QWidget *parent = 0);
~CaptureScreen();
Q_SIGNALS:
// 通知截图完毕,并将截取图片传递给调用类;
void signalCompleteCature(QPixmap catureImage);
private:
void initWindow();
void initStretchRect();
void loadBackgroundPixmap();
QRect getRect(const QPoint &beginPoint, const QPoint &endPoint);
QRect getMoveRect();
QRect getStretchRect();
bool isPressPointInSelectRect(QPoint mousePressPoint);
QRect getSelectRect();
QPoint getMovePoint();
StretchRectState getStrethRectState(QPoint point);
void setStretchCursorStyle(StretchRectState stretchRectState);
void drawCaptureImage();
void drawStretchRect();
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent *event);
void keyPressEvent(QKeyEvent *event);
void paintEvent(QPaintEvent *event);
private:
QPixmap m_loadPixmap, m_capturePixmap;
int m_screenwidth;
int m_screenheight;
// 保存确定选区的坐标点;
QPoint m_beginPoint, m_endPoint, m_beginMovePoint, m_endMovePoint;
QPainter m_painter;
// 保存当前截图状态;
CaptureState m_currentCaptureState;
// 当前选择区域矩形;
QRect m_currentSelectRect;
// 选中矩形8个顶点小矩形;
QRect m_topLeftRect, m_topRightRect, m_bottomLeftRect, m_bottomRightRect;
QRect m_leftCenterRect, m_topCenterRect, m_rightCenterRect, m_bottomCenterRect;
// 当前鼠标所在顶点状态;
StretchRectState m_stretchRectState;
};
#endif // CAPTURESCREEN_H