From 801b302e58a64d24f913c28a28e8c53bc37c5cff Mon Sep 17 00:00:00 2001 From: luoliangyi <87842688@qq.com> Date: Mon, 4 Dec 2023 09:07:03 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=81=9C=E6=AD=A2=E6=89=AB?= =?UTF-8?q?=E6=8F=8F=E5=90=8E=EF=BC=8C=E6=8F=90=E7=A4=BA=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E7=BB=A7=E7=BB=AD=E7=9A=84=E5=AF=B9=E8=AF=9D=E6=A1=86=E6=9C=89?= =?UTF-8?q?=E6=97=B6=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=87=BA=E6=9D=A5=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scanner2/device_user.cpp | 14 +++++++++++--- app/scanner2/device_user.h | 5 ++++- app/scanner2/mainwindow.cpp | 15 +++++++++------ app/scanner2/mainwindow.h | 2 +- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/app/scanner2/device_user.cpp b/app/scanner2/device_user.cpp index 52d66483..551dea86 100644 --- a/app/scanner2/device_user.cpp +++ b/app/scanner2/device_user.cpp @@ -86,6 +86,11 @@ QString DeviceUser::GetName() return QString(devName); } +HGResult DeviceUser::Clear() +{ + return HGTwain_DisableDS(m_twainDS); +} + HGResult DeviceUser::ShowSettingDlg() { return HGTwain_EnableDSUIOnly(m_twainDS, (HWND)m_wnd->winId(), DSEventFunc, this); @@ -158,7 +163,6 @@ void HGAPI DeviceUser::DSEventFunc(HGTwainDS ds, HGUInt event, HGPointer param) DeviceUser* p = (DeviceUser*)param; if (HGTWAIN_EVENT_TYPE_SCANFINISHED == event) { - HGTwain_DisableDS(p->m_twainDS); emit p->scanFinishEvent(); } else if (HGTWAIN_EVENT_TYPE_WORKING == event) @@ -167,8 +171,7 @@ void HGAPI DeviceUser::DSEventFunc(HGTwainDS ds, HGUInt event, HGPointer param) } else if (HGTWAIN_EVENT_TYPE_CLOSEDSREQ == event) { - HGTwain_DisableDS(p->m_twainDS); - emit p->closeDSReq(); + emit p->clearRes(); } } @@ -291,6 +294,11 @@ QString DeviceUser::GetName() return QString(devName); } +HGResult DeviceUser::Clear() +{ + return HGBASE_ERR_OK; +} + HGResult DeviceUser::ShowSettingDlg() { return HGSane_ShowDeviceSettingDlg(m_saneDev, m_wnd); diff --git a/app/scanner2/device_user.h b/app/scanner2/device_user.h index 9ac87b09..af9fd62b 100644 --- a/app/scanner2/device_user.h +++ b/app/scanner2/device_user.h @@ -39,6 +39,7 @@ public: HGResult Close(); // 获取设备名字 QString GetName(); + HGResult Clear(); // 弹出配置对话框 HGResult ShowSettingDlg(); // 弹出扫描对话框 @@ -61,7 +62,7 @@ signals: void newImage(void *image); void scanFinishEvent(); void scanWorkingEvent(); - void closeDSReq(); + void clearRes(); private: QWidget *m_wnd; @@ -104,6 +105,7 @@ public: HGResult Close(); // 获取设备名字 QString GetName(); + HGResult Clear(); // 弹出配置对话框 HGResult ShowSettingDlg(); // 弹出扫描对话框 @@ -128,6 +130,7 @@ signals: void abnormalImage(void *image, HGUInt *result); void scanFinishEvent(); void scanWorkingEvent(); + void clearRes(); private: QWidget *m_wnd; diff --git a/app/scanner2/mainwindow.cpp b/app/scanner2/mainwindow.cpp index 092cfba6..8b3557ae 100644 --- a/app/scanner2/mainwindow.cpp +++ b/app/scanner2/mainwindow.cpp @@ -376,7 +376,7 @@ MainWindow::MainWindow(const QString& appLang, QWidget *parent) connect(m_devUser, SIGNAL(abnormalImage(void*,HGUInt*)), this, SLOT(on_abnormalImage(void*,HGUInt*)), Qt::BlockingQueuedConnection); connect(m_devUser, SIGNAL(scanWorkingEvent()), this, SLOT(on_scanWorkingEvent()), Qt::QueuedConnection); connect(m_devUser, SIGNAL(scanFinishEvent()), this, SLOT(on_scanFinishEvent()), Qt::QueuedConnection); - connect(m_devUser, SIGNAL(closeDSReq()), this, SLOT(on_closeDSReq()), Qt::QueuedConnection); + connect(m_devUser, SIGNAL(clearRes()), this, SLOT(on_clearRes()), Qt::QueuedConnection); #if !defined(HG_CMP_MSC) checkRollerLife(); @@ -434,7 +434,7 @@ MainWindow::~MainWindow() disconnect(m_devUser, SIGNAL(abnormalImage(void*,HGUInt*)), this, SLOT(on_abnormalImage(void*,HGUInt*))); disconnect(m_devUser, SIGNAL(scanWorkingEvent()), this, SLOT(on_scanWorkingEvent())); disconnect(m_devUser, SIGNAL(scanFinishEvent()), this, SLOT(on_scanFinishEvent())); - disconnect(m_devUser, SIGNAL(closeDSReq()), this, SLOT(on_closeDSReq())); + disconnect(m_devUser, SIGNAL(clearRes()), this, SLOT(on_clearRes())); delete m_devUser; m_devUser = nullptr; } @@ -1345,6 +1345,8 @@ void MainWindow::on_scanWorkingEvent() void MainWindow::on_scanFinishEvent() { + m_devUser->Clear(); + HGBase_EnterLock(m_lockPreviewImage); HGBase_DestroyImage(m_previewImage); m_previewImage = nullptr; @@ -1519,8 +1521,9 @@ void MainWindow::on_scanFinishEvent() } } -void MainWindow::on_closeDSReq() +void MainWindow::on_clearRes() { + m_devUser->Clear(); m_dsEnabled = false; } @@ -4279,7 +4282,7 @@ void MainWindow::deleteDevUser() disconnect(m_devUser, SIGNAL(abnormalImage(void*,HGUInt*)), this, SLOT(on_abnormalImage(void*,HGUInt*))); disconnect(m_devUser, SIGNAL(scanWorkingEvent()), this, SLOT(on_scanWorkingEvent())); disconnect(m_devUser, SIGNAL(scanFinishEvent()), this, SLOT(on_scanFinishEvent())); - disconnect(m_devUser, SIGNAL(closeDSReq()), this, SLOT(on_closeDSReq())); + disconnect(m_devUser, SIGNAL(clearRes()), this, SLOT(on_clearRes())); m_devUser->Logout(); delete m_devUser; m_devUser = nullptr; @@ -4543,7 +4546,7 @@ void MainWindow::on_act_selectDevice_triggered() disconnect(m_devUser, SIGNAL(abnormalImage(void*,HGUInt*)), this, SLOT(on_abnormalImage(void*,HGUInt*))); disconnect(m_devUser, SIGNAL(scanWorkingEvent()), this, SLOT(on_scanWorkingEvent())); disconnect(m_devUser, SIGNAL(scanFinishEvent()), this, SLOT(on_scanFinishEvent())); - disconnect(m_devUser, SIGNAL(closeDSReq()), this, SLOT(on_closeDSReq())); + disconnect(m_devUser, SIGNAL(clearRes()), this, SLOT(on_clearRes())); m_devUser->Logout(); delete m_devUser; m_devUser = nullptr; @@ -4566,7 +4569,7 @@ void MainWindow::on_act_selectDevice_triggered() connect(m_devUser, SIGNAL(abnormalImage(void*,HGUInt*)), this, SLOT(on_abnormalImage(void*,HGUInt*)), Qt::BlockingQueuedConnection); connect(m_devUser, SIGNAL(scanWorkingEvent()), this, SLOT(on_scanWorkingEvent()), Qt::QueuedConnection); connect(m_devUser, SIGNAL(scanFinishEvent()), this, SLOT(on_scanFinishEvent()), Qt::QueuedConnection); - connect(m_devUser, SIGNAL(closeDSReq()), this, SLOT(on_closeDSReq()), Qt::QueuedConnection); + connect(m_devUser, SIGNAL(clearRes()), this, SLOT(on_clearRes()), Qt::QueuedConnection); #if !defined(HG_CMP_MSC) checkRollerLife(); #endif diff --git a/app/scanner2/mainwindow.h b/app/scanner2/mainwindow.h index 2ea0b8c0..b6b8cc74 100644 --- a/app/scanner2/mainwindow.h +++ b/app/scanner2/mainwindow.h @@ -146,7 +146,7 @@ private slots: void on_abnormalImage(void *image, HGUInt *result); void on_scanFinishEvent(); void on_scanWorkingEvent(); - void on_closeDSReq(); + void on_clearRes(); void on_m_pbtn_push_clicked(); void on_dialog_sideBar_applyToImage(HGImage img, int brightness, int contrast, double gamma, bool enhanceText); void on_dialog_sideBar_finish(bool ok);