forked from lidian53/Screenshot-with-picture-edit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
screen.h
80 lines (62 loc) · 2.05 KB
/
screen.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
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
#ifndef SCREEN_H
#define SCREEN_H
#include <QWidget>
#include "myrect.h"
#include"qslabel.h"
#include"controlwidget.h"
enum Type {
RECT1, RECT2, RECT3, RECT4, RECT, NO
};
class QSLabel;
class ControlWidget;
class Screen : public QWidget
{
Q_OBJECT
public:
explicit Screen(QWidget *parent = 0);
void drawline();
void textedit();
void drawarrow();
void drawround();
void drawrectang();
void paintEvent(QPaintEvent *);
void mousePressEvent(QMouseEvent *);
void mouseReleaseEvent(QMouseEvent *);
void mouseMoveEvent(QMouseEvent *);
void setselectimagelabel(QMouseEvent* event);
void keyPressEvent(QKeyEvent *e);
//绘制控制选区,也就是四个小三角
void drawControlArea(QPainter &);
bool comparePoint(QPoint &p1, QPoint &p2);
bool compareRect(QRectF &r1, QRectF &r2);
Type pointInWhere(QPoint p);
//返回截取之后的图片
QPixmap getGrabPixmap();
QPainterPath getPath();
//保存截图
void savePixmap();
virtual ~Screen();
void Exit();
private:
bool pointInRect(QPoint &p, QRectF &r);
private:
QPixmap pixmap; //全屏
QPoint pressedPoint; //鼠标左键按下后的坐标
QPoint movePoint; //终点坐标
QPainterPath globalPath; //保存全局路径
bool oncePress; //是不是第一次左键按下
MyRect widthInfoRect;//截取区域的长宽信息矩形
//控制选区变化的正方形
QRectF rect1; //第一象限的正方形
QRectF rect2; //第二象限的正方形
QRectF rect3; //第三象限的正方形
QRectF rect4; //第四象限的正方形
QRectF rect; //代表选区的正方形
Type type;
QPoint oldPoint; //原先的坐标
QWidget *control;
ControlWidget *controlUi;
QRect rec;
QSLabel *labelimage;
};
#endif // SCREEN_H