From df8258cddfe11a168f788995e1b89736ef7cb71d Mon Sep 17 00:00:00 2001 From: lordmulder Date: Thu, 24 Mar 2011 15:37:49 +0100 Subject: [PATCH] Added busy animation to "Update" dialog + added timeout for Wget process. --- etc/Translation/LameXP_DE.ts | 4 +- etc/Translation/LameXP_RU.ts | 44 ++++++------- gui/UpdateDialog.ui | 113 ++++++++++++++++++++++++++++++++++ res/Icons.qrc | 1 + res/Images.qrc | 2 + res/images/Loading3.gif | Bin 0 -> 1188 bytes res/localization/LameXP_DE.qm | Bin 56393 -> 56385 bytes src/Config.h | 2 +- src/Dialog_Update.cpp | 70 +++++++++++++++++++-- src/Dialog_Update.h | 2 + 10 files changed, 209 insertions(+), 29 deletions(-) create mode 100644 res/images/Loading3.gif diff --git a/etc/Translation/LameXP_DE.ts b/etc/Translation/LameXP_DE.ts index 435fe940..2dc2f6f4 100644 --- a/etc/Translation/LameXP_DE.ts +++ b/etc/Translation/LameXP_DE.ts @@ -1714,7 +1714,7 @@ Please make sure your internet connection is working properly and try again. - Bitte überprüfen Sie Ihre Internetverbindung und versuchen Sie es dann noch einmal. + Bitte prüfen Sie Ihre Internetverbindung und versuchen Sie es dann noch einmal. Checking for new updates online, please wait... @@ -1742,7 +1742,7 @@ No new updates available at this time. - Zu diesem Zeitpunkt sind keine Updates verfügabr. + Zu diesem Zeitpunkt sind keine Updates verfügbar. Your version of LameXP is still up-to-date. Please check for updates regularly! diff --git a/etc/Translation/LameXP_RU.ts b/etc/Translation/LameXP_RU.ts index 644a991b..d00514e0 100644 --- a/etc/Translation/LameXP_RU.ts +++ b/etc/Translation/LameXP_RU.ts @@ -2159,108 +2159,108 @@ пожалуйста, подождите... - + Latest version available: Последняя доступная версия: - + Currently installed version: Установленная верися: - + Retry Повторить - + Show Log Показать Лог - + Download && Install Скачать и Установить - + Close Закрыть - - + + Build Сборка - + Unknown Неизвестно - + Testing your internet connection, please wait... Проверяю соединение с сетью, пожалуйста, подождите... - + Network connectivity test has failed! Нет соединения с сетью! - + Please make sure your internet connection is working properly and try again. Проверьте доступность интернет соединения и попробуйте снова. - + Checking for new updates online, please wait... Проверяю обновлений, пожалйста, подождите... - + Failed to fetch update information from server! Немогу получить информацию об обновлениях с сервера! - + Sorry, the update server might be busy at this time. Plase try again later. Извините, сервер обновлений сейчас недоступен. Пожалуйста попробуйте позднее. - + More information available at: Больше информации доступно здесь: - + A new version of LameXP is available! Новя версия LameXP доступна! - + We highly recommend all users to install this update as soon as possible. Мы очень рекомендуем установить это обновлений как можо скорее. - + No new updates available at this time. Нет обновлений. - + Your version of LameXP is still up-to-date. Please check for updates regularly! Вы используете самую новую версию LameXP. Проверяйте обновления регулярно! - + Your version appears to be newer than the latest release. Установленная версия новее чем последний релиз. - + This usually indicates your are currently using a pre-release version of LameXP. Это обычно показывает, что вы используете бета версию LameXP. diff --git a/gui/UpdateDialog.ui b/gui/UpdateDialog.ui index a44681dd..75f1bc53 100644 --- a/gui/UpdateDialog.ui +++ b/gui/UpdateDialog.ui @@ -188,6 +188,113 @@ + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + :/icons/transmit.png + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 6 + 20 + + + + + + + + + + + :/images/Loading3.gif + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 6 + 20 + + + + + + + + + + + :/icons/computer.png + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + @@ -587,6 +694,12 @@ + + + + + + diff --git a/res/Icons.qrc b/res/Icons.qrc index 762d87ef..1d301d90 100644 --- a/res/Icons.qrc +++ b/res/Icons.qrc @@ -77,6 +77,7 @@ icons/table_edit.png icons/tick.png icons/timeline_marker.png + icons/transmit.png icons/transmit_blue.png icons/user.png icons/user_suit.png diff --git a/res/Images.qrc b/res/Images.qrc index 6b88d80a..191af4be 100644 --- a/res/Images.qrc +++ b/res/Images.qrc @@ -8,6 +8,8 @@ images/HeaderIcon_MetaInfo.png images/Label.png images/Loading.gif + images/Loading2.gif + images/Loading3.gif images/Logo.png images/Logo_Contributors.png images/Logo_Software.png diff --git a/res/images/Loading3.gif b/res/images/Loading3.gif new file mode 100644 index 0000000000000000000000000000000000000000..7c2ef2b6dba1a2bc981bdbf98b219b2034dd3743 GIT binary patch literal 1188 zcmZ?wbhEHbOkogUIKsg2|NsAAzkYrH{{8FMudiRfe)a0rP?zFQ7FKo! zAqE|g2_R=MuzI_FDr?^mpQU-SO|fdvH~Dq?aI-4}`&DDW^Y z6V|GA^YqQ0+BG-MJ@TE$gaj3qr3V*nl$fG0(PBx7!wvotYbO6y_dnOyR@EriRX4P& zaPjnTsq*knHecg`u)<>t{AP1SR0}hf@+%e41U84K+l8+4SKGYlVI7lbRgErbzUfEN1E4p?K#`d7av1@0T?v&-Opw plaN%Frjn7BQ&Ui9?&+=O>#rIZ916*6-E-#7o4;V;B6~#!YXC(=xLN=J literal 0 HcmV?d00001 diff --git a/res/localization/LameXP_DE.qm b/res/localization/LameXP_DE.qm index bb6a22596735391261f669af39f4ae9b18d05a14..ea3baa00449a6c9c9acfbacf713517f401ab27fe 100644 GIT binary patch delta 136 zcmV;30C)e%xC6ns1F#$c0e7<<0Y3o&r?XuGp8)}~v;70#1OeQW-3X@v^pk}NrUJ?Q zlPwCL0jRUh3jYBC;*-q`HvzMg1r1jlDi7bhP5=N5!4K$ki2wjgBWVBt&d37*000`3 qFb^ZMnhmbTlRpp!lTOq}4W0l(0BHbp0CWIl03egWT}89+)LI9onK23g delta 124 zcmV-?0E7R*xC6XXe3Hvzko1r1jlG7sOpP5=N5!4K$ki2wjgBWVBt&d>t@000`3 eFb^ZMnhmbT17QGSlS|Y}0j86!U0Ji|)LI8q{4N~; diff --git a/src/Config.h b/src/Config.h index 35d0e5fa..b0c5ebee 100644 --- a/src/Config.h +++ b/src/Config.h @@ -25,7 +25,7 @@ #define VER_LAMEXP_MAJOR 4 #define VER_LAMEXP_MINOR_HI 0 #define VER_LAMEXP_MINOR_LO 1 -#define VER_LAMEXP_BUILD 400 +#define VER_LAMEXP_BUILD 402 #define VER_LAMEXP_SUFFIX Beta-13 /* diff --git a/src/Dialog_Update.cpp b/src/Dialog_Update.cpp index 6cf4c50a..9b5af370 100644 --- a/src/Dialog_Update.cpp +++ b/src/Dialog_Update.cpp @@ -36,8 +36,10 @@ #include #include #include +#include #include +#include /////////////////////////////////////////////////////////////////////////////// @@ -58,6 +60,7 @@ static const char *update_mirrors[] = "http://free.pages.at/borschdfresser/", "http://mplayer.savedonthe.net/", "http://www.tricksoft.de/", + "http://mplayer.somestuff.org/", NULL }; @@ -69,10 +72,14 @@ static const char *known_hosts[] = "http://www.msn.com/", "http://www.yahoo.com/", "http://sourceforge.net/", + "http://www.gitorious.org/", + "http://www.youtube.com/", + "http://www.ebay.com/", + "http://www.amazon.com/", NULL }; -static const int MIN_CONNSCORE = 2; +static const int MIN_CONNSCORE = 3; static char *USER_AGENT_STR = "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101101 IceCat/3.6.12 (like Firefox/3.6.12)"; /////////////////////////////////////////////////////////////////////////////// @@ -128,6 +135,11 @@ UpdateDialog::UpdateDialog(SettingsModel *settings, QWidget *parent) HMENU hMenu = GetSystemMenu((HWND) winId(), FALSE); EnableMenuItem(hMenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED); + //Init animation + m_animator = new QMovie(":/images/Loading3.gif"); + labelAnimationCenter->setMovie(m_animator); + m_animator->start(); + //Enable button connect(retryButton, SIGNAL(clicked()), this, SLOT(checkForUpdates())); connect(installButton, SIGNAL(clicked()), this, SLOT(applyUpdate())); @@ -140,8 +152,11 @@ UpdateDialog::UpdateDialog(SettingsModel *settings, QWidget *parent) UpdateDialog::~UpdateDialog(void) { + if(m_animator) m_animator->stop(); + LAMEXP_DELETE(m_updateInfo); LAMEXP_DELETE(m_logFile); + LAMEXP_DELETE(m_animator); WinSevenTaskbar::setTaskbarState(this->parentWidget(), WinSevenTaskbar::WinSevenTaskbarNoState); WinSevenTaskbar::setOverlayIcon(this->parentWidget(), NULL); @@ -164,6 +179,7 @@ void UpdateDialog::showEvent(QShowEvent *event) infoLabel->hide(); hintLabel->hide(); hintIcon->hide(); + frameAnimation->hide(); int counter = 2; for(int i = 0; known_hosts[i]; i++) counter++; @@ -223,6 +239,7 @@ void UpdateDialog::checkForUpdates(void) if(infoLabel->isVisible()) infoLabel->hide(); if(hintLabel->isVisible()) hintLabel->hide(); if(hintIcon->isVisible()) hintIcon->hide(); + frameAnimation->show(); QApplication::processEvents(); QApplication::setOverrideCursor(Qt::WaitCursor); @@ -232,14 +249,22 @@ void UpdateDialog::checkForUpdates(void) m_logFile->clear(); m_logFile->append("Checking internet connection..."); + QStringList hostList; for(int i = 0; known_hosts[i]; i++) + { + hostList << QString::fromLatin1(known_hosts[i]); + } + + qsrand(time(NULL)); + while(!hostList.isEmpty()) { progressBar->setValue(progressBar->value() + 1); + QString currentHost = hostList.takeAt(qrand() % hostList.count()); if(connectionScore < MIN_CONNSCORE) { - m_logFile->append(QStringList() << "" << "Testing host:" << known_hosts[i] << ""); + m_logFile->append(QStringList() << "" << "Testing host:" << currentHost << ""); QString outFile = QString("%1/%2.htm").arg(lamexp_temp_folder2(), lamexp_rand_str()); - if(getFile(known_hosts[i], outFile)) + if(getFile(currentHost, outFile)) { connectionScore++; } @@ -254,6 +279,7 @@ void UpdateDialog::checkForUpdates(void) closeButton->setEnabled(true); retryButton->setEnabled(true); logButton->setEnabled(true); + if(frameAnimation->isVisible()) frameAnimation->hide(); statusLabel->setText(tr("Network connectivity test has failed!")); progressBar->setValue(progressBar->maximum()); hintIcon->setPixmap(QIcon(":/icons/error.png").pixmap(16,16)); @@ -272,12 +298,25 @@ void UpdateDialog::checkForUpdates(void) statusLabel->setText(tr("Checking for new updates online, please wait...")); m_logFile->append("Checking for updates online..."); + QStringList mirrorList; for(int i = 0; update_mirrors[i]; i++) { + mirrorList << QString::fromLatin1(update_mirrors[i]); + } + + qsrand(time(NULL)); + for(int i = 0; i < 16; i++) + { + mirrorList.swap(i % 4, qrand() % 4); + } + + while(!mirrorList.isEmpty()) + { + QString currentMirror = mirrorList.takeFirst(); progressBar->setValue(progressBar->value() + 1); if(!success) { - if(tryUpdateMirror(m_updateInfo, update_mirrors[i])) + if(tryUpdateMirror(m_updateInfo, currentMirror)) { success = true; } @@ -294,6 +333,7 @@ void UpdateDialog::checkForUpdates(void) closeButton->setEnabled(true); retryButton->setEnabled(true); logButton->setEnabled(true); + if(frameAnimation->isVisible()) frameAnimation->hide(); statusLabel->setText(tr("Failed to fetch update information from server!")); progressBar->setValue(progressBar->maximum()); WinSevenTaskbar::setTaskbarState(this->parentWidget(), WinSevenTaskbar::WinSevenTaskbarErrorState); @@ -318,6 +358,7 @@ void UpdateDialog::checkForUpdates(void) statusLabel->setText(tr("A new version of LameXP is available!")); hintIcon->setPixmap(QIcon(":/icons/shield_exclamation.png").pixmap(16,16)); hintLabel->setText(tr("We highly recommend all users to install this update as soon as possible.")); + if(frameAnimation->isVisible()) frameAnimation->hide(); hintIcon->show(); hintLabel->show(); WinSevenTaskbar::setOverlayIcon(this->parentWidget(), &QIcon(":/icons/shield_exclamation.png")); @@ -328,6 +369,7 @@ void UpdateDialog::checkForUpdates(void) statusLabel->setText(tr("No new updates available at this time.")); hintIcon->setPixmap(QIcon(":/icons/shield_green.png").pixmap(16,16)); hintLabel->setText(tr("Your version of LameXP is still up-to-date. Please check for updates regularly!")); + if(frameAnimation->isVisible()) frameAnimation->hide(); hintIcon->show(); hintLabel->show(); WinSevenTaskbar::setOverlayIcon(this->parentWidget(), &QIcon(":/icons/shield_green.png")); @@ -338,6 +380,7 @@ void UpdateDialog::checkForUpdates(void) statusLabel->setText(tr("Your version appears to be newer than the latest release.")); hintIcon->setPixmap(QIcon(":/icons/bug.png").pixmap(16,16)); hintLabel->setText(tr("This usually indicates your are currently using a pre-release version of LameXP.")); + if(frameAnimation->isVisible()) frameAnimation->hide(); hintIcon->show(); hintLabel->show(); WinSevenTaskbar::setOverlayIcon(this->parentWidget(), &QIcon(":/icons/bug.png")); @@ -347,6 +390,7 @@ void UpdateDialog::checkForUpdates(void) closeButton->setEnabled(true); if(retryButton->isVisible()) retryButton->hide(); if(logButton->isVisible()) logButton->hide(); + if(frameAnimation->isVisible()) frameAnimation->hide(); m_success = true; } @@ -414,6 +458,11 @@ bool UpdateDialog::getFile(const QString &url, const QString &outFile) connect(&process, SIGNAL(finished(int,QProcess::ExitStatus)), &loop, SLOT(quit())); connect(&process, SIGNAL(readyRead()), &loop, SLOT(quit())); + QTimer timer; + timer.setSingleShot(true); + timer.setInterval(15000); + connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); + process.start(m_binaryWGet, QStringList() << "-U" << USER_AGENT_STR << "-O" << output.fileName() << url); if(!process.waitForStarted()) @@ -421,15 +470,28 @@ bool UpdateDialog::getFile(const QString &url, const QString &outFile) return false; } + timer.start(); + while(process.state() == QProcess::Running) { loop.exec(); + if(!timer.isActive()) + { + qWarning("WGet process timed out <-- killing!"); + process.kill(); + process.waitForFinished(); + m_logFile->append("TIMEOUT !!!"); + return false; + } while(process.canReadLine()) { m_logFile->append(QString::fromLatin1(process.readLine()).simplified()); } } + timer.stop(); + timer.disconnect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); + m_logFile->append(QString().sprintf("Exited with code %d", process.exitCode())); return (process.exitCode() == 0) && output.exists() && output.isFile(); } diff --git a/src/Dialog_Update.h b/src/Dialog_Update.h index a5f37ac9..8c280c5e 100644 --- a/src/Dialog_Update.h +++ b/src/Dialog_Update.h @@ -27,6 +27,7 @@ class UpdateInfo; class SettingsModel; +class QMovie; class UpdateDialog : public QDialog, private Ui::UpdateDialog { @@ -61,6 +62,7 @@ private: UpdateInfo *m_updateInfo; QStringList *m_logFile; SettingsModel *m_settings; + QMovie *m_animator; const QString m_binaryWGet; const QString m_binaryGnuPG;