-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathscreenapi.h
More file actions
94 lines (72 loc) · 2.02 KB
/
screenapi.h
File metadata and controls
94 lines (72 loc) · 2.02 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
#ifndef SCREENAPI_H
#define SCREENAPI_H
#ifndef FRMSCREEN_H
#define FRMSCREEN_H
#include <QPoint>
#include <QSize>
#include <QDialog>
#include <QMutex>
#include <QMenu>
class ScreenAPI
{
public:
enum STATUS {SELECT, MOV, SET_W_H};
ScreenAPI() {}
ScreenAPI(QSize size);
void setStart(QPoint pos);
void setEnd(QPoint pos);
QPoint getStart();
QPoint getEnd();
QPoint getLeftUp();
QPoint getRightDown();
STATUS getStatus();
void setStatus(STATUS status);
int width();
int height();
bool isInArea(QPoint pos); // 检测pos是否在截图区域内
void move(QPoint p); // 按 p 移动截图区域
private:
QPoint leftUpPos, rightDownPos; //记录 截图区域 左上角、右下角
QPoint startPos, endPos; //记录 鼠标开始位置、结束位置
int maxWidth, maxHeight; //记录屏幕大小
STATUS status; //三个状态 : 选择区域、移动区域、设置width height
void cmpPoint(QPoint &s, QPoint &e);//比较两位置,判断左上角、右下角
};
#endif // SCREENAPI_H
class frmScreen : public QDialog
{
Q_OBJECT
public:
explicit frmScreen(QWidget *parent = 0);
static frmScreen *Instance()
{
static QMutex mutex;
if (!_instance) {
QMutexLocker locker(&mutex);
if (!_instance) {
_instance = new frmScreen;
}
}
return _instance;
}
private:
static frmScreen *_instance;
QMenu *menu; //右键菜单对象
ScreenAPI *screen; //截屏对象
QPixmap *fullScreen; //保存全屏图像
QPixmap *bgScreen; //模糊背景图
QPoint movPos; //坐标
protected:
void contextMenuEvent(QContextMenuEvent *);
void mousePressEvent(QMouseEvent *);
void mouseMoveEvent(QMouseEvent *);
void mouseReleaseEvent(QMouseEvent *);
void paintEvent(QPaintEvent *);
void showEvent(QShowEvent *);
private slots:
void InitForm();
void SaveScreen();
void SaveScreenOther();
void SaveFullScreen();
};
#endif // FRMSCREEN_H