调整获取版本列表和拷贝依赖文件到临时目录

This commit is contained in:
yangjiaxuan 2022-07-21 10:56:47 +08:00
parent 7aa5ad82ee
commit e453e5e2f4
4 changed files with 58 additions and 59 deletions

View File

@ -58,51 +58,6 @@ void Dialog_updateProgress::ThreadFunc(HGThread thread, HGPointer param)
HGResult ret = p->m_versionDll->HttpDownload(p->m_url.toStdString().c_str(), p->m_savePath.toStdString().c_str(), HttpDownloadThreadFunc, p);
if (HGBASE_ERR_OK == ret)
{
QString curPath = QDir::currentPath();
QString tmpPath = QDir::tempPath();
QFile file(curPath);
#if defined(HG_CMP_MSC)
#if defined(OEM_HANWANG)
file.copy("HwUpgradeApp.exe", tmpPath + "/HwUpgradeApp.exe");
file.copy("HwBase.dll", tmpPath + "/HwBase.dll");
file.copy("HwVersion.dll", tmpPath + "/HwVersion.dll");
#elif defined(OEM_LISICHENG)
file.copy("LscUpgradeApp.exe", tmpPath + "/LscUpgradeApp.exe");
file.copy("LscBase.dll", tmpPath + "/LscBase.dll");
file.copy("LscVersion.dll", tmpPath + "/LscVersion.dll");
#else
file.copy("HGUpgradeApp.exe", tmpPath + "/HGUpgradeApp.exe");
file.copy("HGBase.dll", tmpPath + "/HGBase.dll");
file.copy("HGVersion.dll", tmpPath + "/HGVersion.dll");
#endif
file.copy("msvcp140.dll", tmpPath + "/msvcp140.dll");
file.copy("Qt5Core.dll", tmpPath + "/Qt5Core.dll");
file.copy("Qt5Gui.dll", tmpPath + "/Qt5Gui.dll");
file.copy("Qt5Widgets.dll", tmpPath + "/Qt5Widgets.dll");
file.copy("vcruntime140.dll", tmpPath + "/vcruntime140.dll");
QDir dir;
dir.mkdir(tmpPath + "/platforms");
file.copy("platforms/qwindows.dll", tmpPath + "/platforms/qwindows.dll");
dir.mkdir(tmpPath + "/imageformats");
file.copy("imageformats/qgif.dll", tmpPath + "/imageformats/qgif.dll");
#else
#if defined(OEM_HANWANG)
file.copy("HwUpgradeApp", tmpPath + "/HwUpgradeApp");
file.copy("libHwBase.so", tmpPath + "/libHwBase.so");
file.copy("libHwVersion.so", tmpPath + "/libHwVersion.so");
#elif defined(OEM_LISICHENG)
file.copy("LscUpgradeApp", tmpPath + "/LscUpgradeApp");
file.copy("libLscBase.so", tmpPath + "/libLscBase.so");
file.copy("libLscVersion.so", tmpPath + "/libLscVersion.so");
#else
file.copy("HGUpgradeApp", tmpPath + "/HGUpgradeApp");
file.copy("libHGBase.so", tmpPath + "/libHGBase.so");
file.copy("libHGVersion.so", tmpPath + "/libHGVersion.so");
#endif
#endif
emit p->finish();
emit p->upgrade(p->m_savePath);
}

View File

