Moved Taskbar progress into MUtilities library.

This commit is contained in:
LoRd_MuldeR 2014-12-18 22:49:37 +01:00
parent d3917b5233
commit cc45c1a904
15 changed files with 160 additions and 403 deletions

View File

@ -343,7 +343,6 @@ copy /Y "$(SolutionDir)\..\Prerequisites\VisualLeakDetector\bin\Win32\*.manifest
<ClCompile Include="src\Thread_RAMObserver.cpp" /> <ClCompile Include="src\Thread_RAMObserver.cpp" />
<ClCompile Include="src\Tool_Abstract.cpp" /> <ClCompile Include="src\Tool_Abstract.cpp" />
<ClCompile Include="src\Tool_WaveProperties.cpp" /> <ClCompile Include="src\Tool_WaveProperties.cpp" />
<ClCompile Include="src\WinSevenTaskbar.cpp" />
<ClCompile Include="tmp\LameXP\MOC_CustomEventFilter.cpp" /> <ClCompile Include="tmp\LameXP\MOC_CustomEventFilter.cpp" />
<ClCompile Include="tmp\LameXP\MOC_Decoder_Abstract.cpp" /> <ClCompile Include="tmp\LameXP\MOC_Decoder_Abstract.cpp" />
<ClCompile Include="tmp\LameXP\MOC_Dialog_About.cpp" /> <ClCompile Include="tmp\LameXP\MOC_Dialog_About.cpp" />
@ -943,7 +942,6 @@ copy /Y "$(SolutionDir)\..\Prerequisites\VisualLeakDetector\bin\Win32\*.manifest
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp" "%(FullPath)"</Command> <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp" "%(FullPath)"</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp;%(Outputs)</Outputs>
</CustomBuild> </CustomBuild>
<ClInclude Include="src\WinSevenTaskbar.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<CustomBuild Include="res\Documents.qrc"> <CustomBuild Include="res\Documents.qrc">

View File

@ -151,9 +151,6 @@
<ClCompile Include="src\Thread_MessageProducer.cpp"> <ClCompile Include="src\Thread_MessageProducer.cpp">
<Filter>Source Files\Threads</Filter> <Filter>Source Files\Threads</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="src\WinSevenTaskbar.cpp">
<Filter>Source Files\Misc</Filter>
</ClCompile>
<ClCompile Include="src\LockedFile.cpp"> <ClCompile Include="src\LockedFile.cpp">
<Filter>Source Files\Misc</Filter> <Filter>Source Files\Misc</Filter>
</ClCompile> </ClCompile>
@ -495,9 +492,6 @@
<ClInclude Include="src\PlaylistImporter.h"> <ClInclude Include="src\PlaylistImporter.h">
<Filter>Header Files\Misc</Filter> <Filter>Header Files\Misc</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src\WinSevenTaskbar.h">
<Filter>Header Files\Misc</Filter>
</ClInclude>
<ClInclude Include="src\Global.h"> <ClInclude Include="src\Global.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>

View File

