Some improvements to the updater dialog.

This commit is contained in:
LoRd_MuldeR 2013-11-23 15:20:07 +01:00
parent e860efa3e0
commit 50bd16dc80
6 changed files with 625 additions and 460 deletions

View File

@ -652,7 +652,7 @@
<normaloff>:/buttons/update.png</normaloff>:/buttons/update.png</iconset>
</property>
<property name="text">
<string>Check for Updates</string>
<string>Check for new Updates</string>
</property>
</action>
</widget>

View File

@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>458</width>
<height>255</height>
<width>410</width>
<height>273</height>
</rect>
</property>
<property name="palette">
@ -78,13 +78,18 @@
</palette>
</property>
<property name="windowTitle">
<string>Autoupdate</string>
<string>Web-Update</string>
</property>
<property name="windowIcon">
<iconset resource="../res/resources.qrc">
<normaloff>:/buttons/update.png</normaloff>:/buttons/update.png</iconset>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
@ -93,14 +98,14 @@
<widget class="QLabel" name="logo">
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
<width>72</width>
<height>72</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>80</height>
<width>72</width>
<height>72</height>
</size>
</property>
<property name="text">
@ -139,7 +144,7 @@
</property>
<property name="sizeHint" stdset="0">
<size>
<width>18</width>
<width>32</width>
<height>20</height>
</size>
</property>
@ -183,7 +188,7 @@
<string/>
</property>
<property name="pixmap">
<pixmap resource="../res/resources.qrc">:/buttons/hourglass.png</pixmap>
<pixmap resource="../res/resources.qrc">:/buttons/clock.png</pixmap>
</property>
</widget>
</item>
@ -229,7 +234,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>6</height>
<height>10</height>
</size>
</property>
</spacer>
@ -254,7 +259,7 @@
<string/>
</property>
<property name="pixmap">
<pixmap resource="../res/resources.qrc">:/buttons/hourglass.png</pixmap>
<pixmap resource="../res/resources.qrc">:/buttons/clock.png</pixmap>
</property>
</widget>
</item>
@ -300,7 +305,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>6</height>
<height>10</height>
</size>
</property>
</spacer>
@ -325,7 +330,7 @@
<string/>
</property>
<property name="pixmap">
<pixmap resource="../res/resources.qrc">:/buttons/hourglass.png</pixmap>
<pixmap resource="../res/resources.qrc">:/buttons/clock.png</pixmap>
</property>
</widget>
</item>
@ -360,6 +365,22 @@
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>6</height>
</size>
</property>
</spacer>
</item>
<item>
<spacer name="verticalSpacer_6">
<property name="orientation">
@ -383,7 +404,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
<height>0</height>
</size>
</property>
</spacer>
@ -394,7 +415,7 @@
<string/>
</property>
<property name="pixmap">
<pixmap resource="../res/resources.qrc">:/buttons/update.png</pixmap>
<pixmap resource="../res/resources.qrc">:/buttons/transmit.png</pixmap>
</property>
</widget>
</item>
@ -414,7 +435,7 @@
<string/>
</property>
<property name="pixmap">
<pixmap resource="../res/resources.qrc">:/buttons/setup.png</pixmap>
<pixmap resource="../res/resources.qrc">:/buttons/computer.png</pixmap>
</property>
</widget>
</item>
@ -426,7 +447,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
<height>0</height>
</size>
</property>
</spacer>
@ -436,7 +457,7 @@
<item>
<widget class="QLabel" name="labelInfo">
<property name="text">
<string>Info:</string>
<string>More information available at:</string>
</property>
</widget>
</item>
@ -485,7 +506,7 @@
</font>
</property>
<property name="text">
<string>http://www.example.com/info.hmtl</string>
<string>http://www.example.com/update_info.html</string>
</property>
</widget>
</item>
@ -505,6 +526,10 @@
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
@ -539,7 +564,7 @@
</size>
</property>
<property name="text">
<string>Download &amp; Install</string>
<string>Download &amp;&amp; Install</string>
</property>
<property name="icon">
<iconset resource="../res/resources.qrc">
@ -548,7 +573,7 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<widget class="QPushButton" name="buttonRetry">
<property name="minimumSize">
<size>
<width>88</width>
@ -573,7 +598,7 @@
</size>
</property>
<property name="text">
<string>Cancel</string>
<string>Discard</string>
</property>
<property name="icon">
<iconset resource="../res/resources.qrc">
@ -586,8 +611,6 @@
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="../res/resources.qrc"/>

View File

@ -7,9 +7,11 @@
<file>buttons/bomb.png</file>
<file>buttons/book_open.png</file>
<file>buttons/cancel.png</file>
<file>buttons/clock.png</file>
<file>buttons/clock_pause.png</file>
<file>buttons/clock_play.png</file>
<file>buttons/clock_stop.png</file>
<file>buttons/computer.png</file>
<file>buttons/control_pause.png</file>
<file>buttons/cross.png</file>
<file>buttons/disk.png</file>
@ -34,7 +36,11 @@
<file>buttons/restart.png</file>
<file>buttons/setup.png</file>
<file>buttons/shield_admin.png</file>
<file>buttons/shield_error.png</file>
<file>buttons/shield_exclamation.png</file>
<file>buttons/shield_green.png</file>
<file>buttons/suspended.png</file>
<file>buttons/transmit.png</file>
<file>buttons/trash.png</file>
<file>buttons/update.png</file>
<file>buttons/world_link.png</file>

View File

