-
Notifications
You must be signed in to change notification settings - Fork 0
/
clipbox.h
48 lines (40 loc) · 1.1 KB
/
clipbox.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
#ifndef CLIPBOX_H
#define CLIPBOX_H
#include <QWidget>
#include <QPainter>
#include <QMouseEvent>
#include <QPaintEvent>
QT_BEGIN_NAMESPACE
class QLabel;
class QPixmap;
class QPoint;
QT_END_NAMESPACE
class ClipBox : public QWidget
{
Q_OBJECT
public:
enum CaptureState{INIT, BEGIN_CAPTURE, BEGIN_MOVE, WAITING,
LEFT_TOP_MOVE, LEFT_MOVE, LEFT_BOTTOM_MOVE,
BOTTOM_MOVE, RIGHT_BOTTOM_MOVE, RIGHT_MOVE,
RIGHT_TOP_MOVE, TOP_MOVE};
ClipBox(QPixmap pixmap, QWidget *parent = 0);
signals:
void currentRect(QRect rect);
void sendEnable();
private:
CaptureState captureState;
QPixmap loadPixmap;
QPixmap capturePixmap;
QPainter *painter;
QPoint beginPos, endPos;
QPoint moveBeginPos, moveEndPos;
QRect selectRect;
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void keyPressEvent(QMouseEvent *event);
void paintEvent(QPaintEvent *event);
QRect getSelectRect();
void drawCaptureImage();
};
#endif // CLIPBOX_H