diff --git a/app/scanner/dialog_updateprogress.cpp b/app/scanner/dialog_updateprogress.cpp index e132d34a..3b462c7a 100644 --- a/app/scanner/dialog_updateprogress.cpp +++ b/app/scanner/dialog_updateprogress.cpp @@ -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); } diff --git a/app/scanner/dialog_upgrade.cpp b/app/scanner/dialog_upgrade.cpp index 2172160d..eb594ba8 100644 --- a/app/scanner/dialog_upgrade.cpp +++ b/app/scanner/dialog_upgrade.cpp @@ -6,10 +6,12 @@ #include #include -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); } diff --git a/app/scanner/dialog_upgrade.h b/app/scanner/dialog_upgrade.h index 375353af..ce68ee4b 100644 --- a/app/scanner/dialog_upgrade.h +++ b/app/scanner/dialog_upgrade.h @@ -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 diff --git a/app/scanner/mainwindow.cpp b/app/scanner/mainwindow.cpp index ceb9ea61..11a9f8e0 100644 --- a/app/scanner/mainwindow.cpp +++ b/app/scanner/mainwindow.cpp @@ -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()