@ -26,7 +26,7 @@
#define VER_X264_MAJOR 2
#define VER_X264_MINOR 2
#define VER_X264_PATCH 7
#define VER_X264_BUILD 642
#define VER_X264_BUILD 665
#define VER_X264_MINIMUM_REV 2363
#define VER_X264_CURRENT_API 140

View File

@ -23,6 +23,27 @@
#include "uic_win_updater.h"
#include "global.h"
#include "checksum.h"
#include <QMovie>
#include <QCloseEvent>
#include <QTimer>
///////////////////////////////////////////////////////////////////////////////
#define UPDATE_TEXT(N, TEXT) ui->label_phase##N->setText((TEXT))
#define UPDATE_ICON(N, ICON) ui->icon_phase##N->setPixmap(QIcon(":/buttons/" ICON ".png").pixmap(16, 16))
#define SHOW_ANIMATION(FLAG) do \
{ \
ui->labelLoadingLeft->setVisible((FLAG)); \
ui->labelLoadingCenter->setVisible((FLAG)); \
ui->labelLoadingRight->setVisible((FLAG)); \
ui->labelInfo->setVisible(!(FLAG)); \
ui->labelUrl->setVisible(!(FLAG)); \
} \
while(0)
///////////////////////////////////////////////////////////////////////////////
// Constructor & Destructor
@ -31,18 +52,49 @@
UpdaterDialog::UpdaterDialog(QWidget *parent)
:
QDialog(parent),
ui(new Ui::UpdaterDialog())
ui(new Ui::UpdaterDialog()),
m_state(0),
m_firstShow(true)
{
//Init the dialog, from the .ui file
ui->setupUi(this);
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
//Fix size
setMinimumSize(size());
setFixedSize(size());
//Init animation
m_animator = new QMovie(":/images/loading.gif");
ui->labelLoadingCenter->setMovie(m_animator);
m_animator->start();
//Init buttons
ui->buttonCancel->setEnabled(false);
ui->buttonRetry->hide();
ui->buttonDownload->hide();
//Hide labels
ui->labelInfo->hide();
ui->labelUrl->hide();
//TEST
QBlake2Checksum checksum;
checksum.update("The quick brown fox jumps over the lazy dog");
qWarning("Result: %s\n", checksum.finalize().constData());
//TEST
QBlake2Checksum checksum2;
QFile file("");
if(file.open(QIODevice::ReadOnly))
{
checksum2.update(file);
qWarning("Result: %s\n", checksum2.finalize().constData());
}
}
UpdaterDialog::~UpdaterDialog(void)
{
X264_DELETE(m_animator);
delete ui;
}
@ -54,11 +106,81 @@ UpdaterDialog::~UpdaterDialog(void)
// Events
///////////////////////////////////////////////////////////////////////////////
/*None*/
void UpdaterDialog::showEvent(QShowEvent *event)
{
if(m_firstShow)
{
m_firstShow = false;
QTimer::singleShot(0, this, SLOT(initUpdate()));
}
}
void UpdaterDialog::closeEvent(QCloseEvent *e)
{
if(!ui->buttonCancel->isEnabled())
{
e->ignore();
}
}
///////////////////////////////////////////////////////////////////////////////
// Slots
///////////////////////////////////////////////////////////////////////////////
/*None*/
void UpdaterDialog::initUpdate(void)
{
//Restet text
ui->retranslateUi(this);
//Init buttons
ui->buttonCancel->setEnabled(false);
ui->buttonRetry->hide();
ui->buttonDownload->hide();
//Hide labels
ui->labelInfo->hide();
ui->labelUrl->hide();
//Reset icons
UPDATE_ICON(1, "clock");
UPDATE_ICON(2, "clock");
UPDATE_ICON(3, "clock");
//Show animation
SHOW_ANIMATION(true);
//Begin updater test run
m_state = 0;
QTimer::singleShot(333, this, SLOT(updateState()));
}
void UpdaterDialog::updateState(void)
{
switch(m_state++)
{
case 0:
UPDATE_ICON(1, "play");
QTimer::singleShot(6666, this, SLOT(updateState()));
break;
case 1:
UPDATE_ICON(1, "shield_green");
UPDATE_TEXT(1, tr("Internet connection is working."));
UPDATE_ICON(2, "play");
QTimer::singleShot(6666, this, SLOT(updateState()));
break;
case 2:
UPDATE_ICON(2, "shield_green");
UPDATE_TEXT(2, tr("Update-information was received successfully."));
UPDATE_ICON(3, "play");
QTimer::singleShot(6666, this, SLOT(updateState()));
break;
case 3:
UPDATE_ICON(3, "shield_exclamation");
UPDATE_TEXT(3, tr("A newer version is available!"));
QTimer::singleShot(6666, this, SLOT(updateState()));
SHOW_ANIMATION(false);
ui->buttonCancel->setEnabled(true);
ui->buttonDownload->show();
break;
}
}

View File

@ -23,6 +23,8 @@
#include <QDialog>
class QMovie;
namespace Ui
{
class UpdaterDialog;
@ -36,6 +38,18 @@ public:
UpdaterDialog(QWidget *parent);
~UpdaterDialog(void);
protected:
virtual void showEvent(QShowEvent *event);
virtual void closeEvent(QCloseEvent *e);
private slots:
void initUpdate(void);
void updateState(void);
private:
Ui::UpdaterDialog *const ui;
bool m_firstShow;
QMovie *m_animator;
int m_state;
};