-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFloatingPopUp.cpp
More file actions
71 lines (61 loc) · 1.83 KB
/
FloatingPopUp.cpp
File metadata and controls
71 lines (61 loc) · 1.83 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "FloatingPopUp.h"
#include <QPainter>
#include <QDebug>
#define DURATION 3000
#define PAUSE 90*1000
FloatingPopUp::FloatingPopUp(QWidget *parent) : QWidget(parent)
{
font = new QFont("MS Shell Dlg 2", 8, QFont::DemiBold);
animopac = new QVariantAnimation(this);
animopac->setStartValue(0.0);
animopac->setEndValue(1.0);
animopac->setDuration(DURATION);
connect(animopac, &QVariantAnimation::finished, this, &FloatingPopUp::timeOut);
connect(animopac, &QVariantAnimation::valueChanged, this, &FloatingPopUp::timeChanged);
timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &FloatingPopUp::start);
connect(this, &FloatingPopUp::destroyed, timer, &QTimer::deleteLater);
direction = true;
timer->start(PAUSE);
}
FloatingPopUp::~FloatingPopUp()
{
}
void FloatingPopUp::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
qreal opacity = animopac->currentValue().toReal();
QPainter p(this);
p.setOpacity(opacity);
QColor bckclr("#ffbf00");
QBrush brush = QBrush(bckclr);
QPen pen = QPen(QColor(bckclr));
p.setPen(pen);
p.setBrush(brush);
p.drawRoundedRect(0, 0, this->rect().width(), this->rect().height(), 6, 6);
p.setPen(QColor(Qt::red));
p.setFont(*font);
p.drawText(this->rect(), Qt::AlignCenter, tr("Ez a program szerzői jogvédelem alá esik.\nKészítette: Voszkovenkó István"));
}
void FloatingPopUp::start()
{
animopac->setDirection(direction ? QAbstractAnimation::Forward : QAbstractAnimation::Backward);
animopac->start();
}
void FloatingPopUp::timeChanged()
{
repaint();
}
void FloatingPopUp::timeOut()
{
animopac->stop();
if (direction)
{
direction = false;
start();
}
else
{
direction = true;
}
}