code_app/app/scanner2/dialog_upgrade.cpp

85 lines
2.5 KiB
C++
Raw Normal View History

2022-07-18 08:59:12 +00:00
#include "dialog_upgrade.h"
#include "ui_dialog_upgrade.h"
#include "base/HGUtility.h"
#include <QCryptographicHash>
#include <QMessageBox>
#include <QDir>
#include <QFile>
Dialog_upgrade::Dialog_upgrade(class VersionDll *versionDll, HGVersionInfo *versionInfo, QWidget *parent) :
2022-07-18 08:59:12 +00:00
QDialog(parent)
, ui(new Ui::Dialog_upgrade)
, m_versionDll(versionDll)
, m_versionInfo(versionInfo)
2022-07-18 08:59:12 +00:00
{
ui->setupUi(this);
setWindowTitle(tr("upgrade online"));
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
this->layout()->setSizeConstraint(QLayout::SetFixedSize);
const HGChar *oemName = nullptr;
#if defined(OEM_HANWANG)
oemName = HGVERSION_OEMNAME_HANVON;
#elif defined(OEM_LISICHENG)
oemName = HGVERSION_OEMNAME_LANXUM;
#elif defined(OEM_CANGTIAN)
oemName = HGVERSION_OEMNAME_CUMTENN;
#elif defined(OEM_ZHONGJING)
oemName = HGVERSION_OEMNAME_MICROTEK;
2023-03-10 05:39:50 +00:00
#elif defined(OEM_ZIGUANG)
2023-03-10 10:31:39 +00:00
oemName = HGVERSION_OEMNAME_UNIS;
2023-04-20 08:13:29 +00:00
#elif defined(OEM_NEUTRAL)
oemName = HGVERSION_OEMNAME_NEUTRAL;
#else
oemName = HGVERSION_OEMNAME_HUAGO;
#endif
2022-07-18 08:59:12 +00:00
HGChar currVersion[64] = {0};
m_versionDll->GetCurrVersion(HGVERSION_APPNAME_SCANNER, oemName, currVersion, 64);
2022-07-18 08:59:12 +00:00
HGInt result = 0;
m_versionDll->CompareVersion(currVersion, m_versionInfo[0].version, &result);
2022-11-29 10:45:50 +00:00
if(result >= 0)
2022-07-18 08:59:12 +00:00
{
ui->label_detectResult->setText(tr("The current version is the latest! The current version number is : ") + currVersion);
ui->pbtn_upgrade->setVisible(false);
}
else
{
ui->pbtn_upgrade->setVisible(true);
2022-11-29 08:57:39 +00:00
QString str(m_versionInfo[0].desc);
if (!str.isEmpty())
{
ui->label_detectResult->setText(tr("Discover the new version : ") +
m_versionInfo[0].version +
tr(" ,the current version is : ") + currVersion + "\n" + "\n" +
tr("upgrade contents: \n") +
2022-11-29 10:45:50 +00:00
str + "\n");
2022-11-29 08:57:39 +00:00
}
else
{
ui->label_detectResult->setText(tr("Discover the new version : ") +
m_versionInfo[0].version +
tr(" ,the current version is : ") + currVersion);
}
2022-07-18 08:59:12 +00:00
}
}
Dialog_upgrade::~Dialog_upgrade()
{
delete ui;
}
QString Dialog_upgrade::getVersionNum()
{
return m_versionNum;
}
2022-07-18 08:59:12 +00:00
void Dialog_upgrade::on_pbtn_upgrade_clicked()
{
m_versionNum = m_versionInfo[0].version;
accept();
2022-07-18 08:59:12 +00:00
}