-
Notifications
You must be signed in to change notification settings - Fork 0
/
newgamebutton.cpp
47 lines (36 loc) · 1.04 KB
/
newgamebutton.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
#include "newgamebutton.h"
#include "ui_newgamebutton.h"
NewGameButton::NewGameButton(QWidget *parent) :
QWidget(parent),
ui(new Ui::NewGameButton)
{
ui->setupUi(this);
ui->shadow->hide();
sound = new QSound(":/assets/click.wav", this);
connect(this, &NewGameButton::clicked, this, &NewGameButton::animateButton);
}
void NewGameButton::setSize(float width, float height)
{
this->setFixedWidth(width);
this->setFixedHeight(height);
ui->background->setFixedWidth(width);
ui->background->setFixedHeight(height);
ui->shadow->setFixedWidth(width);
ui->shadow->setFixedHeight(height);
}
void NewGameButton::animateButton(){
QtConcurrent::run([] (QLabel *shadow, NewGameButton *mb, QSound* sound) {
shadow->show();
sound->play();
QThread::usleep(200000);
shadow->hide();
emit mb->animationFinished();
}, ui->shadow, this, sound);
}
void NewGameButton::mousePressEvent(QMouseEvent* event) {
emit clicked();
}
NewGameButton::~NewGameButton()
{
delete ui;
}