@ -34,8 +34,8 @@
#define VER_LAMEXP_MINOR_HI 1 #define VER_LAMEXP_MINOR_HI 1
#define VER_LAMEXP_MINOR_LO 1 #define VER_LAMEXP_MINOR_LO 1
#define VER_LAMEXP_TYPE Beta #define VER_LAMEXP_TYPE Beta
#define VER_LAMEXP_PATCH 8 #define VER_LAMEXP_PATCH 9
#define VER_LAMEXP_BUILD 1632 #define VER_LAMEXP_BUILD 1636
#define VER_LAMEXP_CONFG 1558 #define VER_LAMEXP_CONFG 1558
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -40,7 +40,6 @@
#include "Model_Settings.h" #include "Model_Settings.h"
#include "Model_FileList.h" #include "Model_FileList.h"
#include "Model_FileSystem.h" #include "Model_FileSystem.h"
#include "WinSevenTaskbar.h"
#include "Registry_Encoder.h" #include "Registry_Encoder.h"
#include "Registry_Decoder.h" #include "Registry_Decoder.h"
#include "Encoder_Abstract.h" #include "Encoder_Abstract.h"
@ -1269,7 +1268,7 @@ bool MainWindow::winEvent(MSG *message, long *result)
*result = 0; *result = 0;
return true; return true;
} }
return WinSevenTaskbar::handleWinEvent(message, result); return false;
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -41,7 +41,6 @@
#include "Filter_Normalize.h" #include "Filter_Normalize.h"
#include "Filter_Resample.h" #include "Filter_Resample.h"
#include "Filter_ToneAdjust.h" #include "Filter_ToneAdjust.h"
#include "WinSevenTaskbar.h"
//MUtils //MUtils
#include <MUtils/Global.h> #include <MUtils/Global.h>
@ -49,6 +48,7 @@
#include <MUtils/GUI.h> #include <MUtils/GUI.h>
#include <MUtils/CPUFeatures.h> #include <MUtils/CPUFeatures.h>
#include <MUtils/Sound.h> #include <MUtils/Sound.h>
#include <MUtils/Taskbar7.h>
//Qt //Qt
#include <QApplication> #include <QApplication>
@ -153,6 +153,7 @@ ProcessingDialog::ProcessingDialog(FileListModel *fileListModel, const AudioFile
QDialog(parent), QDialog(parent),
ui(new Ui::ProcessingDialog), ui(new Ui::ProcessingDialog),
m_systemTray(new QSystemTrayIcon(QIcon(":/icons/cd_go.png"), this)), m_systemTray(new QSystemTrayIcon(QIcon(":/icons/cd_go.png"), this)),
m_taskbar(new MUtils::Taskbar7(this)),
m_settings(settings), m_settings(settings),
m_metaInfo(metaInfo), m_metaInfo(metaInfo),
m_shutdownFlag(SHUTDOWN_FLAG_NONE), m_shutdownFlag(SHUTDOWN_FLAG_NONE),
@ -360,8 +361,8 @@ ProcessingDialog::~ProcessingDialog(void)
MUTILS_DELETE(m_threadPool); MUTILS_DELETE(m_threadPool);
MUTILS_DELETE(m_defaultColor); MUTILS_DELETE(m_defaultColor);
WinSevenTaskbar::setOverlayIcon(this, NULL); m_taskbar->setOverlayIcon(NULL);
WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNoState); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_NONE);
MUTILS_DELETE(ui); MUTILS_DELETE(ui);
} }
@ -477,11 +478,6 @@ void ProcessingDialog::resizeEvent(QResizeEvent *event)
} }
} }
bool ProcessingDialog::winEvent(MSG *message, long *result)
{
return WinSevenTaskbar::handleWinEvent(message, result);
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// SLOTS // SLOTS
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -511,9 +507,9 @@ void ProcessingDialog::initEncoding(void)
ui->checkBox_shutdownComputer->setEnabled(true); ui->checkBox_shutdownComputer->setEnabled(true);
ui->checkBox_shutdownComputer->setChecked(false); ui->checkBox_shutdownComputer->setChecked(false);
WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNormalState); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_NORMAL);
WinSevenTaskbar::setTaskbarProgress(this, 0, m_pendingJobs.count()); m_taskbar->setTaskbarProgress(0, m_pendingJobs.count());
WinSevenTaskbar::setOverlayIcon(this, &QIcon(":/icons/control_play_blue.png")); m_taskbar->setOverlayIcon(&QIcon(":/icons/control_play_blue.png"));
if(!m_diskObserver) if(!m_diskObserver)
{ {
@ -669,7 +665,7 @@ void ProcessingDialog::doneEncoding(void)
if(!m_userAborted) if(!m_userAborted)
{ {
SET_PROGRESS_TEXT(tr("Encoding: %n file(s) of %1 completed so far, please wait...", "", ui->progressBar->value()).arg(QString::number(ui->progressBar->maximum()))); SET_PROGRESS_TEXT(tr("Encoding: %n file(s) of %1 completed so far, please wait...", "", ui->progressBar->value()).arg(QString::number(ui->progressBar->maximum())));
WinSevenTaskbar::setTaskbarProgress(this, ui->progressBar->value(), ui->progressBar->maximum()); m_taskbar->setTaskbarProgress(ui->progressBar->value(), ui->progressBar->maximum());
} }
if((!m_pendingJobs.isEmpty()) && (!m_userAborted)) if((!m_pendingJobs.isEmpty()) && (!m_userAborted))
@ -698,8 +694,8 @@ void ProcessingDialog::doneEncoding(void)
if(m_userAborted) if(m_userAborted)
{ {
CHANGE_BACKGROUND_COLOR(ui->frame_header, QColor("#FFFFE0")); CHANGE_BACKGROUND_COLOR(ui->frame_header, QColor("#FFFFE0"));
WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarErrorState); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_ERROR);
WinSevenTaskbar::setOverlayIcon(this, &QIcon(":/icons/error.png")); m_taskbar->setOverlayIcon(&QIcon(":/icons/error.png"));
SET_PROGRESS_TEXT((m_succeededJobs.count() > 0) ? tr("Process was aborted by the user after %n file(s)!", "", m_succeededJobs.count()) : tr("Process was aborted prematurely by the user!")); SET_PROGRESS_TEXT((m_succeededJobs.count() > 0) ? tr("Process was aborted by the user after %n file(s)!", "", m_succeededJobs.count()) : tr("Process was aborted prematurely by the user!"));
m_systemTray->showMessage(tr("LameXP - Aborted"), tr("Process was aborted by the user."), QSystemTrayIcon::Warning); m_systemTray->showMessage(tr("LameXP - Aborted"), tr("Process was aborted by the user."), QSystemTrayIcon::Warning);
m_systemTray->setIcon(QIcon(":/icons/cd_delete.png")); m_systemTray->setIcon(QIcon(":/icons/cd_delete.png"));
@ -717,8 +713,8 @@ void ProcessingDialog::doneEncoding(void)
if(m_failedJobs.count() > 0) if(m_failedJobs.count() > 0)
{ {
CHANGE_BACKGROUND_COLOR(ui->frame_header, QColor("#FFF0F0")); CHANGE_BACKGROUND_COLOR(ui->frame_header, QColor("#FFF0F0"));
WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarErrorState); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_ERROR);
WinSevenTaskbar::setOverlayIcon(this, &QIcon(":/icons/exclamation.png")); m_taskbar->setOverlayIcon(&QIcon(":/icons/exclamation.png"));
if(m_skippedJobs.count() > 0) if(m_skippedJobs.count() > 0)
{ {
SET_PROGRESS_TEXT(tr("Error: %1 of %n file(s) failed (%2). Double-click failed items for detailed information!", "", m_failedJobs.count() + m_succeededJobs.count() + m_skippedJobs.count()).arg(QString::number(m_failedJobs.count()), tr("%n file(s) skipped", "", m_skippedJobs.count()))); SET_PROGRESS_TEXT(tr("Error: %1 of %n file(s) failed (%2). Double-click failed items for detailed information!", "", m_failedJobs.count() + m_succeededJobs.count() + m_skippedJobs.count()).arg(QString::number(m_failedJobs.count()), tr("%n file(s) skipped", "", m_skippedJobs.count())));
@ -735,8 +731,8 @@ void ProcessingDialog::doneEncoding(void)
else else
{ {
CHANGE_BACKGROUND_COLOR(ui->frame_header, QColor("#F0FFF0")); CHANGE_BACKGROUND_COLOR(ui->frame_header, QColor("#F0FFF0"));
WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNormalState); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_NORMAL);
WinSevenTaskbar::setOverlayIcon(this, &QIcon(":/icons/accept.png")); m_taskbar->setOverlayIcon(&QIcon(":/icons/accept.png"));
if(m_skippedJobs.count() > 0) if(m_skippedJobs.count() > 0)
{ {
SET_PROGRESS_TEXT(tr("All files completed successfully. Skipped %n file(s).", "", m_skippedJobs.count())); SET_PROGRESS_TEXT(tr("All files completed successfully. Skipped %n file(s).", "", m_skippedJobs.count()));
@ -761,7 +757,7 @@ void ProcessingDialog::doneEncoding(void)
ui->view_log->scrollToBottom(); ui->view_log->scrollToBottom();
m_progressIndicator->stop(); m_progressIndicator->stop();
ui->progressBar->setValue(ui->progressBar->maximum()); ui->progressBar->setValue(ui->progressBar->maximum());
WinSevenTaskbar::setTaskbarProgress(this, ui->progressBar->value(), ui->progressBar->maximum()); m_taskbar->setTaskbarProgress(ui->progressBar->value(), ui->progressBar->maximum());
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();

View File

@ -53,10 +53,17 @@ enum lamexp_shutdownFlag_t
}; };
//UIC forward declartion //UIC forward declartion
namespace Ui { namespace Ui
{
class ProcessingDialog; class ProcessingDialog;
} }
//MUtils forward declartion
namespace MUtils
{
class Taskbar7;
}
//ProcessingDialog class //ProcessingDialog class
class ProcessingDialog : public QDialog class ProcessingDialog : public QDialog
{ {
@ -96,7 +103,6 @@ protected:
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
bool eventFilter(QObject *obj, QEvent *event); bool eventFilter(QObject *obj, QEvent *event);
virtual bool event(QEvent *e); virtual bool event(QEvent *e);
virtual bool winEvent(MSG *message, long *result);
virtual void resizeEvent(QResizeEvent *event); virtual void resizeEvent(QResizeEvent *event);
private: private:
@ -136,4 +142,5 @@ private:
QScopedPointer<QElapsedTimer> m_totalTime; QScopedPointer<QElapsedTimer> m_totalTime;
int m_progressViewFilter; int m_progressViewFilter;
QColor *m_defaultColor; QColor *m_defaultColor;
QScopedPointer<MUtils::Taskbar7> m_taskbar;
}; };

View File

@ -22,13 +22,16 @@
#include "Dialog_SplashScreen.h" #include "Dialog_SplashScreen.h"
//UIC includes
#include "UIC_SplashScreen.h"
//Internal //Internal
#include "Global.h" #include "Global.h"
#include "WinSevenTaskbar.h"
//MUtils //MUtils
#include <MUtils/Global.h> #include <MUtils/Global.h>
#include <MUtils/GUI.h> #include <MUtils/GUI.h>
#include <MUtils/Taskbar7.h>
//Qt //Qt
#include <QThread> #include <QThread>
@ -40,15 +43,14 @@
#define OPACITY_DELTA 0.04 #define OPACITY_DELTA 0.04
//Setup taskbar indicator //Setup taskbar indicator
#define SET_TASKBAR_STATE(WIDGET,VAR,FLAG) do \ #define SET_TASKBAR_STATE(WIDGET,FLAG) do \
{ \ { \
if(FLAG) \ if((WIDGET)->m_taskBarFlag != (FLAG)) \
{ \ { \
if(!(VAR)) (VAR) = WinSevenTaskbar::setTaskbarState((WIDGET), WinSevenTaskbar::WinSevenTaskbarIndeterminateState); \ if((WIDGET)->m_taskbar->setTaskbarState((FLAG) ? MUtils::Taskbar7::TASKBAR_STATE_INTERMEDIATE : MUtils::Taskbar7::TASKBAR_STATE_NONE)) \
} \ { \
else \ (WIDGET)->m_taskBarFlag = (FLAG); \
{ \ } \
if((VAR)) (VAR) = (!WinSevenTaskbar::setTaskbarState((WIDGET), WinSevenTaskbar::WinSevenTaskbarNoState)); \
} \ } \
} \ } \
while(0) while(0)
@ -59,25 +61,27 @@ while(0)
SplashScreen::SplashScreen(QWidget *parent) SplashScreen::SplashScreen(QWidget *parent)
: :
QFrame(parent, Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint),
ui(new Ui::SplashScreen),
m_opacitySteps(qRound(1.0 / OPACITY_DELTA)), m_opacitySteps(qRound(1.0 / OPACITY_DELTA)),
QFrame(parent, Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint) m_taskbar(new MUtils::Taskbar7(this))
{ {
//Init the dialog, from the .ui file //Init the dialog, from the .ui file
setupUi(this); ui->setupUi(this);
//Make size fixed //Make size fixed
setFixedSize(this->size()); setFixedSize(this->size());
//Create event loop //Create event loop
m_loop = new QEventLoop(this); m_loop.reset(new QEventLoop(this));
//Create timer //Create timer
m_timer = new QTimer(this); m_timer.reset(new QTimer(this));
m_timer->setInterval(FADE_DELAY); m_timer->setInterval(FADE_DELAY);
m_timer->setSingleShot(false); m_timer->setSingleShot(false);
//Connect timer to slot //Connect timer to slot
connect(m_timer, SIGNAL(timeout()), this, SLOT(updateHandler())); connect(m_timer.data(), SIGNAL(timeout()), this, SLOT(updateHandler()));
//Enable "sheet of glass" effect on splash screen //Enable "sheet of glass" effect on splash screen
if(!MUtils::GUI::sheet_of_glass(this)) if(!MUtils::GUI::sheet_of_glass(this))
@ -86,16 +90,16 @@ SplashScreen::SplashScreen(QWidget *parent)
} }
//Start animation //Start animation
m_working = new QMovie(":/images/Loading4.gif"); m_working.reset(new QMovie(":/images/Loading4.gif"));
m_working->setCacheMode(QMovie::CacheAll); m_working->setCacheMode(QMovie::CacheAll);
labelLoading->setMovie(m_working); ui->labelLoading->setMovie(m_working.data());
m_working->start(); m_working->start();
//Init status //Init status
m_canClose = false; m_canClose = false;
m_status = STATUS_FADE_IN; m_status = STATUS_FADE_IN;
m_fadeValue = 0; m_fadeValue = 0;
m_taskBarInit = false; m_taskBarFlag = false;
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -109,9 +113,7 @@ SplashScreen::~SplashScreen(void)
m_working->stop(); m_working->stop();
} }
MUTILS_DELETE(m_working); delete ui;
MUTILS_DELETE(m_loop);
MUTILS_DELETE(m_timer);
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -120,7 +122,7 @@ SplashScreen::~SplashScreen(void)
void SplashScreen::showSplash(QThread *thread) void SplashScreen::showSplash(QThread *thread)
{ {
SplashScreen *splashScreen = new SplashScreen(); QScopedPointer<SplashScreen> splashScreen(new SplashScreen());
//Show splash //Show splash
splashScreen->setWindowOpacity(OPACITY_DELTA); splashScreen->setWindowOpacity(OPACITY_DELTA);
@ -131,19 +133,19 @@ void SplashScreen::showSplash(QThread *thread)
//Wait for window to show //Wait for window to show
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
splashScreen->repaint(); MUtils::GUI::bring_to_front(splashScreen); splashScreen->repaint(); MUtils::GUI::bring_to_front(splashScreen.data());
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
//Connect thread signals //Connect thread signals
connect(thread, SIGNAL(terminated()), splashScreen, SLOT(threadComplete()), Qt::QueuedConnection); connect(thread, SIGNAL(terminated()), splashScreen.data(), SLOT(threadComplete()), Qt::QueuedConnection);
connect(thread, SIGNAL(finished()), splashScreen, SLOT(threadComplete()), Qt::QueuedConnection); connect(thread, SIGNAL(finished()), splashScreen.data(), SLOT(threadComplete()), Qt::QueuedConnection);
//Init taskbar //Init taskbar
SET_TASKBAR_STATE(splashScreen, splashScreen->m_taskBarInit, true); SET_TASKBAR_STATE(splashScreen, true);
//Start the thread //Start the thread
splashScreen->m_timer->start(FADE_DELAY); splashScreen->m_timer->start(FADE_DELAY);
QTimer::singleShot(8*60*1000, splashScreen->m_loop, SLOT(quit())); QTimer::singleShot(8*60*1000, splashScreen->m_loop.data(), SLOT(quit()));
QTimer::singleShot(333, thread, SLOT(start())); QTimer::singleShot(333, thread, SLOT(start()));
//Start event handling! //Start event handling!
@ -157,7 +159,7 @@ void SplashScreen::showSplash(QThread *thread)
} }
//Restore taskbar //Restore taskbar
SET_TASKBAR_STATE(splashScreen, splashScreen->m_taskBarInit, false); SET_TASKBAR_STATE(splashScreen, false);
//Restore cursor //Restore cursor
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
@ -165,9 +167,6 @@ void SplashScreen::showSplash(QThread *thread)
//Hide splash //Hide splash
splashScreen->m_canClose = true; splashScreen->m_canClose = true;
splashScreen->close(); splashScreen->close();
//Free
MUTILS_DELETE(splashScreen);
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -181,7 +180,7 @@ void SplashScreen::updateHandler(void)
if(m_fadeValue < m_opacitySteps) if(m_fadeValue < m_opacitySteps)
{ {
setWindowOpacity(OPACITY_DELTA * static_cast<double>(++m_fadeValue)); setWindowOpacity(OPACITY_DELTA * static_cast<double>(++m_fadeValue));
SET_TASKBAR_STATE(this, m_taskBarInit, true); SET_TASKBAR_STATE(this, true);
} }
else else
{ {
@ -196,7 +195,7 @@ void SplashScreen::updateHandler(void)
if(m_fadeValue > 0) if(m_fadeValue > 0)
{ {
setWindowOpacity(OPACITY_DELTA * static_cast<double>(--m_fadeValue)); setWindowOpacity(OPACITY_DELTA * static_cast<double>(--m_fadeValue));
SET_TASKBAR_STATE(this, m_taskBarInit, true); SET_TASKBAR_STATE(this, true);
} }
else else
{ {
@ -236,8 +235,3 @@ void SplashScreen::closeEvent(QCloseEvent *event)
{ {
if(!m_canClose) event->ignore(); if(!m_canClose) event->ignore();
} }
bool SplashScreen::winEvent(MSG *message, long *result)
{
return WinSevenTaskbar::handleWinEvent(message, result);
}

View File

@ -24,21 +24,33 @@
#include "UIC_SplashScreen.h" #include "UIC_SplashScreen.h"
//MUtils forward declaration
namespace MUtils
{
class Taskbar7;
}
//UIC forward declartion
namespace Ui
{
class SplashScreen;
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Splash Frame // Splash Frame
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
class SplashScreen: public QFrame, private Ui::SplashScreen class SplashScreen: public QFrame
{ {
Q_OBJECT Q_OBJECT
public: public:
static void showSplash(QThread *thread);
private:
SplashScreen(QWidget *parent = 0); SplashScreen(QWidget *parent = 0);
~SplashScreen(void); ~SplashScreen(void);
static void showSplash(QThread *thread);
private:
enum enum
{ {
STATUS_FADE_IN = 0, STATUS_FADE_IN = 0,
@ -48,9 +60,12 @@ private:
} }
status_t; status_t;
QMovie *m_working; Ui::SplashScreen *ui; //for Qt UIC
QEventLoop *m_loop;
QTimer *m_timer; QScopedPointer<QMovie> m_working;
QScopedPointer<QEventLoop> m_loop;
QScopedPointer<QTimer> m_timer;
QScopedPointer<MUtils::Taskbar7> m_taskbar;
const unsigned int m_opacitySteps; const unsigned int m_opacitySteps;
@ -58,7 +73,7 @@ private:
unsigned int m_fadeValue; unsigned int m_fadeValue;
volatile bool m_canClose; volatile bool m_canClose;
volatile bool m_taskBarInit; volatile bool m_taskBarFlag;
private slots: private slots:
void updateHandler(void); void updateHandler(void);
@ -68,5 +83,4 @@ protected:
void keyPressEvent(QKeyEvent *event); void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event); void keyReleaseEvent(QKeyEvent *event);
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
bool winEvent(MSG *message, long *result);
}; };

View File

@ -29,7 +29,6 @@
#include "Global.h" #include "Global.h"
#include "Dialog_LogView.h" #include "Dialog_LogView.h"
#include "Model_Settings.h" #include "Model_Settings.h"
#include "WinSevenTaskbar.h"
//MUtils //MUtils
#include <MUtils/UpdateChecker.h> #include <MUtils/UpdateChecker.h>
@ -38,7 +37,7 @@
#include <MUtils/Sound.h> #include <MUtils/Sound.h>
#include <MUtils/GUI.h> #include <MUtils/GUI.h>
#include <MUtils/OSSupport.h> #include <MUtils/OSSupport.h>
#include <MUtils/Taskbar7.h>
//Qt includes //Qt includes
#include <QClipboard> #include <QClipboard>
@ -64,18 +63,18 @@ while(0)
#define UPDATE_TASKBAR(STATE, ICON) do \ #define UPDATE_TASKBAR(STATE, ICON) do \
{ \ { \
WinSevenTaskbar::setTaskbarState(this->parentWidget(), (STATE)); \ m_taskbar->setTaskbarState((STATE)); \
WinSevenTaskbar::setOverlayIcon(this->parentWidget(), &QIcon((ICON))); \ m_taskbar->setOverlayIcon(&QIcon((ICON))); \
} \ } \
while(0) while(0)
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
UpdateDialog::UpdateDialog(SettingsModel *settings, QWidget *parent) UpdateDialog::UpdateDialog(const SettingsModel *const settings, QWidget *parent)
: :
QDialog(parent), QDialog(parent),
ui(new Ui::UpdateDialog), ui(new Ui::UpdateDialog),
m_thread(NULL), m_taskbar(new MUtils::Taskbar7(parent)),
m_settings(settings), m_settings(settings),
m_logFile(new QStringList()), m_logFile(new QStringList()),
m_betaUpdates(settings ? (settings->autoUpdateCheckBeta() || lamexp_version_demo()) : lamexp_version_demo()), m_betaUpdates(settings ? (settings->autoUpdateCheckBeta() || lamexp_version_demo()) : lamexp_version_demo()),
@ -101,8 +100,8 @@ UpdateDialog::UpdateDialog(SettingsModel *settings, QWidget *parent)
MUtils::GUI::enable_close_button(this, false); MUtils::GUI::enable_close_button(this, false);
//Init animation //Init animation
m_animator = new QMovie(":/images/Loading3.gif"); m_animator.reset(new QMovie(":/images/Loading3.gif"));
ui->labelAnimationCenter->setMovie(m_animator); ui->labelAnimationCenter->setMovie(m_animator.data());
m_animator->start(); m_animator->start();
//Indicate beta updates //Indicate beta updates
@ -128,7 +127,7 @@ UpdateDialog::~UpdateDialog(void)
m_animator->stop(); m_animator->stop();
} }
if(m_thread) if(!m_thread.isNull())
{ {
if(!m_thread->wait(1000)) if(!m_thread->wait(1000))
{ {
@ -137,14 +136,10 @@ UpdateDialog::~UpdateDialog(void)
} }
} }
MUTILS_DELETE(m_thread); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_NONE);
MUTILS_DELETE(m_logFile); m_taskbar->setOverlayIcon(NULL);
MUTILS_DELETE(m_animator);
WinSevenTaskbar::setTaskbarState(this->parentWidget(), WinSevenTaskbar::WinSevenTaskbarNoState); delete ui;
WinSevenTaskbar::setOverlayIcon(this->parentWidget(), NULL);
MUTILS_DELETE(ui);
} }
void UpdateDialog::showEvent(QShowEvent *event) void UpdateDialog::showEvent(QShowEvent *event)
@ -153,14 +148,14 @@ void UpdateDialog::showEvent(QShowEvent *event)
if(m_firstShow) if(m_firstShow)
{ {
if(!m_thread) if(m_thread.isNull())
{ {
m_thread = new MUtils::UpdateChecker(m_binaryWGet, m_binaryGnuPG, m_binaryKeys, QLatin1String("LameXP"), lamexp_version_build(), m_betaUpdates); m_thread.reset(new MUtils::UpdateChecker(m_binaryWGet, m_binaryGnuPG, m_binaryKeys, QLatin1String("LameXP"), lamexp_version_build(), m_betaUpdates));
connect(m_thread, SIGNAL(statusChanged(int)), this, SLOT(threadStatusChanged(int))); connect(m_thread.data(), SIGNAL(statusChanged(int)), this, SLOT(threadStatusChanged(int)));
connect(m_thread, SIGNAL(progressChanged(int)), this, SLOT(threadProgressChanged(int))); connect(m_thread.data(), SIGNAL(progressChanged(int)), this, SLOT(threadProgressChanged(int)));
connect(m_thread, SIGNAL(messageLogged(QString)), this, SLOT(threadMessageLogged(QString))); connect(m_thread.data(), SIGNAL(messageLogged(QString)), this, SLOT(threadMessageLogged(QString)));
connect(m_thread, SIGNAL(finished()), this, SLOT(threadFinished())); connect(m_thread.data(), SIGNAL(finished()), this, SLOT(threadFinished()));
connect(m_thread, SIGNAL(terminated()), this, SLOT(threadFinished())); connect(m_thread.data(), SIGNAL(terminated()), this, SLOT(threadFinished()));
} }
threadStatusChanged(m_thread->getUpdateStatus()); threadStatusChanged(m_thread->getUpdateStatus());
@ -196,8 +191,8 @@ void UpdateDialog::closeEvent(QCloseEvent *event)
} }
else else
{ {
WinSevenTaskbar::setTaskbarState(this->parentWidget(), WinSevenTaskbar::WinSevenTaskbarNoState); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_NONE);
WinSevenTaskbar::setOverlayIcon(this->parentWidget(), NULL); m_taskbar->setOverlayIcon(NULL);
} }
} }
@ -226,11 +221,6 @@ bool UpdateDialog::event(QEvent *e)
return QDialog::event(e); return QDialog::event(e);
} }
bool UpdateDialog::winEvent(MSG *message, long *result)
{
return WinSevenTaskbar::handleWinEvent(message, result);
}
void UpdateDialog::updateInit(void) void UpdateDialog::updateInit(void)
{ {
setMinimumSize(size()); setMinimumSize(size());
@ -258,8 +248,8 @@ void UpdateDialog::checkForUpdates(void)
} }
} }
WinSevenTaskbar::setTaskbarState(this->parentWidget(), WinSevenTaskbar::WinSevenTaskbarNormalState); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_NORMAL);
WinSevenTaskbar::setOverlayIcon(this->parentWidget(), &QIcon(":/icons/transmit_blue.png")); m_taskbar->setOverlayIcon(&QIcon(":/icons/transmit_blue.png"));
ui->progressBar->setValue(0); ui->progressBar->setValue(0);
ui->installButton->setEnabled(false); ui->installButton->setEnabled(false);
@ -294,32 +284,32 @@ void UpdateDialog::threadStatusChanged(const int status)
case MUtils::UpdateChecker::UpdateStatus_CompletedUpdateAvailable: case MUtils::UpdateChecker::UpdateStatus_CompletedUpdateAvailable:
ui->statusLabel->setText(tr("A new version of LameXP is available!")); ui->statusLabel->setText(tr("A new version of LameXP is available!"));
SHOW_HINT(tr("We highly recommend all users to install this update as soon as possible."), ":/icons/shield_exclamation.png"); SHOW_HINT(tr("We highly recommend all users to install this update as soon as possible."), ":/icons/shield_exclamation.png");
UPDATE_TASKBAR(WinSevenTaskbar::WinSevenTaskbarNormalState, ":/icons/shield_exclamation.png"); UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_NORMAL, ":/icons/shield_exclamation.png");
break; break;
case MUtils::UpdateChecker::UpdateStatus_CompletedNoUpdates: case MUtils::UpdateChecker::UpdateStatus_CompletedNoUpdates:
ui->statusLabel->setText(tr("No new updates available at this time.")); ui->statusLabel->setText(tr("No new updates available at this time."));
SHOW_HINT(tr("Your version of LameXP is still up-to-date. Please check for updates regularly!"), ":/icons/shield_green.png"); SHOW_HINT(tr("Your version of LameXP is still up-to-date. Please check for updates regularly!"), ":/icons/shield_green.png");
UPDATE_TASKBAR(WinSevenTaskbar::WinSevenTaskbarNormalState, ":/icons/shield_green.png"); UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_NORMAL, ":/icons/shield_green.png");
break; break;
case MUtils::UpdateChecker::UpdateStatus_CompletedNewVersionOlder: case MUtils::UpdateChecker::UpdateStatus_CompletedNewVersionOlder:
ui->statusLabel->setText(tr("Your version appears to be newer than the latest release.")); ui->statusLabel->setText(tr("Your version appears to be newer than the latest release."));
SHOW_HINT(tr("This usually indicates your are currently using a pre-release version of LameXP."), ":/icons/shield_blue.png"); SHOW_HINT(tr("This usually indicates your are currently using a pre-release version of LameXP."), ":/icons/shield_blue.png");
UPDATE_TASKBAR(WinSevenTaskbar::WinSevenTaskbarNormalState, ":/icons/shield_error.png"); UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_NORMAL, ":/icons/shield_error.png");
break; break;
case MUtils::UpdateChecker::UpdateStatus_ErrorNoConnection: case MUtils::UpdateChecker::UpdateStatus_ErrorNoConnection:
ui->statusLabel->setText(tr("It appears that the computer currently is offline!")); ui->statusLabel->setText(tr("It appears that the computer currently is offline!"));
SHOW_HINT(tr("Please make sure your computer is connected to the internet and try again."), ":/icons/network_error.png"); SHOW_HINT(tr("Please make sure your computer is connected to the internet and try again."), ":/icons/network_error.png");
UPDATE_TASKBAR(WinSevenTaskbar::WinSevenTaskbarErrorState, ":/icons/exclamation.png"); UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_NORMAL, ":/icons/exclamation.png");
break; break;
case MUtils::UpdateChecker::UpdateStatus_ErrorConnectionTestFailed: case MUtils::UpdateChecker::UpdateStatus_ErrorConnectionTestFailed:
ui->statusLabel->setText(tr("Network connectivity test has failed!")); ui->statusLabel->setText(tr("Network connectivity test has failed!"));
SHOW_HINT(tr("Please make sure your computer is connected to the internet and try again."), ":/icons/network_error.png"); SHOW_HINT(tr("Please make sure your computer is connected to the internet and try again."), ":/icons/network_error.png");
UPDATE_TASKBAR(WinSevenTaskbar::WinSevenTaskbarErrorState, ":/icons/exclamation.png"); UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_NORMAL, ":/icons/exclamation.png");
break; break;
case MUtils::UpdateChecker::UpdateStatus_ErrorFetchUpdateInfo: case MUtils::UpdateChecker::UpdateStatus_ErrorFetchUpdateInfo:
ui->statusLabel->setText(tr("Failed to fetch update information from server!")); ui->statusLabel->setText(tr("Failed to fetch update information from server!"));
SHOW_HINT(tr("Sorry, the update server might be busy at this time. Plase try again later."), ":/icons/server_error.png"); SHOW_HINT(tr("Sorry, the update server might be busy at this time. Plase try again later."), ":/icons/server_error.png");
UPDATE_TASKBAR(WinSevenTaskbar::WinSevenTaskbarErrorState, ":/icons/exclamation.png"); UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_NORMAL, ":/icons/exclamation.png");
break; break;
default: default:
qWarning("Unknown status %d !!!", int(status)); qWarning("Unknown status %d !!!", int(status));
@ -411,7 +401,7 @@ void UpdateDialog::applyUpdate(void)
args << QString("/AppTitle=LameXP (Build #%1)").arg(QString::number(updateInfo->getBuildNo())); args << QString("/AppTitle=LameXP (Build #%1)").arg(QString::number(updateInfo->getBuildNo()));
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
UPDATE_TASKBAR(WinSevenTaskbar::WinSevenTaskbarIndeterminateState, ":/icons/transmit_blue.png"); UPDATE_TASKBAR(MUtils::Taskbar7::TASKBAR_STATE_INTERMEDIATE, ":/icons/transmit_blue.png");
process.start(m_binaryUpdater, args); process.start(m_binaryUpdater, args);
bool updateStarted = process.waitForStarted(); bool updateStarted = process.waitForStarted();
@ -434,16 +424,16 @@ void UpdateDialog::applyUpdate(void)
{ {
ui->statusLabel->setText(tr("Update ready to install. Applicaion will quit...")); ui->statusLabel->setText(tr("Update ready to install. Applicaion will quit..."));
m_updateReadyToInstall = true; m_updateReadyToInstall = true;
WinSevenTaskbar::setTaskbarState(this->parentWidget(), WinSevenTaskbar::WinSevenTaskbarNoState); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_NONE);
WinSevenTaskbar::setOverlayIcon(this->parentWidget(), NULL); m_taskbar->setOverlayIcon(NULL);
accept(); accept();
} }
else else
{ {
ui->statusLabel->setText(tr("Update failed. Please try again or download manually!")); ui->statusLabel->setText(tr("Update failed. Please try again or download manually!"));
WinSevenTaskbar::setTaskbarState(this->parentWidget(), WinSevenTaskbar::WinSevenTaskbarErrorState); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_ERROR);
WinSevenTaskbar::setOverlayIcon(this->parentWidget(), &QIcon(":/icons/exclamation.png")); m_taskbar->setOverlayIcon(&QIcon(":/icons/exclamation.png"));
WinSevenTaskbar::setTaskbarProgress(this->parentWidget(), 100, 100); m_taskbar->setTaskbarProgress(100, 100);
} }
} }
@ -460,7 +450,7 @@ void UpdateDialog::logButtonClicked(void)
void UpdateDialog::progressBarValueChanged(int value) void UpdateDialog::progressBarValueChanged(int value)
{ {
WinSevenTaskbar::setTaskbarProgress(this->parentWidget(), value, ui->progressBar->maximum()); m_taskbar->setTaskbarProgress(value, ui->progressBar->maximum());
} }
void UpdateDialog::testKnownHosts(void) void UpdateDialog::testKnownHosts(void)

