-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharea_selector.cpp
48 lines (37 loc) · 1.02 KB
/
area_selector.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
42
43
44
45
46
47
48
#include "area_selector.h"
#include "ui_boundselector.h"
BoundSelector::BoundSelector(QWidget *parent) :
QDialog(parent),
ui(new Ui::BoundSelector)
{
ui->setupUi(this);
this->setWindowFlags(Qt::Tool | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint);
btnSet = this->ui->btnSetBounds;
connect(btnSet, SIGNAL(clicked(bool)), this, SLOT(btnClicked(bool)));
setWindowOpacity(0.5);
}
void BoundSelector::mousePressEvent(QMouseEvent *event){
mpos = event->pos();
}
void BoundSelector::mouseMoveEvent(QMouseEvent *event){
if (event->buttons() & Qt::LeftButton) {
QPoint diff = event->pos() - mpos;
QPoint newpos = this->pos() + diff;
this->move(newpos);
}
}
void BoundSelector::btnClicked(bool b){
QRect r(
this->pos().x(),
this->pos().y(),
this->width(),
this->height()
);
emit BoundsSelected(r);
this->close();
}
BoundSelector::~BoundSelector()
{
delete btnSet;
delete ui;
}