-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpopup.cpp
More file actions
28 lines (26 loc) · 1014 Bytes
/
Copy pathpopup.cpp
File metadata and controls
28 lines (26 loc) · 1014 Bytes
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
#include "popup.h"
#include <QLabel>
#include <QPropertyAnimation>
#include <QTimer>
PopUp::PopUp(QString text, QWidget *parent): QFrame(parent)
{
QLabel* lbl = new QLabel(this);
lbl->setText(text + " ");
lbl->setFixedSize(500,50);
lbl->setStyleSheet("background-color: gray; color:white;");
lbl->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
QPropertyAnimation* anim = new QPropertyAnimation(lbl, "pos", this);
anim->setDuration(500);
anim->setStartValue(QPoint(-500, 0));
anim->setEndValue(QPoint(0, 0));
timer = new QTimer(this);
anim->start(QAbstractAnimation::DeleteWhenStopped);
connect(anim, &QPropertyAnimation::finished, this, &PopUp::killNotification);
this->setFixedSize(500,50);
this->setStyleSheet("background-color: transparent; border-top-right-radius: 20px; border-bottom-right-radius: 20px; border: none");
}
void PopUp::killNotification()
{
connect(timer, &QTimer::timeout, this, &PopUp::deleteLater);
timer->start(1000);
}