1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2012 LoRd_MuldeR <MuldeR2@GMX.de>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
22 #include "Dialog_SplashScreen.h"
31 #include "WinSevenTaskbar.h"
36 ////////////////////////////////////////////////////////////
38 ////////////////////////////////////////////////////////////
40 SplashScreen::SplashScreen(QWidget *parent)
41 : QFrame(parent, Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint)
43 //Init the dialog, from the .ui file
47 m_working = new QMovie(":/images/Loading.gif");
48 labelLoading->setMovie(m_working);
52 setCursor(Qt::WaitCursor);
58 ////////////////////////////////////////////////////////////
60 ////////////////////////////////////////////////////////////
62 SplashScreen::~SplashScreen(void)
72 ////////////////////////////////////////////////////////////
74 ////////////////////////////////////////////////////////////
76 void SplashScreen::showSplash(QThread *thread)
79 SplashScreen *splashScreen = new SplashScreen();
82 splashScreen->m_canClose = false;
83 splashScreen->setWindowOpacity(opacity);
86 //Wait for window to show
87 QApplication::processEvents();
89 QApplication::processEvents();
91 //Setup the event loop
92 QEventLoop *loop = new QEventLoop(splashScreen);
93 connect(thread, SIGNAL(terminated()), loop, SLOT(quit()), Qt::QueuedConnection);
94 connect(thread, SIGNAL(finished()), loop, SLOT(quit()), Qt::QueuedConnection);
97 QTimer *timer = new QTimer();
98 connect(timer, SIGNAL(timeout()), loop, SLOT(quit()));
101 QApplication::processEvents();
103 QApplication::processEvents();
106 WinSevenTaskbar::setTaskbarState(splashScreen, WinSevenTaskbar::WinSevenTaskbarIndeterminateState);
109 for(int i = 0; i <= 100; i++)
111 opacity = 0.01 * static_cast<double>(i);
112 splashScreen->setWindowOpacity(opacity);
113 QApplication::processEvents(QEventLoop::ExcludeUserInputEvents, FADE_DELAY);
120 //Loop while thread is running
121 while(thread->isRunning())
124 if(thread->isRunning())
126 qWarning("Potential deadlock in initialization thread!");
134 for(int i = 100; i >= 0; i--)
136 opacity = 0.01 * static_cast<double>(i);
137 splashScreen->setWindowOpacity(opacity);
138 QApplication::processEvents(QEventLoop::ExcludeUserInputEvents, FADE_DELAY);
143 WinSevenTaskbar::setTaskbarState(splashScreen, WinSevenTaskbar::WinSevenTaskbarNoState);
146 splashScreen->m_canClose = true;
147 splashScreen->close();
151 LAMEXP_DELETE(timer);
152 LAMEXP_DELETE(splashScreen);
155 ////////////////////////////////////////////////////////////
157 ////////////////////////////////////////////////////////////
159 void SplashScreen::keyPressEvent(QKeyEvent *event)
164 void SplashScreen::keyReleaseEvent(QKeyEvent *event)
169 void SplashScreen::closeEvent(QCloseEvent *event)
171 if(!m_canClose) event->ignore();
174 bool SplashScreen::winEvent(MSG *message, long *result)
176 return WinSevenTaskbar::handleWinEvent(message, result);