Added busy animation to "Update" dialog + added timeout for Wget process.

This commit is contained in:
LoRd_MuldeR 2011-03-24 15:37:49 +01:00
parent 5eec1b5931
commit df8258cddf
10 changed files with 209 additions and 29 deletions

View File

@ -1714,7 +1714,7 @@
</message>
<message>
<source>Please make sure your internet connection is working properly and try again.</source>
<translation>Bitte überprüfen Sie Ihre Internetverbindung und versuchen Sie es dann noch einmal.</translation>
<translation>Bitte prüfen Sie Ihre Internetverbindung und versuchen Sie es dann noch einmal.</translation>
</message>
<message>
<source>Checking for new updates online, please wait...</source>
@ -1742,7 +1742,7 @@
</message>
<message>
<source>No new updates available at this time.</source>
<translation>Zu diesem Zeitpunkt sind keine Updates verfügabr.</translation>
<translation>Zu diesem Zeitpunkt sind keine Updates verfügbar.</translation>
</message>
<message>
<source>Your version of LameXP is still up-to-date. Please check for updates regularly!</source>

View File

@ -2159,108 +2159,108 @@
<translation>пожалуйста, подождите...</translation>
</message>
<message>
<location filename="../../gui/UpdateDialog.ui" line="242"/>
<location filename="../../gui/UpdateDialog.ui" line="349"/>
<source>Latest version available:</source>
<translation>Последняя доступная версия:</translation>
</message>
<message>
<location filename="../../gui/UpdateDialog.ui" line="256"/>
<location filename="../../gui/UpdateDialog.ui" line="363"/>
<source>Currently installed version:</source>
<translation>Установленная верися:</translation>
</message>
<message>
<location filename="../../gui/UpdateDialog.ui" line="371"/>
<location filename="../../gui/UpdateDialog.ui" line="478"/>
<source>Retry</source>
<translation>Повторить</translation>
</message>
<message>
<location filename="../../gui/UpdateDialog.ui" line="394"/>
<location filename="../../gui/UpdateDialog.ui" line="501"/>
<source>Show Log</source>
<translation>Показать Лог</translation>
</message>
<message>
<location filename="../../gui/UpdateDialog.ui" line="482"/>
<location filename="../../gui/UpdateDialog.ui" line="589"/>
<source>Download &amp;&amp; Install</source>
<translation>Скачать и Установить</translation>
</message>
<message>
<location filename="../../gui/UpdateDialog.ui" line="505"/>
<location filename="../../gui/UpdateDialog.ui" line="612"/>
<source>Close</source>
<translation>Закрыть</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="154"/>
<location filename="../../src/Dialog_Update.cpp" line="310"/>
<location filename="../../src/Dialog_Update.cpp" line="169"/>
<location filename="../../src/Dialog_Update.cpp" line="350"/>
<source>Build</source>
<translation type="unfinished">Сборка</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="155"/>
<location filename="../../src/Dialog_Update.cpp" line="170"/>
<source>Unknown</source>
<translation type="unfinished">Неизвестно</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="230"/>
<location filename="../../src/Dialog_Update.cpp" line="247"/>
<source>Testing your internet connection, please wait...</source>
<translation type="unfinished">Проверяю соединение с сетью, пожалуйста, подождите...</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="257"/>
<location filename="../../src/Dialog_Update.cpp" line="283"/>
<source>Network connectivity test has failed!</source>
<translation type="unfinished">Нет соединения с сетью!</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="260"/>
<location filename="../../src/Dialog_Update.cpp" line="286"/>
<source>Please make sure your internet connection is working properly and try again.</source>
<translation type="unfinished">Проверьте доступность интернет соединения и попробуйте снова.</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="272"/>
<location filename="../../src/Dialog_Update.cpp" line="298"/>
<source>Checking for new updates online, please wait...</source>
<translation type="unfinished">Проверяю обновлений, пожалйста, подождите...</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="297"/>
<location filename="../../src/Dialog_Update.cpp" line="337"/>
<source>Failed to fetch update information from server!</source>
<translation type="unfinished">Немогу получить информацию об обновлениях с сервера!</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="302"/>
<location filename="../../src/Dialog_Update.cpp" line="342"/>
<source>Sorry, the update server might be busy at this time. Plase try again later.</source>
<translation type="unfinished">Извините, сервер обновлений сейчас недоступен. Пожалуйста попробуйте позднее.</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="312"/>
<location filename="../../src/Dialog_Update.cpp" line="352"/>
<source>More information available at:</source>
<translation type="unfinished">Больше информации доступно здесь:</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="318"/>
<location filename="../../src/Dialog_Update.cpp" line="358"/>
<source>A new version of LameXP is available!</source>
<translation>Новя версия LameXP доступна!</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="320"/>
<location filename="../../src/Dialog_Update.cpp" line="360"/>
<source>We highly recommend all users to install this update as soon as possible.</source>
<translation type="unfinished">Мы очень рекомендуем установить это обновлений как можо скорее.</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="328"/>
<location filename="../../src/Dialog_Update.cpp" line="369"/>
<source>No new updates available at this time.</source>
<translation type="unfinished">Нет обновлений.</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="330"/>
<location filename="../../src/Dialog_Update.cpp" line="371"/>
<source>Your version of LameXP is still up-to-date. Please check for updates regularly!</source>
<translation type="unfinished">Вы используете самую новую версию LameXP. Проверяйте обновления регулярно!</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="338"/>
<location filename="../../src/Dialog_Update.cpp" line="380"/>
<source>Your version appears to be newer than the latest release.</source>
<translation type="unfinished">Установленная версия новее чем последний релиз.</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="340"/>
<location filename="../../src/Dialog_Update.cpp" line="382"/>
<source>This usually indicates your are currently using a pre-release version of LameXP.</source>
<translation type="unfinished">Это обычно показывает, что вы используете бета версию LameXP.</translation>
</message>

