Added support for Windows 7 Taskbar Progress to "Update" dialog.

This commit is contained in:
LoRd_MuldeR 2011-02-25 13:40:45 +01:00
parent f75c3ca496
commit efbb182372
5 changed files with 48 additions and 7 deletions

View File

@ -25,8 +25,8 @@
#define VER_LAMEXP_MAJOR 4 #define VER_LAMEXP_MAJOR 4
#define VER_LAMEXP_MINOR_HI 0 #define VER_LAMEXP_MINOR_HI 0
#define VER_LAMEXP_MINOR_LO 1 #define VER_LAMEXP_MINOR_LO 1
#define VER_LAMEXP_BUILD 334 #define VER_LAMEXP_BUILD 336
#define VER_LAMEXP_SUFFIX Beta-1 #define VER_LAMEXP_SUFFIX Beta-3
/* /*
* Tools versions * Tools versions

View File

@ -61,7 +61,7 @@ g_lamexp_contributors[] =
{"it", L"Italiano", L"Roberto", "Gulliver_69@libero.it"}, {"it", L"Italiano", L"Roberto", "Gulliver_69@libero.it"},
{"es", L"Español", L"Rub3nCT", "Rub3nCT@gmail.com" }, {"es", L"Español", L"Rub3nCT", "Rub3nCT@gmail.com" },
{"ru", L"Русский", L"Neonailol", "Neonailol@gmail.com" }, {"ru", L"Русский", L"Neonailol", "Neonailol@gmail.com" },
{"uk", L"Українська", L"Arestarh", "arestarh@ukr.net" }, {"uk", L"Українська", L"Arestarh", "Arestarh@ukr.net" },
{NULL, NULL, NULL, NULL} {NULL, NULL, NULL, NULL}
}; };

View File

@ -756,7 +756,10 @@ void MainWindow::windowShown(void)
QApplication::processEvents(); QApplication::processEvents();
PlaySound(MAKEINTRESOURCE(IDR_WAVE_WHAMMY), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC); PlaySound(MAKEINTRESOURCE(IDR_WAVE_WHAMMY), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
QMessageBox::critical(this, tr("License Declined"), tr("You have declined the license. Consequently the application will exit now!"), tr("Goodbye!")); QMessageBox::critical(this, tr("License Declined"), tr("You have declined the license. Consequently the application will exit now!"), tr("Goodbye!"));
QProcess::startDetached(QString("%1/Uninstall.exe").arg(QApplication::applicationDirPath()), QStringList()); if(!QProcess::startDetached(QString("%1/Uninstall.exe").arg(QApplication::applicationDirPath()), QStringList()))
{
MoveFileEx(QWCHAR(QDir::toNativeSeparators(QFileInfo(QApplication::applicationFilePath()).canonicalFilePath())), NULL, MOVEFILE_DELAY_UNTIL_REBOOT | MOVEFILE_REPLACE_EXISTING);
}
QApplication::quit(); QApplication::quit();
return; return;
} }

View File

@ -25,6 +25,7 @@
#include "Resource.h" #include "Resource.h"
#include "Dialog_LogView.h" #include "Dialog_LogView.h"
#include "Model_Settings.h" #include "Model_Settings.h"
#include "WinSevenTaskbar.h"
#include <QClipboard> #include <QClipboard>
#include <QFileDialog> #include <QFileDialog>
@ -132,12 +133,18 @@ UpdateDialog::UpdateDialog(SettingsModel *settings, QWidget *parent)
connect(installButton, SIGNAL(clicked()), this, SLOT(applyUpdate())); connect(installButton, SIGNAL(clicked()), this, SLOT(applyUpdate()));
connect(infoLabel, SIGNAL(linkActivated(QString)), this, SLOT(linkActivated(QString))); connect(infoLabel, SIGNAL(linkActivated(QString)), this, SLOT(linkActivated(QString)));
connect(logButton, SIGNAL(clicked()), this, SLOT(logButtonClicked())); connect(logButton, SIGNAL(clicked()), this, SLOT(logButtonClicked()));
//Enable progress bar
connect(progressBar, SIGNAL(valueChanged(int)), this, SLOT(progressBarValueChanged(int)));
} }
UpdateDialog::~UpdateDialog(void) UpdateDialog::~UpdateDialog(void)
{ {
LAMEXP_DELETE(m_updateInfo); LAMEXP_DELETE(m_updateInfo);
LAMEXP_DELETE(m_logFile); LAMEXP_DELETE(m_logFile);
WinSevenTaskbar::setTaskbarState(this->parentWidget(), WinSevenTaskbar::WinSevenTaskbarNoState);
WinSevenTaskbar::setOverlayIcon(this->parentWidget(), NULL);
} }
void UpdateDialog::showEvent(QShowEvent *event) void UpdateDialog::showEvent(QShowEvent *event)
@ -168,7 +175,15 @@ void UpdateDialog::showEvent(QShowEvent *event)
void UpdateDialog::closeEvent(QCloseEvent *event) void UpdateDialog::closeEvent(QCloseEvent *event)
{ {
if(!closeButton->isEnabled()) event->ignore(); if(!closeButton->isEnabled())
{
event->ignore();
}
else
{
WinSevenTaskbar::setTaskbarState(this->parentWidget(), WinSevenTaskbar::WinSevenTaskbarNoState);
WinSevenTaskbar::setOverlayIcon(this->parentWidget(), NULL);
}
} }
void UpdateDialog::keyPressEvent(QKeyEvent *e) void UpdateDialog::keyPressEvent(QKeyEvent *e)
@ -199,6 +214,8 @@ void UpdateDialog::checkForUpdates(void)
m_updateInfo = new UpdateInfo; m_updateInfo = new UpdateInfo;
progressBar->setValue(0); progressBar->setValue(0);
WinSevenTaskbar::setTaskbarState(this->parentWidget(), WinSevenTaskbar::WinSevenTaskbarNormalState);
WinSevenTaskbar::setOverlayIcon(this->parentWidget(), &QIcon(":/icons/transmit_blue.png"));
installButton->setEnabled(false); installButton->setEnabled(false);
closeButton->setEnabled(false); closeButton->setEnabled(false);
retryButton->setEnabled(false); retryButton->setEnabled(false);
@ -247,6 +264,8 @@ void UpdateDialog::checkForUpdates(void)
if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_ERROR), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC); if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_ERROR), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
progressBar->setValue(progressBar->maximum()); progressBar->setValue(progressBar->maximum());
WinSevenTaskbar::setTaskbarState(this->parentWidget(), WinSevenTaskbar::WinSevenTaskbarErrorState);
WinSevenTaskbar::setOverlayIcon(this->parentWidget(), &QIcon(":/icons/exclamation.png"));
return; return;
} }
@ -267,7 +286,7 @@ void UpdateDialog::checkForUpdates(void)
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
progressBar->setValue(progressBar->maximum()); progressBar->setValue(progressBar->maximum());
if(!success) if(!success)
{ {
if(!retryButton->isVisible()) retryButton->show(); if(!retryButton->isVisible()) retryButton->show();
@ -277,6 +296,8 @@ void UpdateDialog::checkForUpdates(void)
logButton->setEnabled(true); logButton->setEnabled(true);
statusLabel->setText(tr("Failed to fetch update information from server!")); statusLabel->setText(tr("Failed to fetch update information from server!"));
progressBar->setValue(progressBar->maximum()); progressBar->setValue(progressBar->maximum());
WinSevenTaskbar::setTaskbarState(this->parentWidget(), WinSevenTaskbar::WinSevenTaskbarErrorState);
WinSevenTaskbar::setOverlayIcon(this->parentWidget(), &QIcon(":/icons/exclamation.png"));
hintIcon->setPixmap(QIcon(":/icons/server_error.png").pixmap(16,16)); hintIcon->setPixmap(QIcon(":/icons/server_error.png").pixmap(16,16));
hintLabel->setText(tr("Sorry, the update server might be busy at this time. Plase try again later.")); hintLabel->setText(tr("Sorry, the update server might be busy at this time. Plase try again later."));
hintIcon->show(); hintIcon->show();
@ -299,6 +320,7 @@ void UpdateDialog::checkForUpdates(void)
hintLabel->setText(tr("We highly recommend all users to install this update as soon as possible.")); hintLabel->setText(tr("We highly recommend all users to install this update as soon as possible."));
hintIcon->show(); hintIcon->show();
hintLabel->show(); hintLabel->show();
WinSevenTaskbar::setOverlayIcon(this->parentWidget(), &QIcon(":/icons/bell.png"));
MessageBeep(MB_ICONINFORMATION); MessageBeep(MB_ICONINFORMATION);
} }
else if(m_updateInfo->m_buildNo == lamexp_version_build()) else if(m_updateInfo->m_buildNo == lamexp_version_build())
@ -308,6 +330,7 @@ void UpdateDialog::checkForUpdates(void)
hintLabel->setText(tr("Your version of LameXP is still up-to-date. Please check for updates regularly!")); hintLabel->setText(tr("Your version of LameXP is still up-to-date. Please check for updates regularly!"));
hintIcon->show(); hintIcon->show();
hintLabel->show(); hintLabel->show();
WinSevenTaskbar::setOverlayIcon(this->parentWidget(), &QIcon(":/icons/information.png"));
MessageBeep(MB_ICONINFORMATION); MessageBeep(MB_ICONINFORMATION);
} }
else else
@ -317,6 +340,7 @@ void UpdateDialog::checkForUpdates(void)
hintLabel->setText(tr("This usually indicates your are currently using a pre-release version of LameXP.")); hintLabel->setText(tr("This usually indicates your are currently using a pre-release version of LameXP."));
hintIcon->show(); hintIcon->show();
hintLabel->show(); hintLabel->show();
WinSevenTaskbar::setOverlayIcon(this->parentWidget(), &QIcon(":/icons/bug.png"));
MessageBeep(MB_ICONEXCLAMATION); MessageBeep(MB_ICONEXCLAMATION);
} }
@ -559,19 +583,27 @@ void UpdateDialog::applyUpdate(void)
args << QString("/AppTitle=LameXP (Build #%1)").arg(QString::number(m_updateInfo->m_buildNo)); args << QString("/AppTitle=LameXP (Build #%1)").arg(QString::number(m_updateInfo->m_buildNo));
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
WinSevenTaskbar::setTaskbarState(this->parentWidget(), WinSevenTaskbar::WinSevenTaskbarIndeterminateState);
WinSevenTaskbar::setOverlayIcon(this->parentWidget(), &QIcon(":/icons/transmit_blue.png"));
process.start(m_binaryUpdater, args); process.start(m_binaryUpdater, args);
loop.exec(); loop.exec();
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
if(process.exitCode() == 0) if(process.exitCode() == 0)
{ {
statusLabel->setText("Update ready to install. Applicaion will quit..."); statusLabel->setText("Update ready to install. Applicaion will quit...");
m_updateReadyToInstall = true; m_updateReadyToInstall = true;
WinSevenTaskbar::setTaskbarState(this->parentWidget(), WinSevenTaskbar::WinSevenTaskbarNoState);
WinSevenTaskbar::setOverlayIcon(this->parentWidget(), NULL);
accept(); accept();
} }
else else
{ {
statusLabel->setText("Update failed. Please try again or download manually!"); statusLabel->setText("Update failed. Please try again or download manually!");
WinSevenTaskbar::setTaskbarState(this->parentWidget(), WinSevenTaskbar::WinSevenTaskbarErrorState);
WinSevenTaskbar::setOverlayIcon(this->parentWidget(), &QIcon(":/icons/exclamation.png"));
WinSevenTaskbar::setTaskbarProgress(this->parentWidget(), 100, 100);
} }
} }
@ -585,3 +617,8 @@ void UpdateDialog::logButtonClicked(void)
logView->exec(*m_logFile); logView->exec(*m_logFile);
LAMEXP_DELETE(logView); LAMEXP_DELETE(logView);
} }
void UpdateDialog::progressBarValueChanged(int value)
{
WinSevenTaskbar::setTaskbarProgress(this->parentWidget(), value, progressBar->maximum());
}

View File

@ -45,6 +45,7 @@ private slots:
void linkActivated(const QString &link); void linkActivated(const QString &link);
void applyUpdate(void); void applyUpdate(void);
void logButtonClicked(void); void logButtonClicked(void);
void progressBarValueChanged(int value);
protected: protected:
void showEvent(QShowEvent *event); void showEvent(QShowEvent *event);