2020-04-11 08:06:34 -04:00
|
|
|
/****************************************
|
|
|
|
*
|
|
|
|
* INSERT-PROJECT-NAME-HERE - INSERT-GENERIC-NAME-HERE
|
|
|
|
* Copyright (C) 2020 Victor Tran
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* *************************************/
|
|
|
|
#include "splashwindow.h"
|
|
|
|
#include "ui_splashwindow.h"
|
|
|
|
|
2023-02-02 02:46:30 -05:00
|
|
|
#include "splash/splashcontroller.h"
|
2020-06-17 07:51:44 -04:00
|
|
|
#include <QScreen>
|
2023-02-02 02:46:30 -05:00
|
|
|
#include <tapplication.h>
|
2020-04-11 08:06:34 -04:00
|
|
|
#include <tvariantanimation.h>
|
|
|
|
|
|
|
|
SplashWindow::SplashWindow(QWidget* parent) :
|
|
|
|
QDialog(parent),
|
|
|
|
ui(new Ui::SplashWindow) {
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
this->setWindowFlag(Qt::WindowStaysOnTopHint);
|
|
|
|
ui->stackedWidget->setCurrentAnimation(tStackedWidget::Fade);
|
|
|
|
|
2023-02-02 02:46:30 -05:00
|
|
|
connect(SplashController::instance(), &SplashController::starting, this, [=] {
|
2020-04-11 08:06:34 -04:00
|
|
|
ui->stackedWidget->setCurrentWidget(ui->splashPage, this->isVisible());
|
|
|
|
this->showFullScreen();
|
|
|
|
});
|
2023-02-02 02:46:30 -05:00
|
|
|
connect(SplashController::instance(), &SplashController::hideSplashes, this, [=] {
|
2020-04-11 08:06:34 -04:00
|
|
|
this->hide();
|
|
|
|
});
|
2023-02-02 02:46:30 -05:00
|
|
|
connect(SplashController::instance(), &SplashController::crash, this, [=] {
|
2020-04-11 08:06:34 -04:00
|
|
|
ui->stackedWidget->setCurrentWidget(ui->crashPage, this->isVisible());
|
|
|
|
this->showFullScreen();
|
|
|
|
});
|
2023-02-02 02:46:30 -05:00
|
|
|
connect(SplashController::instance(), &SplashController::startFail, this, [=] {
|
2020-04-11 08:06:34 -04:00
|
|
|
ui->stackedWidget->setCurrentWidget(ui->crashPage, this->isVisible());
|
|
|
|
this->showFullScreen();
|
|
|
|
});
|
2023-02-02 02:46:30 -05:00
|
|
|
connect(SplashController::instance(), &SplashController::question, this, [=](QString title, QString message) {
|
2020-04-26 00:07:20 -04:00
|
|
|
ui->questionTitle->setText(title);
|
|
|
|
ui->questionText->setText(message);
|
|
|
|
ui->stackedWidget->setCurrentWidget(ui->questionPage, this->isVisible());
|
|
|
|
this->showFullScreen();
|
|
|
|
});
|
2020-06-17 07:51:44 -04:00
|
|
|
|
|
|
|
this->setGeometry(tApplication::primaryScreen()->geometry());
|
2020-04-11 08:06:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
SplashWindow::~SplashWindow() {
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SplashWindow::hide() {
|
|
|
|
tVariantAnimation* anim = new tVariantAnimation(this);
|
|
|
|
anim->setStartValue(1.0);
|
|
|
|
anim->setEndValue(0.0);
|
|
|
|
anim->setEasingCurve(QEasingCurve::OutCubic);
|
|
|
|
anim->setDuration(500);
|
2023-02-02 02:46:30 -05:00
|
|
|
connect(anim, &tVariantAnimation::valueChanged, this, [=](QVariant value) {
|
2020-04-11 08:06:34 -04:00
|
|
|
this->setWindowOpacity(value.toDouble());
|
|
|
|
});
|
2023-02-02 02:46:30 -05:00
|
|
|
connect(anim, &tVariantAnimation::finished, this, [=] {
|
2020-04-11 08:06:34 -04:00
|
|
|
anim->deleteLater();
|
|
|
|
QDialog::hide();
|
|
|
|
this->setWindowOpacity(1);
|
|
|
|
});
|
|
|
|
anim->start();
|
|
|
|
}
|
2020-04-26 00:07:20 -04:00
|
|
|
|
|
|
|
void SplashWindow::on_yesButton_clicked() {
|
|
|
|
SplashController::instance()->respond(true);
|
|
|
|
ui->stackedWidget->setCurrentWidget(ui->splashPage);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SplashWindow::on_noButton_clicked() {
|
|
|
|
SplashController::instance()->respond(false);
|
|
|
|
ui->stackedWidget->setCurrentWidget(ui->splashPage);
|
|
|
|
}
|