View File

@ -188,6 +188,113 @@
</property>
</spacer>
</item>
<item>
<widget class="QFrame" name="frameAnimation">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="labelAnimationLeft">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../res/Icons.qrc">:/icons/transmit.png</pixmap>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>6</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="labelAnimationCenter">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../res/Images.qrc">:/images/Loading3.gif</pixmap>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_10">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>6</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="labelAnimationRight">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../res/Icons.qrc">:/icons/computer.png</pixmap>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="spacing">
@ -587,6 +694,12 @@
<include location="../res/Images.qrc"/>
<include location="../res/Icons.qrc"/>
<include location="../res/Images.qrc"/>
<include location="../res/Icons.qrc"/>
<include location="../res/Images.qrc"/>
<include location="../res/Icons.qrc"/>
<include location="../res/Images.qrc"/>
<include location="../res/Icons.qrc"/>
<include location="../res/Images.qrc"/>
</resources>
<connections>
<connection>

View File

@ -77,6 +77,7 @@
<file>icons/table_edit.png</file>
<file>icons/tick.png</file>
<file>icons/timeline_marker.png</file>
<file>icons/transmit.png</file>
<file>icons/transmit_blue.png</file>
<file>icons/user.png</file>
<file>icons/user_suit.png</file>

View File

@ -8,6 +8,8 @@
<file>images/HeaderIcon_MetaInfo.png</file>
<file>images/Label.png</file>
<file>images/Loading.gif</file>
<file>images/Loading2.gif</file>
<file>images/Loading3.gif</file>
<file>images/Logo.png</file>
<file>images/Logo_Contributors.png</file>
<file>images/Logo_Software.png</file>

BIN
res/images/Loading3.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

View File

@ -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
/*

View File

@ -36,8 +36,10 @@
#include <QDesktopServices>
#include <QUrl>
#include <QCloseEvent>
#include <QMovie>
#include <Windows.h>
#include <time.h>
///////////////////////////////////////////////////////////////////////////////
@ -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();
}

View File

@ -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;