UI: TaskUpdateChecker: Show message about new version.

This commit is contained in:
Nodir Temirkhodjaev 2017-12-23 14:51:23 +05:00
parent a296c50492
commit e3554008d7
7 changed files with 55 additions and 13 deletions

View File

@ -216,9 +216,22 @@ void FortManager::exit(int retcode)
qApp->exit(retcode);
}
void FortManager::showErrorBox(const QString &text)
void FortManager::showErrorBox(const QString &text,
const QString &title)
{
QMessageBox::warning(&m_window, QString(), text);
QMessageBox::warning(&m_window, title, text);
}
void FortManager::showInfoBox(const QString &text,
const QString &title)
{
QMessageBox box(&m_window);
box.setIcon(QMessageBox::Information);
box.setStandardButtons(QMessageBox::Ok);
box.setWindowTitle(title);
box.setText(text);
box.setTextInteractionFlags(Qt::TextBrowserInteraction);
box.exec();
}
bool FortManager::saveOriginConf(const QString &message)

View File

@ -49,7 +49,10 @@ public slots:
void exit(int retcode = 0);
void showErrorBox(const QString &text);
void showErrorBox(const QString &text,
const QString &title = QString());
void showInfoBox(const QString &text,
const QString &title = QString());
bool saveOriginConf(const QString &message);
bool saveConf(bool onlyFlags = false);

Binary file not shown.

View File

@ -19,17 +19,17 @@
<translation>Конфигурация слишком большая</translation>
</message>
<message>
<location filename="../util/confutil.cpp" line="114"/>
<location filename="../util/confutil.cpp" line="113"/>
<source>Number of Application Groups must be &lt; %1</source>
<translation>Количество групп приложений должно быть &lt; %1</translation>
</message>
<message>
<location filename="../util/confutil.cpp" line="126"/>
<location filename="../util/confutil.cpp" line="125"/>
<source>Length of Application Group&apos;s Name must be &lt; %1</source>
<translation>Длина наименования группы приложения должна быть &lt; %1</translation>
</message>
<message>
<location filename="../util/confutil.cpp" line="168"/>
<location filename="../util/confutil.cpp" line="167"/>
<source>Length of Application&apos;s Path must be &lt; %1</source>
<translation>Длина пути приложения должна быть &lt; %1</translation>
</message>
@ -37,22 +37,22 @@
<context>
<name>FortManager</name>
<message>
<location filename="../fortmanager.cpp" line="387"/>
<location filename="../fortmanager.cpp" line="394"/>
<source>Options</source>
<translation>Опции</translation>
</message>
<message>
<location filename="../fortmanager.cpp" line="392"/>
<location filename="../fortmanager.cpp" line="399"/>
<source>Filter Enabled</source>
<translation>Фильтр включен</translation>
</message>
<message>
<location filename="../fortmanager.cpp" line="396"/>
<location filename="../fortmanager.cpp" line="403"/>
<source>Stop Traffic</source>
<translation>Отключить трафик</translation>
</message>
<message>
<location filename="../fortmanager.cpp" line="411"/>
<location filename="../fortmanager.cpp" line="418"/>
<source>Quit</source>
<translation>Выйти</translation>
</message>
@ -145,6 +145,14 @@
<translation>TAS-IX адреса обновлены!</translation>
</message>
</context>
<context>
<name>TaskUpdateChecker</name>
<message>
<location filename="../task/taskupdatechecker.cpp" line="35"/>
<source>New version!</source>
<translation>Новая версия!</translation>
</message>
</context>
<context>
<name>TaskUzonline</name>
<message>

View File

@ -75,10 +75,10 @@ bool TaskManager::saveSettings(FortSettings *fortSettings)
void TaskManager::handleTaskFinished(bool success)
{
TaskInfo *taskInfo = qobject_cast<TaskInfo *>(sender());
if (success) {
TaskInfo *taskInfo = qobject_cast<TaskInfo *>(sender());
TaskWorker *taskWorker = taskInfo->taskWorker();
taskWorker->processResult(m_fortManager);
}

View File

@ -1,5 +1,6 @@
#include "taskupdatechecker.h"
#include <QDateTime>
#include <QJsonDocument>
#include <QVariant>
@ -8,6 +9,7 @@
#include "../fortmanager.h"
#endif
#include "../util/net/netdownloader.h"
#include "../util/net/netutil.h"
TaskUpdateChecker::TaskUpdateChecker(QObject *parent) :
TaskDownloader(parent)
@ -31,7 +33,7 @@ void TaskUpdateChecker::downloadFinished(bool success)
bool TaskUpdateChecker::processResult(FortManager *fortManager)
{
#ifndef TASK_TEST
fortManager->showTrayMessage(m_releaseName);
fortManager->showInfoBox(successMessage(), tr("New version!"));
#else
Q_UNUSED(fortManager)
#endif
@ -82,3 +84,17 @@ bool TaskUpdateChecker::parseBuffer(const QByteArray &buffer)
return true;
}
QString TaskUpdateChecker::successMessage() const
{
const QDateTime publishedTime = QDateTime::fromString(
m_publishedAt, Qt::ISODate);
return "<b>" + m_releaseName + "</b> (<i>"
+ publishedTime.toString("dd-MMM-yyyy hh:mm") + "</i>, "
+ NetUtil::formatDataSize(m_downloadSize)
+ ", #" + QString::number(m_downloadCount)
+ "):<br/>\n"
+ m_releaseNotes + "<br/><br/>\n"
+ "<a href=\"" + m_downloadUrl + "\">" + m_downloadUrl + "</a>";
}

View File

@ -24,6 +24,8 @@ protected slots:
private:
bool parseBuffer(const QByteArray &buffer);
QString successMessage() const;
private:
QString m_releaseName;
QString m_publishedAt;