<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">
<enum>Qt::Horizontal</enum>
ui->buttonCancel->setEnabled(false);
ui->buttonRetry->hide();
ui->buttonDownload->hide();
+ ui->labelCancel->hide();
//Start animation
SHOW_ANIMATION(true);
void UpdaterDialog::keyPressEvent(QKeyEvent *event)
{
- if(event->key() == Qt::Key_F11)
+ switch (event->key())
{
- const QString logFilePath = MUtils::make_temp_file(MUtils::temp_folder(), "log", true);
- if (!logFilePath.isEmpty())
+ case Qt::Key_Escape:
+ if ((!m_thread.isNull()) && m_thread->isRunning())
{
- QFile logFile(logFilePath);
- if (logFile.open(QIODevice::WriteOnly | QIODevice::Truncate))
+ if (m_status >= MUtils::UpdateChecker::UpdateStatus_FetchingUpdates)
{
- logFile.write("\xEF\xBB\xBF");
- for (QStringList::ConstIterator iter = m_logFile.constBegin(); iter != m_logFile.constEnd(); iter++)
+ 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())
+ {
+ QFile logFile(logFilePath);
+ if (logFile.open(QIODevice::WriteOnly | QIODevice::Truncate))
{
- logFile.write(iter->toUtf8());
- logFile.write("\r\n");
+ logFile.write("\xEF\xBB\xBF");
+ for (QStringList::ConstIterator iter = m_logFile.constBegin(); iter != m_logFile.constEnd(); iter++)
+ {
+ logFile.write(iter->toUtf8());
+ logFile.write("\r\n");
+ }
+ logFile.close();
+ QDesktopServices::openUrl(QUrl::fromLocalFile(logFile.fileName()));
}
- logFile.close();
- QDesktopServices::openUrl(QUrl::fromLocalFile(logFile.fileName()));
}
}
+ break;
+ default:
+ QDialog::keyPressEvent(event);
}
}
//Hide labels
ui->labelInfo->hide();
ui->labelUrl->hide();
+ ui->labelCancel->show();
//Update status
threadStatusChanged(MUtils::UpdateChecker::UpdateStatus_NotStartedYet);
void UpdaterDialog::threadStatusChanged(int status)
{
+ const int prevStatus = m_status;
switch(m_status = status)
{
case MUtils::UpdateChecker::UpdateStatus_NotStartedYet:
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!");
}
{
m_success = m_thread->getSuccess();
QTimer::singleShot((m_success ? 1000 : 0), this, SLOT(updateFinished()));
+ ui->labelCancel->hide();
}
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;