mirror of
https://github.com/tnodir/fort
synced 2024-11-15 08:35:08 +00:00
UI: Splash: Fade in/out
This commit is contained in:
parent
dc5555ebd6
commit
365bf30eda
@ -4,12 +4,31 @@
|
|||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QPropertyAnimation>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#include <form/controls/controlutil.h>
|
#include <form/controls/controlutil.h>
|
||||||
#include <manager/windowmanager.h>
|
#include <manager/windowmanager.h>
|
||||||
#include <util/iconcache.h>
|
#include <util/iconcache.h>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
void startOpacityAnimation(
|
||||||
|
QWidget *w, const std::function<void()> &onFinished, bool backward = false)
|
||||||
|
{
|
||||||
|
auto anim = new QPropertyAnimation(w, "windowOpacity", w);
|
||||||
|
anim->setDirection(backward ? QPropertyAnimation::Backward : QPropertyAnimation::Forward);
|
||||||
|
anim->setDuration(900);
|
||||||
|
anim->setStartValue(0.0f);
|
||||||
|
anim->setEndValue(1.0f);
|
||||||
|
|
||||||
|
QObject::connect(anim, &QPropertyAnimation::finished, onFinished);
|
||||||
|
|
||||||
|
anim->start(QPropertyAnimation::DeleteWhenStopped);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
SplashScreen::SplashScreen() : QSplashScreen()
|
SplashScreen::SplashScreen() : QSplashScreen()
|
||||||
{
|
{
|
||||||
this->setAttribute(Qt::WA_DeleteOnClose);
|
this->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
@ -17,11 +36,23 @@ SplashScreen::SplashScreen() : QSplashScreen()
|
|||||||
setupUi();
|
setupUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplashScreen::showTemporary()
|
void SplashScreen::showFading()
|
||||||
{
|
{
|
||||||
|
setWindowOpacity(0.0f);
|
||||||
show();
|
show();
|
||||||
|
|
||||||
QTimer::singleShot(2000, this, &QWidget::close);
|
startOpacityAnimation(this, [&] { closeDelayed(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
void SplashScreen::closeDelayed()
|
||||||
|
{
|
||||||
|
QTimer::singleShot(1600, this, &SplashScreen::closeFading);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SplashScreen::closeFading()
|
||||||
|
{
|
||||||
|
startOpacityAnimation(
|
||||||
|
this, [&] { close(); }, /*backward=*/true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplashScreen::setupUi()
|
void SplashScreen::setupUi()
|
||||||
|
@ -16,7 +16,9 @@ public:
|
|||||||
static QLayout *createLogoTextLayout();
|
static QLayout *createLogoTextLayout();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void showTemporary();
|
void showFading();
|
||||||
|
void closeDelayed();
|
||||||
|
void closeFading();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupUi();
|
void setupUi();
|
||||||
|
@ -302,7 +302,7 @@ void WindowManager::showTrayMessage(const QString &message, WindowManager::TrayM
|
|||||||
void WindowManager::showSplashScreen()
|
void WindowManager::showSplashScreen()
|
||||||
{
|
{
|
||||||
auto splash = new SplashScreen();
|
auto splash = new SplashScreen();
|
||||||
splash->showTemporary();
|
splash->showFading();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::showHomeWindow()
|
void WindowManager::showHomeWindow()
|
||||||
|
Loading…
Reference in New Issue
Block a user