aboutsummaryrefslogtreecommitdiff
path: root/installer/licensewidget.cpp
blob: 8a0a5166e40896a5a2ce6f87bb498a3910dd32ad (plain) (blame)
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
72
73
74
75
76
77
78
#include "licensewidget.h"
#include "ui_licensewidget.h"

#include <QPropertyAnimation>
#include <QDesktopServices>

LicenseWidget::LicenseWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::LicenseWidget)
{
    ui->setupUi(this);
}

LicenseWidget::~LicenseWidget()
{
    delete ui;
}

void LicenseWidget::show(QString title, QString text) {
    ui->titleWidget->setText(title);
    ui->license->setHtml(text);

    this->setGeometry(parentWidget()->width(), 0, parentWidget()->width(), parentWidget()->height());

    QWidget::show();

    QPropertyAnimation* anim = new QPropertyAnimation(this, "geometry");
    anim->setStartValue(this->geometry());
    anim->setEndValue(QRect(0, 0, this->width(), this->height()));
    anim->setDuration(500);
    anim->setEasingCurve(QEasingCurve::OutCubic);
    anim->start(QPropertyAnimation::DeleteWhenStopped);

    coverWidget = new QWidget(this->parentWidget());
    coverWidget->setGeometry(0, 0, this->width(), this->height());
    coverWidget->setPalette(this->palette());
    coverWidget->setAutoFillBackground(true);

    opacityEffect = new QGraphicsOpacityEffect(coverWidget);
    coverWidget->setGraphicsEffect(opacityEffect);
    opacityEffect->setOpacity(0);
    coverWidget->show();

    coverWidget->raise();
    this->raise();

    QPropertyAnimation* opac = new QPropertyAnimation(opacityEffect, "opacity");
    opac->setStartValue((qreal) 0);
    opac->setEndValue((qreal) 1);
    opac->setDuration(500);
    opac->setEasingCurve(QEasingCurve::OutCubic);
    opac->start(QPropertyAnimation::DeleteWhenStopped);
}

void LicenseWidget::on_backButton_clicked()
{
    QPropertyAnimation* anim = new QPropertyAnimation(this, "geometry");
    anim->setStartValue(this->geometry());
    anim->setEndValue(QRect(this->width(), 0, this->width(), this->height()));
    anim->setDuration(500);
    anim->setEasingCurve(QEasingCurve::OutCubic);
    anim->start(QPropertyAnimation::DeleteWhenStopped);

    QPropertyAnimation* opac = new QPropertyAnimation(opacityEffect, "opacity");
    opac->setStartValue((qreal) 1);
    opac->setEndValue((qreal) 0);
    opac->setDuration(500);
    opac->setEasingCurve(QEasingCurve::OutCubic);
    opac->start(QPropertyAnimation::DeleteWhenStopped);
    connect(opac, &QPropertyAnimation::finished, [=] {
        coverWidget->deleteLater();
    });
}

void LicenseWidget::on_license_anchorClicked(const QUrl &arg1)
{
    QDesktopServices::openUrl(arg1);
}