forked from korroktheslavemaster/vision
/
camlabel.cpp
41 lines (37 loc) · 893 Bytes
/
camlabel.cpp
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
#include "camlabel.h"
CamLabel::CamLabel(QWidget *parent) :
QLabel(parent)
{
prevx = 0;
prevy = 0;
}
void CamLabel::mousePressEvent(QMouseEvent *ev)
{
if(ev->buttons() & Qt::LeftButton)
{
// qDebug() << "mouse signal sent.";
emit mouseClicked(ev->x(), ev->y());
// emit mousePressed(ev->x(), ev->y());
}
if(ev->buttons() & Qt::RightButton)
{
prevx = ev->x();
prevy = ev->y();
}
}
void CamLabel::mouseMoveEvent(QMouseEvent *ev)
{
if(ev->buttons() & Qt::LeftButton)
emit mousePressed(ev->x(), ev->y());
else if(ev->buttons() & Qt::RightButton)
{
emit mouseRightPressed(ev->x()-prevx, ev->y()-prevy);
prevx = ev->x();
prevy = ev->y();
}
emit mouseOnlyMove(ev->x(), ev->y());
}
void CamLabel::wheelEvent(QWheelEvent *ev)
{
emit mouseScrollCam(ev->delta()/120);
}