From b315b0dba55bd6fe5d44c87d429fd5334774ed58 Mon Sep 17 00:00:00 2001 From: luoliangyi <87842688@qq.com> Date: Fri, 22 Jul 2022 14:25:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scanner/mainwindow.cpp | 230 ++++++++++++++++++------------------- app/scanner/mainwindow.h | 2 +- 2 files changed, 115 insertions(+), 117 deletions(-) diff --git a/app/scanner/mainwindow.cpp b/app/scanner/mainwindow.cpp index bfc43e51..36be730d 100644 --- a/app/scanner/mainwindow.cpp +++ b/app/scanner/mainwindow.cpp @@ -1097,120 +1097,6 @@ void MainWindow::on_statusInfoDblClick() m_dialogLog->show(); } -void MainWindow::on_upgradeApp(QString pkgPath) -{ - QString curPath = QDir::currentPath(); - QString tmpPath = QDir::tempPath(); - -#if defined(HG_CMP_MSC) - #if defined(OEM_HANWANG) - QFile::remove(tmpPath + "/HwUpgradeApp.exe"); - QFile::copy(curPath + "/HwUpgradeApp.exe", tmpPath + "/HwUpgradeApp.exe"); - QFile::remove(tmpPath + "/HwBase.dll"); - QFile::copy(curPath + "/HwBase.dll", tmpPath + "/HwBase.dll"); - QFile::remove(tmpPath + "/HwVersion.dll"); - QFile::copy(curPath + "/HwVersion.dll", tmpPath + "/HwVersion.dll"); - #elif defined(OEM_LISICHENG) - QFile::remove(tmpPath + "/LscUpgradeApp.exe"); - QFile::copy(curPath + "/LscUpgradeApp.exe", tmpPath + "/LscUpgradeApp.exe"); - QFile::remove(tmpPath + "/LscBase.dll"); - QFile::copy(curPath + "/LscBase.dll", tmpPath + "/LscBase.dll"); - QFile::remove(tmpPath + "/LscVersion.dll"); - QFile::copy(curPath + "/LscVersion.dll", tmpPath + "/LscVersion.dll"); - #else - QFile::remove(tmpPath + "/HGUpgradeApp.exe"); - QFile::copy(curPath + "/HGUpgradeApp.exe", tmpPath + "/HGUpgradeApp.exe"); - QFile::remove(tmpPath + "/HGBase.dll"); - QFile::copy(curPath + "/HGBase.dll", tmpPath + "/HGBase.dll"); - QFile::remove(tmpPath + "/HGVersion.dll"); - QFile::copy(curPath + "/HGVersion.dll", tmpPath + "/HGVersion.dll"); - #endif - - QFile::remove(tmpPath + "/msvcp140.dll"); - QFile::copy(curPath + "/msvcp140.dll", tmpPath + "/msvcp140.dll"); - QFile::remove(tmpPath + "/Qt5Core.dll"); - QFile::copy(curPath + "/Qt5Core.dll", tmpPath + "/Qt5Core.dll"); - QFile::remove(tmpPath + "/Qt5Gui.dll"); - QFile::copy(curPath + "/Qt5Gui.dll", tmpPath + "/Qt5Gui.dll"); - QFile::remove(tmpPath + "/Qt5Widgets.dll"); - QFile::copy(curPath + "/Qt5Widgets.dll", tmpPath + "/Qt5Widgets.dll"); - QFile::remove(tmpPath + "/vcruntime140.dll"); - QFile::copy(curPath + "/vcruntime140.dll", tmpPath + "/vcruntime140.dll"); - QDir dir; - dir.mkdir(tmpPath + "/platforms"); - QFile::remove(tmpPath + "/platforms/qwindows.dll"); - QFile::copy(curPath + "/platforms/qwindows.dll", tmpPath + "/platforms/qwindows.dll"); - dir.mkdir(tmpPath + "/imageformats"); - QFile::remove(tmpPath + "/imageformats/qgif.dll"); - QFile::copy(curPath + "/imageformats/qgif.dll", tmpPath + "/imageformats/qgif.dll"); -#else - #if defined(OEM_HANWANG) - QFile::remove(tmpPath + "/HwUpgradeApp"); - QFile::copy(curPath + "/HwUpgradeApp", tmpPath + "/HwUpgradeApp"); - QFile::remove(tmpPath + "/libHwBase.so"); - QFile::copy(curPath + "/libHwBase.so", tmpPath + "/libHwBase.so"); - QFile::remove(tmpPath + "/libHwVersion.so"); - QFile::copy(curPath + "/libHwVersion.so", tmpPath + "/libHwVersion.so"); - #elif defined(OEM_LISICHENG) - QFile::remove(tmpPath + "/LscUpgradeApp"); - QFile::copy(curPath + "/LscUpgradeApp", tmpPath + "/LscUpgradeApp"); - QFile::remove(tmpPath + "/libLscBase.so"); - QFile::copy(curPath + "/libLscBase.so", tmpPath + "/libLscBase.so"); - QFile::remove(tmpPath + "/libLscVersion.so"); - QFile::copy(curPath + "/libLscVersion.so", tmpPath + "/libLscVersion.so"); - #else - QFile::remove(tmpPath + "/HGUpgradeApp"); - QFile::copy(curPath + "/HGUpgradeApp", tmpPath + "/HGUpgradeApp"); - QFile::remove(tmpPath + "/libHGBase.so"); - QFile::copy(curPath + "/libHGBase.so", tmpPath + "/libHGBase.so"); - QFile::remove(tmpPath + "/libHGVersion.so"); - QFile::copy(curPath + "/libHGVersion.so", tmpPath + "/libHGVersion.so"); - #endif -#endif - - - - QProcess proc; - bool isSuccessdStart = false; - - QStringList argList; - argList.push_back(QString("-appName=%1").arg(HGVERSION_APPNAME_SCANNER)); - argList.push_back(QString("-pkgpath=%1").arg(pkgPath.toStdString().c_str())); - argList.push_back(QString("-type=%1").arg("upgrade")); - -#if defined(HG_CMP_MSC) - #if defined(OEM_HANWANG) - isSuccessdStart = proc.startDetached(tmpPath + "/HwUpgradeApp.exe", argList); - #elif defined(OEM_LISICHENG) - isSuccessdStart = proc.startDetached(tmpPath + "/LscUpgradeApp.exe", argList); - #else - isSuccessdStart = proc.startDetached(tmpPath + "/HGUpgradeApp.exe", argList); - #endif -#else - #if defined(OEM_HANWANG) - isSuccessdStart = proc.startDetached(tmpPath + "/HwUpgradeApp", argList); - #elif defined(OEM_LISICHENG) - isSuccessdStart = proc.startDetached(tmpPath + "/LscUpgradeApp", argList); - #else - isSuccessdStart = proc.startDetached(tmpPath + "/HGUpgradeApp", argList); - #endif -#endif - - if(isSuccessdStart) - { - m_closeTip = false; - close(); - } - else - { - QMessageBox msg(QMessageBox::Critical, tr("error"), - tr("start failed!"), - QMessageBox::Ok); - msg.setButtonText(QMessageBox::Ok, tr("yes")); - msg.exec(); - } -} - void MainWindow::on_act_thumbnailBar_triggered(bool checked) { ui->dockWidget->setVisible(checked); @@ -3144,6 +3030,118 @@ bool MainWindow::judgeDiskSpace(QString currentPath) return true; } +void MainWindow::upgradeApp(QString pkgPath) +{ + QString curPath = QDir::currentPath(); + QString tmpPath = QDir::tempPath(); + +#if defined(HG_CMP_MSC) + #if defined(OEM_HANWANG) + QFile::remove(tmpPath + "/HwUpgradeApp.exe"); + QFile::copy(curPath + "/HwUpgradeApp.exe", tmpPath + "/HwUpgradeApp.exe"); + QFile::remove(tmpPath + "/HwBase.dll"); + QFile::copy(curPath + "/HwBase.dll", tmpPath + "/HwBase.dll"); + QFile::remove(tmpPath + "/HwVersion.dll"); + QFile::copy(curPath + "/HwVersion.dll", tmpPath + "/HwVersion.dll"); + #elif defined(OEM_LISICHENG) + QFile::remove(tmpPath + "/LscUpgradeApp.exe"); + QFile::copy(curPath + "/LscUpgradeApp.exe", tmpPath + "/LscUpgradeApp.exe"); + QFile::remove(tmpPath + "/LscBase.dll"); + QFile::copy(curPath + "/LscBase.dll", tmpPath + "/LscBase.dll"); + QFile::remove(tmpPath + "/LscVersion.dll"); + QFile::copy(curPath + "/LscVersion.dll", tmpPath + "/LscVersion.dll"); + #else + QFile::remove(tmpPath + "/HGUpgradeApp.exe"); + QFile::copy(curPath + "/HGUpgradeApp.exe", tmpPath + "/HGUpgradeApp.exe"); + QFile::remove(tmpPath + "/HGBase.dll"); + QFile::copy(curPath + "/HGBase.dll", tmpPath + "/HGBase.dll"); + QFile::remove(tmpPath + "/HGVersion.dll"); + QFile::copy(curPath + "/HGVersion.dll", tmpPath + "/HGVersion.dll"); + #endif + + QFile::remove(tmpPath + "/msvcp140.dll"); + QFile::copy(curPath + "/msvcp140.dll", tmpPath + "/msvcp140.dll"); + QFile::remove(tmpPath + "/Qt5Core.dll"); + QFile::copy(curPath + "/Qt5Core.dll", tmpPath + "/Qt5Core.dll"); + QFile::remove(tmpPath + "/Qt5Gui.dll"); + QFile::copy(curPath + "/Qt5Gui.dll", tmpPath + "/Qt5Gui.dll"); + QFile::remove(tmpPath + "/Qt5Widgets.dll"); + QFile::copy(curPath + "/Qt5Widgets.dll", tmpPath + "/Qt5Widgets.dll"); + QFile::remove(tmpPath + "/vcruntime140.dll"); + QFile::copy(curPath + "/vcruntime140.dll", tmpPath + "/vcruntime140.dll"); + QDir dir; + dir.mkdir(tmpPath + "/platforms"); + QFile::remove(tmpPath + "/platforms/qwindows.dll"); + QFile::copy(curPath + "/platforms/qwindows.dll", tmpPath + "/platforms/qwindows.dll"); + dir.mkdir(tmpPath + "/imageformats"); + QFile::remove(tmpPath + "/imageformats/qgif.dll"); + QFile::copy(curPath + "/imageformats/qgif.dll", tmpPath + "/imageformats/qgif.dll"); +#else + #if defined(OEM_HANWANG) + QFile::remove(tmpPath + "/HwUpgradeApp"); + QFile::copy(curPath + "/HwUpgradeApp", tmpPath + "/HwUpgradeApp"); + QFile::remove(tmpPath + "/libHwBase.so"); + QFile::copy(curPath + "/libHwBase.so", tmpPath + "/libHwBase.so"); + QFile::remove(tmpPath + "/libHwVersion.so"); + QFile::copy(curPath + "/libHwVersion.so", tmpPath + "/libHwVersion.so"); + #elif defined(OEM_LISICHENG) + QFile::remove(tmpPath + "/LscUpgradeApp"); + QFile::copy(curPath + "/LscUpgradeApp", tmpPath + "/LscUpgradeApp"); + QFile::remove(tmpPath + "/libLscBase.so"); + QFile::copy(curPath + "/libLscBase.so", tmpPath + "/libLscBase.so"); + QFile::remove(tmpPath + "/libLscVersion.so"); + QFile::copy(curPath + "/libLscVersion.so", tmpPath + "/libLscVersion.so"); + #else + QFile::remove(tmpPath + "/HGUpgradeApp"); + QFile::copy(curPath + "/HGUpgradeApp", tmpPath + "/HGUpgradeApp"); + QFile::remove(tmpPath + "/libHGBase.so"); + QFile::copy(curPath + "/libHGBase.so", tmpPath + "/libHGBase.so"); + QFile::remove(tmpPath + "/libHGVersion.so"); + QFile::copy(curPath + "/libHGVersion.so", tmpPath + "/libHGVersion.so"); + #endif +#endif + + QProcess proc; + bool isSuccessdStart = false; + + QStringList argList; + argList.push_back(QString("-appName=%1").arg(HGVERSION_APPNAME_SCANNER)); + argList.push_back(QString("-pkgpath=%1").arg(pkgPath.toStdString().c_str())); + argList.push_back(QString("-type=%1").arg("upgrade")); + +#if defined(HG_CMP_MSC) + #if defined(OEM_HANWANG) + isSuccessdStart = proc.startDetached(tmpPath + "/HwUpgradeApp.exe", argList); + #elif defined(OEM_LISICHENG) + isSuccessdStart = proc.startDetached(tmpPath + "/LscUpgradeApp.exe", argList); + #else + isSuccessdStart = proc.startDetached(tmpPath + "/HGUpgradeApp.exe", argList); + #endif +#else + #if defined(OEM_HANWANG) + isSuccessdStart = proc.startDetached(tmpPath + "/HwUpgradeApp", argList); + #elif defined(OEM_LISICHENG) + isSuccessdStart = proc.startDetached(tmpPath + "/LscUpgradeApp", argList); + #else + isSuccessdStart = proc.startDetached(tmpPath + "/HGUpgradeApp", argList); + #endif +#endif + + if (isSuccessdStart) + { + m_closeTip = false; + close(); + } + else + { + QMessageBox msg(QMessageBox::Critical, tr("error"), + tr("start failed!"), + QMessageBox::Ok, this); + msg.setButtonText(QMessageBox::Ok, tr("yes")); + msg.exec(); + } +} + void MainWindow::on_scanOptions_changed(const QString &device, const QString &option, bool checked_now) { QString title(tr("app name")); @@ -3300,13 +3298,13 @@ void MainWindow::on_actionact_update_triggered() if (md5 == md5_2) { - on_upgradeApp(savePath); + upgradeApp(savePath); } } } else { - on_upgradeApp(savePath); + upgradeApp(savePath); } } } diff --git a/app/scanner/mainwindow.h b/app/scanner/mainwindow.h index 7524a8a5..4de3e62c 100644 --- a/app/scanner/mainwindow.h +++ b/app/scanner/mainwindow.h @@ -122,7 +122,6 @@ private slots: void on_continueScan(); void on_stopScan(); void on_statusInfoDblClick(); - void on_upgradeApp(QString pkgPath); void on_act_thumbnailBar_triggered(bool checked); @@ -229,6 +228,7 @@ private: QString passwordDecrypt(const QString& transcode); bool open_scanner(const QString& name, OPTSCHEME* schm); bool judgeDiskSpace(QString currentPath); + void upgradeApp(QString pkgPath); private: Ui::MainWindow *ui;