Reworked SplashScreen fade-in and fade-out code a bit.
This commit is contained in:
parent
aa9a513a2b
commit
be410216a9
@ -30,6 +30,7 @@
|
||||
#include "WinSevenTaskbar.h"
|
||||
|
||||
#define EPS (1.0E-5)
|
||||
#define FADE_DELAY 4
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
@ -73,41 +74,51 @@ SplashScreen::~SplashScreen(void)
|
||||
|
||||
void SplashScreen::showSplash(QThread *thread)
|
||||
{
|
||||
double opacity = 0.0;
|
||||
SplashScreen *splashScreen = new SplashScreen();
|
||||
|
||||
//Show splash
|
||||
splashScreen->m_canClose = false;
|
||||
splashScreen->setWindowOpacity(0.0);
|
||||
splashScreen->setWindowOpacity(opacity);
|
||||
splashScreen->show();
|
||||
|
||||
//Wait for window to show
|
||||
QApplication::processEvents();
|
||||
Sleep(100);
|
||||
QApplication::processEvents();
|
||||
|
||||
//Setup event loop
|
||||
//Setup the event loop
|
||||
QEventLoop *loop = new QEventLoop(splashScreen);
|
||||
connect(thread, SIGNAL(terminated()), loop, SLOT(quit()), Qt::QueuedConnection);
|
||||
connect(thread, SIGNAL(finished()), loop, SLOT(quit()), Qt::QueuedConnection);
|
||||
|
||||
//Start the thread
|
||||
//Start thread
|
||||
QApplication::processEvents();
|
||||
thread->start();
|
||||
bool flag = false;
|
||||
QApplication::processEvents();
|
||||
|
||||
//Init taskbar
|
||||
WinSevenTaskbar::setTaskbarState(splashScreen, WinSevenTaskbar::WinSevenTaskbarIndeterminateState);
|
||||
|
||||
//Fade in
|
||||
for(double d = 0.0; d <= 1.0 + EPS; d = d + 0.01)
|
||||
for(int i = 0; i <= 100; i++)
|
||||
{
|
||||
splashScreen->setWindowOpacity(d);
|
||||
opacity = 0.01 * static_cast<double>(i);
|
||||
splashScreen->setWindowOpacity(opacity);
|
||||
QApplication::processEvents();
|
||||
if(!flag) flag = WinSevenTaskbar::setTaskbarState(splashScreen, WinSevenTaskbar::WinSevenTaskbarIndeterminateState);
|
||||
Sleep(6);
|
||||
Sleep(FADE_DELAY);
|
||||
}
|
||||
|
||||
//Loop while thread is running
|
||||
loop->exec();
|
||||
|
||||
//Fade out
|
||||
for(double d = 1.0; d >= 0.0; d = d - 0.01)
|
||||
for(int i = 100; i >= 0; i--)
|
||||
{
|
||||
splashScreen->setWindowOpacity(d);
|
||||
opacity = 0.01 * static_cast<double>(i);
|
||||
splashScreen->setWindowOpacity(opacity);
|
||||
QApplication::processEvents();
|
||||
Sleep(6);
|
||||
Sleep(FADE_DELAY);
|
||||
}
|
||||
|
||||
//Restore taskbar
|
||||
@ -117,6 +128,7 @@ void SplashScreen::showSplash(QThread *thread)
|
||||
splashScreen->m_canClose = true;
|
||||
splashScreen->close();
|
||||
|
||||
//Free
|
||||
LAMEXP_DELETE(loop);
|
||||
LAMEXP_DELETE(splashScreen);
|
||||
}
|
||||
|
@ -218,7 +218,6 @@ void UpdateDialog::showEvent(QShowEvent *event)
|
||||
labelVersionInstalled->setText(QString("%1 %2 (%3)").arg(tr("Build"), QString::number(lamexp_version_build()), lamexp_version_date().toString(Qt::ISODate)));
|
||||
labelVersionLatest->setText(QString("(%1)").arg(tr("Unknown")));
|
||||
|
||||
QTimer::singleShot(0, this, SLOT(updateInit()));
|
||||
installButton->setEnabled(false);
|
||||
closeButton->setEnabled(false);
|
||||
retryButton->setEnabled(false);
|
||||
@ -237,6 +236,8 @@ void UpdateDialog::showEvent(QShowEvent *event)
|
||||
|
||||
progressBar->setMaximum(counter);
|
||||
progressBar->setValue(0);
|
||||
|
||||
QTimer::singleShot(0, this, SLOT(updateInit()));
|
||||
}
|
||||
|
||||
void UpdateDialog::closeEvent(QCloseEvent *event)
|
||||
@ -273,7 +274,7 @@ void UpdateDialog::updateInit(void)
|
||||
{
|
||||
setMinimumSize(size());
|
||||
setMaximumHeight(height());
|
||||
|
||||
QApplication::processEvents();
|
||||
checkForUpdates();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user