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