Adapted "update" dialog for recent MUtils changes + allow user to cancel the update checker thread by pressing Esc button.
This commit is contained in:
parent
452c518605
commit
9e5cf62209
@ -598,6 +598,28 @@
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelCancel">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>1</width>
|
||||
<height>1</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Press Esc button to cancel...</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
|
@ -26,7 +26,7 @@
|
||||
#define VER_X264_MAJOR 2
|
||||
#define VER_X264_MINOR 7
|
||||
#define VER_X264_PATCH 9
|
||||
#define VER_X264_BUILD 1090
|
||||
#define VER_X264_BUILD 1094
|
||||
|
||||
#define VER_X264_PORTABLE_EDITION (0)
|
||||
|
||||
|
@ -112,6 +112,7 @@ UpdaterDialog::UpdaterDialog(QWidget *parent, const SysinfoModel *sysinfo, const
|
||||
ui->buttonCancel->setEnabled(false);
|
||||
ui->buttonRetry->hide();
|
||||
ui->buttonDownload->hide();
|
||||
ui->labelCancel->hide();
|
||||
|
||||
//Start animation
|
||||
SHOW_ANIMATION(true);
|
||||
@ -170,7 +171,23 @@ void UpdaterDialog::closeEvent(QCloseEvent *e)
|
||||
|
||||
void UpdaterDialog::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if(event->key() == Qt::Key_F11)
|
||||
switch (event->key())
|
||||
{
|
||||
case Qt::Key_Escape:
|
||||
if ((!m_thread.isNull()) && m_thread->isRunning())
|
||||
{
|
||||
if (m_status >= MUtils::UpdateChecker::UpdateStatus_FetchingUpdates)
|
||||
{
|
||||
UPDATE_TEXT(2, tr("Cancellation requested..."));
|
||||
}
|
||||
else
|
||||
{
|
||||
UPDATE_TEXT(1, tr("Cancellation requested..."));
|
||||
}
|
||||
m_thread->cancel();
|
||||
}
|
||||
break;
|
||||
case Qt::Key_F11:
|
||||
{
|
||||
const QString logFilePath = MUtils::make_temp_file(MUtils::temp_folder(), "log", true);
|
||||
if (!logFilePath.isEmpty())
|
||||
@ -189,6 +206,10 @@ void UpdaterDialog::keyPressEvent(QKeyEvent *event)
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
QDialog::keyPressEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -262,6 +283,7 @@ void UpdaterDialog::checkForUpdates(void)
|
||||
//Hide labels
|
||||
ui->labelInfo->hide();
|
||||
ui->labelUrl->hide();
|
||||
ui->labelCancel->show();
|
||||
|
||||
//Update status
|
||||
threadStatusChanged(MUtils::UpdateChecker::UpdateStatus_NotStartedYet);
|
||||
@ -282,6 +304,7 @@ void UpdaterDialog::checkForUpdates(void)
|
||||
|
||||
void UpdaterDialog::threadStatusChanged(int status)
|
||||
{
|
||||
const int prevStatus = m_status;
|
||||
switch(m_status = status)
|
||||
{
|
||||
case MUtils::UpdateChecker::UpdateStatus_NotStartedYet:
|
||||
@ -321,6 +344,21 @@ void UpdaterDialog::threadStatusChanged(int status)
|
||||
UPDATE_TEXT(2, tr("Update information received successfully."));
|
||||
UPDATE_ICON(3, "play");
|
||||
break;
|
||||
case MUtils::UpdateChecker::UpdateStatus_CancelledByUser:
|
||||
if (prevStatus >= MUtils::UpdateChecker::UpdateStatus_FetchingUpdates)
|
||||
{
|
||||
UPDATE_ICON(2, "shield_error");
|
||||
UPDATE_TEXT(2, tr("Operation was cancelled by the user!"));
|
||||
UPDATE_ICON(3, "shield_grey");
|
||||
}
|
||||
else
|
||||
{
|
||||
UPDATE_ICON(1, "shield_error");
|
||||
UPDATE_TEXT(1, tr("Operation was cancelled by the user!"));
|
||||
UPDATE_ICON(2, "shield_grey");
|
||||
UPDATE_ICON(3, "shield_grey");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
MUTILS_THROW("Unknown status code!");
|
||||
}
|
||||
@ -330,6 +368,7 @@ void UpdaterDialog::threadFinished(void)
|
||||
{
|
||||
m_success = m_thread->getSuccess();
|
||||
QTimer::singleShot((m_success ? 1000 : 0), this, SLOT(updateFinished()));
|
||||
ui->labelCancel->hide();
|
||||
}
|
||||
|
||||
void UpdaterDialog::updateFinished(void)
|
||||
@ -373,6 +412,7 @@ void UpdaterDialog::updateFinished(void)
|
||||
case MUtils::UpdateChecker::UpdateStatus_ErrorNoConnection:
|
||||
case MUtils::UpdateChecker::UpdateStatus_ErrorConnectionTestFailed:
|
||||
case MUtils::UpdateChecker::UpdateStatus_ErrorFetchUpdateInfo:
|
||||
case MUtils::UpdateChecker::UpdateStatus_CancelledByUser:
|
||||
m_animator->stop();
|
||||
ui->buttonRetry->show();
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user