View File

@ -31,10 +31,12 @@ class QMovie;
namespace MUtils namespace MUtils
{ {
class UpdateChecker; class UpdateChecker;
class Taskbar7;
} }
//UIC forward declartion //UIC forward declartion
namespace Ui { namespace Ui
{
class UpdateDialog; class UpdateDialog;
} }
@ -44,7 +46,7 @@ class UpdateDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
UpdateDialog(SettingsModel *settings, QWidget *parent = 0); UpdateDialog(const SettingsModel *const settings, QWidget *parent = 0);
~UpdateDialog(void); ~UpdateDialog(void);
bool getSuccess(void) { return m_success; } bool getSuccess(void) { return m_success; }
@ -67,23 +69,23 @@ protected:
virtual void showEvent(QShowEvent *event); virtual void showEvent(QShowEvent *event);
virtual void closeEvent(QCloseEvent *event); virtual void closeEvent(QCloseEvent *event);
virtual void keyPressEvent(QKeyEvent *e); virtual void keyPressEvent(QKeyEvent *e);
virtual bool winEvent(MSG *message, long *result);
virtual bool event(QEvent *e); virtual bool event(QEvent *e);
const bool m_betaUpdates; const bool m_betaUpdates;
private: private:
Ui::UpdateDialog *ui; //for Qt UIC Ui::UpdateDialog *const ui; //for Qt UIC
const SettingsModel *const m_settings;
const QString m_binaryWGet; const QString m_binaryWGet;
const QString m_binaryGnuPG; const QString m_binaryGnuPG;
const QString m_binaryKeys; const QString m_binaryKeys;
const QString m_binaryUpdater; const QString m_binaryUpdater;
MUtils::UpdateChecker *m_thread; QScopedPointer<MUtils::Taskbar7> m_taskbar;
QStringList *m_logFile; QScopedPointer<MUtils::UpdateChecker> m_thread;
SettingsModel *m_settings; QScopedPointer<QStringList> m_logFile;
QMovie *m_animator; QScopedPointer<QMovie> m_animator;
unsigned long m_updaterProcess; unsigned long m_updaterProcess;

