///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
-// Copyright (C) 2004-2010 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2012 LoRd_MuldeR <MuldeR2@GMX.de>
//
// 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
#include <QThread>
#include <QMovie>
#include <QKeyEvent>
-#include <Windows.h>
+#include <QTimer>
+
+#include "WinSevenTaskbar.h"
#define EPS (1.0E-5)
+#define FADE_DELAY 4
////////////////////////////////////////////////////////////
// Constructor
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 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();
-
+ 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();
- Sleep(6);
+ Sleep(FADE_DELAY);
}
//Loop while thread is running
while(thread->isRunning())
{
- QApplication::processEvents(QEventLoop::AllEvents | QEventLoop::WaitForMoreEvents);
+ QTimer::singleShot(15000, loop, SLOT(quit()));
+ loop->exec();
+ if(thread->isRunning()) qWarning("Potential deadlock in Init thread!");
}
//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
+ WinSevenTaskbar::setTaskbarState(splashScreen, WinSevenTaskbar::WinSevenTaskbarNoState);
+
//Hide splash
splashScreen->m_canClose = true;
splashScreen->close();
+ //Free
+ LAMEXP_DELETE(loop);
LAMEXP_DELETE(splashScreen);
}
{
if(!m_canClose) event->ignore();
}
+
+bool SplashScreen::winEvent(MSG *message, long *result)
+{
+ return WinSevenTaskbar::handleWinEvent(message, result);
+}