-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathOverlappedWidget.h
45 lines (37 loc) · 901 Bytes
/
OverlappedWidget.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
#pragma once
#include <QDialog>
#include <QPaintEvent>
#include <QMouseEvent>
class OverlappedWidget : public QDialog
{
Q_OBJECT
public:
OverlappedWidget(QWidget *parent);
~OverlappedWidget();
enum Action
{
None = 0,
OcrInRegion,
ClipRegion
};
void setAction(Action action);
void setScreenImage(const QImage& image);
QRect selectedRegion();
QImage regionImage(const QRect& region);
protected:
virtual void paintEvent(QPaintEvent *event);
virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseMoveEvent(QMouseEvent *event);
virtual void mouseReleaseEvent(QMouseEvent *event);
virtual void keyPressEvent(QKeyEvent *event);
Q_SIGNALS:
void regionSelected(Action action, const QRect& region);
protected:
Action m_action;
QImage m_screenImage;
QImage m_darkMaskImage;
QPoint m_pressedPos;
QPoint m_draggingPos;
bool m_dragging;
QRect m_selectedRegion;
};