View File

@ -25,11 +25,11 @@
//Internal //Internal
#include "Global.h" #include "Global.h"
#include "WinSevenTaskbar.h"
//MUtils //MUtils
#include <MUtils/Global.h> #include <MUtils/Global.h>
#include <MUtils/GUI.h> #include <MUtils/GUI.h>
#include <MUtils/Taskbar7.h>
//Qt //Qt
#include <QThread> #include <QThread>
@ -84,7 +84,9 @@ static inline void UPDATE_MARGINS(QWidget *control, int l = 0, int r = 0, int t
WorkingBanner::WorkingBanner(QWidget *parent) WorkingBanner::WorkingBanner(QWidget *parent)
: :
QDialog(parent, Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint), QDialog(parent, Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint),
ui(new Ui::WorkingBanner()), m_metrics(NULL), m_working(NULL), m_style(NULL) ui(new Ui::WorkingBanner()),
m_taskbar(new MUtils::Taskbar7(parent)),
m_metrics(NULL), m_working(NULL), m_style(NULL)
{ {
//Init the dialog, from the .ui file //Init the dialog, from the .ui file
ui->setupUi(this); ui->setupUi(this);
@ -93,18 +95,18 @@ WorkingBanner::WorkingBanner(QWidget *parent)
//Enable the "sheet of glass" effect //Enable the "sheet of glass" effect
if(MUtils::GUI::sheet_of_glass(this)) if(MUtils::GUI::sheet_of_glass(this))
{ {
m_style = new QWindowsVistaStyle(); m_style.reset(new QWindowsVistaStyle());
this->setStyle(m_style); this->setStyle(m_style.data());
ui->progressBar->setStyle(m_style); ui->progressBar->setStyle(m_style.data());
ui->labelStatus->setStyle(m_style); ui->labelStatus->setStyle(m_style.data());
ui->labelStatus->setStyleSheet("background-color: #FFFFFF;"); ui->labelStatus->setStyleSheet("background-color: #FFFFFF;");
} }
else else
{ {
UPDATE_MARGINS(this, 5); UPDATE_MARGINS(this, 5);
m_working = new QMovie(":/images/Busy.gif"); m_working.reset(new QMovie(":/images/Busy.gif"));
m_working->setCacheMode(QMovie::CacheAll); m_working->setCacheMode(QMovie::CacheAll);
ui->labelWorking->setMovie(m_working); ui->labelWorking->setMovie(m_working.data());
} }
//Set Opacity //Set Opacity
@ -123,14 +125,11 @@ WorkingBanner::WorkingBanner(QWidget *parent)
WorkingBanner::~WorkingBanner(void) WorkingBanner::~WorkingBanner(void)
{ {
if(m_working) if(!m_working.isNull())
{ {
m_working->stop(); m_working->stop();
MUTILS_DELETE(m_working);
} }
MUTILS_DELETE(m_style);
MUTILS_DELETE(m_metrics);
delete ui; delete ui;
} }
@ -163,8 +162,8 @@ void WorkingBanner::show(const QString &text, QThread *thread)
connect(thread, SIGNAL(terminated()), loop, SLOT(quit())); connect(thread, SIGNAL(terminated()), loop, SLOT(quit()));
//Set taskbar state //Set taskbar state
WinSevenTaskbar::setOverlayIcon(dynamic_cast<QWidget*>(this->parent()), &QIcon(":/icons/hourglass.png")); m_taskbar->setOverlayIcon(&QIcon(":/icons/hourglass.png"));
WinSevenTaskbar::setTaskbarState(dynamic_cast<QWidget*>(this->parent()), WinSevenTaskbar::WinSevenTaskbarIndeterminateState); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_INTERMEDIATE);
//Start the thread //Start the thread
thread->start(); thread->start();
@ -182,8 +181,8 @@ void WorkingBanner::show(const QString &text, QThread *thread)
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
//Set taskbar state //Set taskbar state
WinSevenTaskbar::setTaskbarState(dynamic_cast<QWidget*>(this->parent()), WinSevenTaskbar::WinSevenTaskbarNoState); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_NONE);
WinSevenTaskbar::setOverlayIcon(dynamic_cast<QWidget*>(this->parent()), NULL); m_taskbar->setOverlayIcon(NULL);
//Free memory //Free memory
MUTILS_DELETE(loop); MUTILS_DELETE(loop);
@ -198,8 +197,8 @@ void WorkingBanner::show(const QString &text, QEventLoop *loop)
this->show(text); this->show(text);
//Set taskbar state //Set taskbar state
WinSevenTaskbar::setOverlayIcon(dynamic_cast<QWidget*>(this->parent()), &QIcon(":/icons/hourglass.png")); m_taskbar->setOverlayIcon(&QIcon(":/icons/hourglass.png"));
WinSevenTaskbar::setTaskbarState(dynamic_cast<QWidget*>(this->parent()), WinSevenTaskbar::WinSevenTaskbarIndeterminateState); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_INTERMEDIATE);
//Update cursor //Update cursor
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
@ -211,8 +210,8 @@ void WorkingBanner::show(const QString &text, QEventLoop *loop)
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
//Set taskbar state //Set taskbar state
WinSevenTaskbar::setTaskbarState(dynamic_cast<QWidget*>(this->parent()), WinSevenTaskbar::WinSevenTaskbarNoState); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_NONE);
WinSevenTaskbar::setOverlayIcon(dynamic_cast<QWidget*>(this->parent()), NULL); m_taskbar->setOverlayIcon(NULL);
//Hide splash //Hide splash
this->close(); this->close();
@ -254,11 +253,6 @@ void WorkingBanner::closeEvent(QCloseEvent *event)
if(!m_canClose) event->ignore(); if(!m_canClose) event->ignore();
} }
bool WorkingBanner::winEvent(MSG *message, long *result)
{
return WinSevenTaskbar::handleWinEvent(message, result);
}
void WorkingBanner::showEvent(QShowEvent *event) void WorkingBanner::showEvent(QShowEvent *event)
{ {
QDialog::showEvent(event); QDialog::showEvent(event);
@ -295,9 +289,9 @@ void WorkingBanner::windowShown(void)
void WorkingBanner::setText(const QString &text) void WorkingBanner::setText(const QString &text)
{ {
if(!m_metrics) if(m_metrics.isNull())
{ {
m_metrics = new QFontMetrics(ui->labelStatus->font()); m_metrics.reset(new QFontMetrics(ui->labelStatus->font()));
} }
if(m_metrics->width(text) <= ui->labelStatus->width() - 16) if(m_metrics->width(text) <= ui->labelStatus->width() - 16)
@ -322,12 +316,12 @@ void WorkingBanner::setProgressMax(unsigned int max)
ui->progressBar->setMaximum(max); ui->progressBar->setMaximum(max);
if(ui->progressBar->maximum() > ui->progressBar->minimum()) if(ui->progressBar->maximum() > ui->progressBar->minimum())
{ {
WinSevenTaskbar::setTaskbarState(dynamic_cast<QWidget*>(this->parent()), WinSevenTaskbar::WinSevenTaskbarNoState); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_NONE);
WinSevenTaskbar::setTaskbarProgress(dynamic_cast<QWidget*>(this->parent()), ui->progressBar->value(), ui->progressBar->maximum()); m_taskbar->setTaskbarProgress(ui->progressBar->value(), ui->progressBar->maximum());
} }
else else
{ {
WinSevenTaskbar::setTaskbarState(dynamic_cast<QWidget*>(this->parent()), WinSevenTaskbar::WinSevenTaskbarIndeterminateState); m_taskbar->setTaskbarState(MUtils::Taskbar7::TASKBAR_STATE_INTERMEDIATE);
} }
} }
@ -336,7 +330,7 @@ void WorkingBanner::setProgressVal(unsigned int val)
ui->progressBar->setValue(val); ui->progressBar->setValue(val);
if(ui->progressBar->maximum() > ui->progressBar->minimum()) if(ui->progressBar->maximum() > ui->progressBar->minimum())
{ {
WinSevenTaskbar::setTaskbarProgress(dynamic_cast<QWidget*>(this->parent()), ui->progressBar->value(), ui->progressBar->maximum()); m_taskbar->setTaskbarProgress(ui->progressBar->value(), ui->progressBar->maximum());
} }
} }

