From 1e329882af096db54d8d7c40b2af9019e5ca0910 Mon Sep 17 00:00:00 2001 From: yangjiaxuan <171295266@qq.com> Date: Wed, 29 May 2024 14:31:13 +0800 Subject: [PATCH] =?UTF-8?q?scantool=E6=94=B9=E4=B8=BA=E9=9D=99=E6=80=81?= =?UTF-8?q?=E7=BC=96=E8=AF=91=EF=BC=8C=E8=A7=A3=E5=86=B3=E6=89=AB=E6=8F=8F?= =?UTF-8?q?=E6=8C=87=E7=A4=BA=E5=99=A8=E7=95=8C=E9=9D=A2=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=EF=BC=9B=E9=9D=9E7010=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E6=B7=BB=E5=8A=A0=E5=88=B0=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scantool/mainwindow.cpp | 22 ++++++++-------------- app/scantool/mainwindow.h | 4 ++-- build.bat | 3 +++ 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/app/scantool/mainwindow.cpp b/app/scantool/mainwindow.cpp index e58c4c3b..50ffd434 100644 --- a/app/scantool/mainwindow.cpp +++ b/app/scantool/mainwindow.cpp @@ -112,7 +112,7 @@ MainWindow::MainWindow(QWidget *parent) connect(this, SIGNAL(scanInfo(QString, bool)), this, SLOT(on_scanInfo(QString, bool))); connect(this, SIGNAL(scanImage(unsigned int)), this, SLOT(on_scanImage(unsigned int))); connect(this, SIGNAL(scanFinish()), this, SLOT(on_scanFinish())); - connect(this, SIGNAL(saneEventCloseDevice(void*)), this, SLOT(on_saneEventCloseDevice(void*))); + connect(this, SIGNAL(saneEventCloseDevice(void*, bool)), this, SLOT(on_saneEventCloseDevice(void*, bool))); SANE_Int version_code = 0; sane_init_ex(&version_code, sane_ex_callback, this); @@ -1125,7 +1125,8 @@ int MainWindow::sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigne break; case SANE_EVENT_SCANNER_CLOSED: { - emit p->saneEventCloseDevice((void*)hdev); + bool isOnline = *(bool*)data; + emit p->saneEventCloseDevice((void*)hdev, isOnline); } break; case SANE_EVENT_IMAGE_OK: @@ -1260,17 +1261,13 @@ void MainWindow::timerEvent(QTimerEvent *e) this->killTimer(m_timerId); m_timerId = -1; } - else if (SCANNER_ERR_DEVICE_NOT_SUPPORT == status) - { - this->killTimer(m_timerId); - m_timerId = -1; - } } } void MainWindow::on_deviceArrive(QString devName) { - ui->comboBox->addItem(devName); + if (devName.contains("306") || devName.contains("307")) + ui->comboBox->addItem(devName); } void MainWindow::on_deviceRemove(QString devName) @@ -1387,10 +1384,6 @@ void MainWindow::on_comboBox_currentIndexChanged(const QString &arg1) ui->pushButtonAdd->setEnabled(true); ui->pushButtonModify->setEnabled(true); } - else if (SCANNER_ERR_DEVICE_NOT_SUPPORT == status) - { - QMessageBox::information(this, tr("Tips"), tr("Do not supported to open %1").arg(arg1)); - } else { m_timerId = this->startTimer(5000); @@ -1424,7 +1417,7 @@ void MainWindow::on_showMainWindowDlg() Show(); } -void MainWindow::on_saneEventCloseDevice(void* devHandle) +void MainWindow::on_saneEventCloseDevice(void* devHandle, bool isOnline) { assert(nullptr != m_devHandle || nullptr != devHandle); if (devHandle != m_devHandle) @@ -1446,7 +1439,8 @@ void MainWindow::on_saneEventCloseDevice(void* devHandle) m_timerId = -1; } - m_timerId = this->startTimer(5000); + if (isOnline) + m_timerId = this->startTimer(5000); } void MainWindow:: on_pushButtonAdd_clicked() diff --git a/app/scantool/mainwindow.h b/app/scantool/mainwindow.h index 18e02677..1d33c4a0 100644 --- a/app/scantool/mainwindow.h +++ b/app/scantool/mainwindow.h @@ -60,7 +60,7 @@ signals: void scanImage(unsigned int count); void scanFinish(); void closeDevice(); - void saneEventCloseDevice(void* devHandle); + void saneEventCloseDevice(void* devHandle, bool isOnline); private slots: void on_deviceArrive(QString devName); @@ -74,7 +74,7 @@ private slots: void on_pushButtonScan_clicked(); void on_trayActivated(QSystemTrayIcon::ActivationReason reason); void on_showMainWindowDlg(); - void on_saneEventCloseDevice(void* devHandle); + void on_saneEventCloseDevice(void* devHandle, bool isOnline); void on_pushButtonAdd_clicked(); void on_pushButtonModify_clicked(); void on_pushButtonRemove_clicked(); diff --git a/build.bat b/build.bat index 05b539c8..dd1d84ad 100644 --- a/build.bat +++ b/build.bat @@ -247,6 +247,9 @@ if "%OEM%" == "hw" ( cd /d HGTwainUI %QT_STATIC_PATH%/x86-windows-static-md/tools/qt5/bin/qmake -r -tp vc HGTwainUI.pro MSBuild.exe HGTwainUI.vcxproj -t:rebuild /m:8 /p:Configuration=Release + cd /d ../HGScanTool + %QT_STATIC_PATH%/x86-windows-static-md/tools/qt5/bin/qmake -r -tp vc HGScanTool.pro + MSBuild.exe HGScanTool.vcxproj -t:rebuild /m:8 /p:Configuration=Release cd /d ../ ) )