code_app/app/scanner/dialog_upgrade.cpp

87 lines
2.6 KiB
C++
Raw Normal View History

2023-05-24 02:58:44 +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) :
QDialog(parent)
, ui(new Ui::Dialog_upgrade)
, m_versionDll(versionDll)
, m_versionInfo(versionInfo)
{
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;
#elif defined(OEM_ZIGUANG)
oemName = HGVERSION_OEMNAME_UNIS;
2023-05-25 08:54:37 +00:00
#elif defined(OEM_NEUTRAL)
2023-05-24 02:58:44 +00:00
oemName = HGVERSION_OEMNAME_HUAGAO_NEU;
2023-07-17 05:40:22 +00:00
#elif defined(OEM_DELI)
oemName = HGVERSION_OEMNAME_DELI;
2023-05-24 02:58:44 +00:00
#else
oemName = HGVERSION_OEMNAME_HUAGO;
#endif
HGChar currVersion[64] = {0};
m_versionDll->GetCurrVersion(HGVERSION_APPNAME_SCANNER, oemName, currVersion, 64);
HGInt result = 0;
m_versionDll->CompareVersion(currVersion, m_versionInfo[0].version, &result);
if(result >= 0)
{
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);
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") +
str + "\n");
}
else
{
ui->label_detectResult->setText(tr("Discover the new version : ") +
m_versionInfo[0].version +
tr(" ,the current version is : ") + currVersion);
}
}
}
Dialog_upgrade::~Dialog_upgrade()
{
delete ui;
}
QString Dialog_upgrade::getVersionNum()
{
return m_versionNum;
}
void Dialog_upgrade::on_pbtn_upgrade_clicked()
{
m_versionNum = m_versionInfo[0].version;
accept();
}