View File

@ -29,6 +29,11 @@ namespace Ui
class WorkingBanner; class WorkingBanner;
} }
namespace MUtils
{
class Taskbar7;
}
class QEventLoop; class QEventLoop;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -50,7 +55,9 @@ public:
private: private:
Ui::WorkingBanner *const ui; Ui::WorkingBanner *const ui;
QMovie *m_working; QScopedPointer<MUtils::Taskbar7> m_taskbar;
QScopedPointer<QMovie> m_working;
bool m_canClose; bool m_canClose;
public slots: public slots:
@ -67,10 +74,9 @@ protected:
virtual void keyPressEvent(QKeyEvent *event); virtual void keyPressEvent(QKeyEvent *event);
virtual void keyReleaseEvent(QKeyEvent *event); virtual void keyReleaseEvent(QKeyEvent *event);
virtual void closeEvent(QCloseEvent *event); virtual void closeEvent(QCloseEvent *event);
virtual bool winEvent(MSG *message, long *result);
virtual void showEvent(QShowEvent *event); virtual void showEvent(QShowEvent *event);
virtual void hideEvent(QHideEvent *event); virtual void hideEvent(QHideEvent *event);
QFontMetrics *m_metrics; QScopedPointer<QFontMetrics> m_metrics;
QStyle *m_style; QScopedPointer<QStyle> m_style;
}; };