@ -6,10 +6,12 @@
#include <QDir>
#include <QFile>
Dialog_upgrade::Dialog_upgrade(class VersionDll *versionDll, QWidget *parent) :
Dialog_upgrade::Dialog_upgrade(class VersionDll *versionDll, HGVersionInfo *versionInfo, HGUInt versionCount, QWidget *parent) :
QDialog(parent)
, ui(new Ui::Dialog_upgrade)
, m_versionDll(versionDll)
, m_versionInfo(versionInfo)
, m_versionCount(versionCount)
{
ui->setupUi(this);
setWindowTitle(tr("upgrade online"));
@ -22,17 +24,13 @@ Dialog_upgrade::Dialog_upgrade(class VersionDll *versionDll, QWidget *parent) :
ui->pbtn_cancel->setVisible(false);
ui->label->setVisible(false);
HGVersionInfo *versionInfo = NULL;
HGUInt versionCount = 0;
m_versionDll->GetVersionList(HGVERSION_APPNAME_SCANNER, &versionInfo, &versionCount);
for(HGUInt i = 0; i < versionCount; ++i)
for(HGUInt i = 0; i < m_versionCount; ++i)
{
QListWidgetItem *listwidgetItem = new QListWidgetItem;
listwidgetItem->setText(QString(versionInfo[i].version));
listwidgetItem->setData(Qt::UserRole, versionInfo[i].url);
listwidgetItem->setData(Qt::UserRole+1, versionInfo[i].md5);
listwidgetItem->setToolTip(tr("upgrade contents: ") + versionInfo[i].desc + tr(" bug description: ") + versionInfo[i].bugInfo);
listwidgetItem->setText(QString(m_versionInfo[i].version));
listwidgetItem->setData(Qt::UserRole, m_versionInfo[i].url);
listwidgetItem->setData(Qt::UserRole+1, m_versionInfo[i].md5);
listwidgetItem->setToolTip(tr("upgrade contents: ") + m_versionInfo[i].desc + tr(" bug description: ") + m_versionInfo[i].bugInfo);
ui->listWidget->addItem(listwidgetItem);
}
@ -62,8 +60,6 @@ Dialog_upgrade::Dialog_upgrade(class VersionDll *versionDll, QWidget *parent) :
}
connect(ui->listWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(on_listWidget_itemDoubleClicked(QListWidgetItem*)), Qt::QueuedConnection);
m_versionDll->ReleaseVersionList(versionInfo, versionCount);
}
Dialog_upgrade::~Dialog_upgrade()
@ -132,6 +128,51 @@ void Dialog_upgrade::on_listWidget_itemDoubleClicked(QListWidgetItem *item)
void Dialog_upgrade::on_upgrade(QString pkgPath)
{
QString curPath = QDir::currentPath();
QString tmpPath = QDir::tempPath();
QFile file(curPath);
#if defined(HG_CMP_MSC)
#if defined(OEM_HANWANG)
file.copy("HwUpgradeApp.exe", tmpPath + "/HwUpgradeApp.exe");
file.copy("HwBase.dll", tmpPath + "/HwBase.dll");
file.copy("HwVersion.dll", tmpPath + "/HwVersion.dll");
#elif defined(OEM_LISICHENG)
file.copy("LscUpgradeApp.exe", tmpPath + "/LscUpgradeApp.exe");
file.copy("LscBase.dll", tmpPath + "/LscBase.dll");
file.copy("LscVersion.dll", tmpPath + "/LscVersion.dll");
#else
file.copy("HGUpgradeApp.exe", tmpPath + "/HGUpgradeApp.exe");
file.copy("HGBase.dll", tmpPath + "/HGBase.dll");
file.copy("HGVersion.dll", tmpPath + "/HGVersion.dll");
#endif
file.copy("msvcp140.dll", tmpPath + "/msvcp140.dll");
file.copy("Qt5Core.dll", tmpPath + "/Qt5Core.dll");
file.copy("Qt5Gui.dll", tmpPath + "/Qt5Gui.dll");
file.copy("Qt5Widgets.dll", tmpPath + "/Qt5Widgets.dll");
file.copy("vcruntime140.dll", tmpPath + "/vcruntime140.dll");
QDir dir;
dir.mkdir(tmpPath + "/platforms");
file.copy("platforms/qwindows.dll", tmpPath + "/platforms/qwindows.dll");
dir.mkdir(tmpPath + "/imageformats");
file.copy("imageformats/qgif.dll", tmpPath + "/imageformats/qgif.dll");
#else
#if defined(OEM_HANWANG)
file.copy("HwUpgradeApp", tmpPath + "/HwUpgradeApp");
file.copy("libHwBase.so", tmpPath + "/libHwBase.so");
file.copy("libHwVersion.so", tmpPath + "/libHwVersion.so");
#elif defined(OEM_LISICHENG)
file.copy("LscUpgradeApp", tmpPath + "/LscUpgradeApp");
file.copy("libLscBase.so", tmpPath + "/libLscBase.so");
file.copy("libLscVersion.so", tmpPath + "/libLscVersion.so");
#else
file.copy("HGUpgradeApp", tmpPath + "/HGUpgradeApp");
file.copy("libHGBase.so", tmpPath + "/libHGBase.so");
file.copy("libHGVersion.so", tmpPath + "/libHGVersion.so");
#endif
#endif
emit upgradeApp(pkgPath);
}

View File

@ -14,7 +14,7 @@ class Dialog_upgrade : public QDialog
Q_OBJECT
public:
explicit Dialog_upgrade(class VersionDll *versionDll, QWidget *parent = nullptr);
explicit Dialog_upgrade(class VersionDll *versionDll, HGVersionInfo *versionInfo, HGUInt versionCount, QWidget *parent = nullptr);
~Dialog_upgrade();
private slots:
@ -36,6 +36,8 @@ private:
Ui::Dialog_upgrade *ui;
VersionDll *m_versionDll;
HGVersionInfo *m_versionInfo;
HGUInt m_versionCount;
};
#endif // DIALOG_UPGRADE_H

View File

@ -3168,7 +3168,7 @@ void MainWindow::on_actionact_update_triggered()
m_versionDll->GetVersionList(HGVERSION_APPNAME_SCANNER, &versionInfo, &versionCount);
if(versionCount > 0)
{
Dialog_upgrade dlg(m_versionDll, this);
Dialog_upgrade dlg(m_versionDll, versionInfo, versionCount, this);
connect(&dlg, SIGNAL(upgradeApp(QString)), this, SLOT(on_upgradeApp(QString)), Qt::QueuedConnection);
dlg.exec();
disconnect(&dlg, SIGNAL(upgradeApp(QString)), this, SLOT(on_upgradeApp(QString)));
@ -3178,6 +3178,7 @@ void MainWindow::on_actionact_update_triggered()
QMessageBox::critical(this, tr("error"), tr("get versionlist failed"));
return;
}
m_versionDll->ReleaseVersionList(versionInfo, versionCount);
}
void MainWindow::on_act_feedback_triggered()