-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathControls3D.cpp
More file actions
47 lines (41 loc) · 1.35 KB
/
Controls3D.cpp
File metadata and controls
47 lines (41 loc) · 1.35 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
#include "Controls3D.h"
#include "ui_Controls3D.h"
Controls3D::Controls3D(QWidget *parent) :
QDialog(parent),
ui(new Ui::Controls3D)
{
ui->setupUi(this);
connect(ui->down, &QPushButton::clicked, this, &Controls3D::buttonClicked);
connect(ui->up, &QPushButton::clicked, this, &Controls3D::buttonClicked);
connect(ui->left, &QPushButton::clicked, this, &Controls3D::buttonClicked);
connect(ui->right, &QPushButton::clicked, this, &Controls3D::buttonClicked);
connect(ui->rotate, &QPushButton::clicked, this, &Controls3D::buttonClicked);
}
Controls3D::~Controls3D()
{
delete ui;
}
void Controls3D::buttonClicked()
{
QPushButton* button = (QPushButton*)sender();
if (button->objectName() == "rotate")
emit rotateClicked();
else
emit directionClicked(button->objectName(), ui->step->value());
}
void Controls3D::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Left)
emit directionClicked("left", ui->step->value());
else if (event->key() == Qt::Key_Right)
emit directionClicked("right", ui->step->value());
else if (event->key() == Qt::Key_Down)
emit directionClicked("down", ui->step->value());
else if (event->key() == Qt::Key_Up)
emit directionClicked("up", ui->step->value());
}
void Controls3D::mousePressEvent(QMouseEvent *event)
{
setFocus();
qDebug() << event->button() << " pressed.";
}