View File

@ -31,7 +31,6 @@
#include "Model_FileList.h" #include "Model_FileList.h"
#include "Model_AudioFile.h" #include "Model_AudioFile.h"
#include "Encoder_Abstract.h" #include "Encoder_Abstract.h"
#include "WinSevenTaskbar.h"
//MUitls //MUitls
#include <MUtils/Global.h> #include <MUtils/Global.h>
@ -243,15 +242,9 @@ static int lamexp_main(int &argc, char **argv)
InitializationThread::selfTest(); InitializationThread::selfTest();
} }
//Taskbar init
WinSevenTaskbar::init();
//Main application loop //Main application loop
iResult = lamexp_main_loop(cpuFeatures, ipcChannel.data(), iShutdown); iResult = lamexp_main_loop(cpuFeatures, ipcChannel.data(), iShutdown);
//Taskbar un-init
WinSevenTaskbar::uninit();
//Final clean-up //Final clean-up
qDebug("Shutting down, please wait...\n"); qDebug("Shutting down, please wait...\n");

View File

@ -1,173 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
// Copyright (C) 2004-2014 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
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version, but always including the *additional*
// restrictions defined in the "License.txt" file.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/licenses/gpl-2.0.txt
///////////////////////////////////////////////////////////////////////////////
#include "WinSevenTaskbar.h"
//MUtils
#include <MUtils/Exception.h>
//Qt
#include <QWidget>
#include <QIcon>
//Windows includes
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <ShObjIdl.h>
static UINT s_winMsg = 0;
static ITaskbarList3 *s_ptbl = NULL;
WinSevenTaskbar::WinSevenTaskbar(void)
{
MUTILS_THROW("Cannot create instance of this class!");
}
WinSevenTaskbar::~WinSevenTaskbar(void)
{
}
////////////////////////////////////////////////////////////
#ifdef __ITaskbarList3_INTERFACE_DEFINED__
void WinSevenTaskbar::init(void)
{
s_winMsg = RegisterWindowMessageW(L"TaskbarButtonCreated");
s_ptbl = NULL;
}
void WinSevenTaskbar::uninit(void)
{
if(s_ptbl)
{
s_ptbl->Release();
s_ptbl = NULL;
}
}
bool WinSevenTaskbar::handleWinEvent(void *message, long *result)
{
bool stopEvent = false;
if(((MSG*)message)->message == s_winMsg)
{
if(!s_ptbl) createInterface();
*result = (s_ptbl) ? S_OK : S_FALSE;
stopEvent = true;
}
return stopEvent;
}
void WinSevenTaskbar::createInterface(void)
{
if(!s_ptbl)
{
ITaskbarList3 *ptbl = NULL;
HRESULT hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&ptbl));
if (SUCCEEDED(hr))
{
HRESULT hr2 = ptbl->HrInit();
if(SUCCEEDED(hr2))
{
s_ptbl = ptbl;
/*qDebug("ITaskbarList3::HrInit() succeeded.");*/
}
else
{
ptbl->Release();
qWarning("ITaskbarList3::HrInit() has failed.");
}
}
else
{
qWarning("ITaskbarList3 could not be created.");
}
}
}
bool WinSevenTaskbar::setTaskbarState(QWidget *window, WinSevenTaskbarState state)
{
bool result = false;
if(s_ptbl && window)
{
HRESULT hr = HRESULT(-1);
switch(state)
{
case WinSevenTaskbarNoState:
hr = s_ptbl->SetProgressState(reinterpret_cast<HWND>(window->winId()), TBPF_NOPROGRESS);
break;
case WinSevenTaskbarNormalState:
hr = s_ptbl->SetProgressState(reinterpret_cast<HWND>(window->winId()), TBPF_NORMAL);
break;
case WinSevenTaskbarIndeterminateState:
hr = s_ptbl->SetProgressState(reinterpret_cast<HWND>(window->winId()), TBPF_INDETERMINATE);
break;
case WinSevenTaskbarErrorState:
hr = s_ptbl->SetProgressState(reinterpret_cast<HWND>(window->winId()), TBPF_ERROR);
break;
case WinSevenTaskbarPausedState:
hr = s_ptbl->SetProgressState(reinterpret_cast<HWND>(window->winId()), TBPF_PAUSED);
break;
}
result = SUCCEEDED(hr);
}
return result;
}
void WinSevenTaskbar::setTaskbarProgress(QWidget *window, unsigned __int64 currentValue, unsigned __int64 maximumValue)
{
if(s_ptbl && window)
{
s_ptbl->SetProgressValue(reinterpret_cast<HWND>(window->winId()), currentValue, maximumValue);
}
}
void WinSevenTaskbar::setOverlayIcon(QWidget *window, QIcon *icon)
{
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
if(s_ptbl && window)
{
s_ptbl->SetOverlayIcon(window->winId(), (icon ? icon->pixmap(16,16).toWinHICON() : NULL), L"LameXP");
}
#endif
}
#else //__ITaskbarList3_INTERFACE_DEFINED__
LAMEXP_COMPILER_WARNING("ITaskbarList3 not defined. Compiling *without* support for Win7 taskbar!")
void WinSevenTaskbar::init(void) {}
void WinSevenTaskbar::uninit(void) {}
bool WinSevenTaskbar::handleWinEvent(MSG *message, long *result) { return false; }
void WinSevenTaskbar::createInterface(void) {}
bool WinSevenTaskbar::setTaskbarState(QWidget *window, WinSevenTaskbarState state) { return false; }
void WinSevenTaskbar::setTaskbarProgress(QWidget *window, unsigned __int64 currentValue, unsigned __int64 maximumValue) {}
void WinSevenTaskbar::setOverlayIcon(QWidget *window, QIcon *icon) {}
#endif //__ITaskbarList3_INTERFACE_DEFINED__

View File

@ -1,57 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
// Copyright (C) 2004-2014 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
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version, but always including the *additional*
// restrictions defined in the "License.txt" file.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/licenses/gpl-2.0.txt
///////////////////////////////////////////////////////////////////////////////
#pragma once
#include "Global.h"
class QWidget;
class QIcon;
class WinSevenTaskbar
{
public:
WinSevenTaskbar(void);
~WinSevenTaskbar(void);
//Taskbar states
enum WinSevenTaskbarState
{
WinSevenTaskbarNoState = 0,
WinSevenTaskbarNormalState = 1,
WinSevenTaskbarIndeterminateState = 2,
WinSevenTaskbarPausedState = 3,
WinSevenTaskbarErrorState = 4
};
//Public interface
static bool handleWinEvent(void *message, long *result);
static bool setTaskbarState(QWidget *window, WinSevenTaskbarState state);
static void setTaskbarProgress(QWidget *window, unsigned __int64 currentValue, unsigned __int64 maximumValue);
static void setOverlayIcon(QWidget *window, QIcon *icon);
static void init(void);
static void uninit(void);
private:
static void createInterface(void);
};