-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinfowidget.cpp
70 lines (58 loc) · 2.36 KB
/
infowidget.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "infowidget.h"
#include "ui_infowidget.h"
InfoWidget::InfoWidget(QWidget *parent) : QWidget(parent), ui(new Ui::InfoWidget)
{
ui->setupUi(this);
this->setWindowOpacity(0);
this->setMouseTracking(true);
this->setGeometry(0, 0, QApplication::desktop()->screenGeometry().width(), 80);
this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowStaysOnTopHint | Qt::Drawer);
this->setAttribute(Qt::WA_TranslucentBackground);
bg = new QLabel(this);
bg->setMouseTracking(true);
bg->setGeometry(0, 0, QApplication::desktop()->screenGeometry().width(), 80);
bg->setStyleSheet("background: rgba(0, 0, 0, 0.5);");
bg->show();
QGraphicsDropShadowEffect * textShadow = new QGraphicsDropShadowEffect(this);
textShadow->setBlurRadius(10);
textShadow->setColor(QColor(0, 0, 0));
textShadow->setOffset(0, 0);
trackName = new QLabel (this);
trackName->setMouseTracking(true);
trackName->setGeometry(0, 5, QApplication::desktop()->screenGeometry().width(), 45);
trackName->setStyleSheet("color: white; font-size: 22px;");
trackName->setAlignment(Qt::AlignCenter);
trackName->setGraphicsEffect(textShadow);
trackName->show();
trackInfo = new QLabel (this);
trackInfo->setMouseTracking(true);
trackInfo->setGeometry(0, 50, QApplication::desktop()->screenGeometry().width(), 20);
trackInfo->setStyleSheet("color: white; font-size: 16px;");
trackInfo->setAlignment(Qt::AlignCenter);
trackInfo->setGraphicsEffect(textShadow);
trackInfo->show();
}
InfoWidget::~InfoWidget()
{
delete ui;
}
void InfoWidget::popup(int duration) {
trackName->setText("♫ " + this->name + " [" + this->duration + "] " + " ♫");
trackInfo->setText(this->info);
QPropertyAnimation * animation = new QPropertyAnimation(this, "windowOpacity");
animation->setDuration(1000);
animation->setStartValue(0);
animation->setEndValue(1);
animation->start();
timer = new QTimer(this);
timer->setSingleShot(true);
timer->setInterval(duration);
timer->start();
connect(timer, &QTimer::timeout, [=]() {
QPropertyAnimation * animation = new QPropertyAnimation(this, "windowOpacity");
animation->setDuration(1000);
animation->setStartValue(this->windowOpacity());
animation->setEndValue(0);
animation->start();
});
}