From 4ce0b0cba1efac6a0143f490f5fdbfbf73cf29c5 Mon Sep 17 00:00:00 2001 From: luoliangyi <87842688@qq.com> Date: Sat, 2 Dec 2023 16:29:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=8F=8C=E5=87=BB=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=8C=89=E9=92=AE=E5=AF=BC=E8=87=B4=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=AF=B9=E8=AF=9D=E6=A1=86=E7=9A=84=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E5=87=BD=E6=95=B0=E9=87=8D=E5=85=A5=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scanner2/device_user.cpp | 5 +++++ app/scanner2/device_user.h | 1 + app/scanner2/mainwindow.cpp | 21 ++++++++++++++++++++- app/scanner2/mainwindow.h | 2 ++ modules/twain_user/HGTwain.h | 1 + modules/twain_user/HGTwainImpl.cpp | 6 +++++- 6 files changed, 34 insertions(+), 2 deletions(-) diff --git a/app/scanner2/device_user.cpp b/app/scanner2/device_user.cpp index a39b377a..52d66483 100644 --- a/app/scanner2/device_user.cpp +++ b/app/scanner2/device_user.cpp @@ -165,6 +165,11 @@ void HGAPI DeviceUser::DSEventFunc(HGTwainDS ds, HGUInt event, HGPointer param) { emit p->scanWorkingEvent(); } + else if (HGTWAIN_EVENT_TYPE_CLOSEDSREQ == event) + { + HGTwain_DisableDS(p->m_twainDS); + emit p->closeDSReq(); + } } HGUInt HGAPI DeviceUser::DSImageFunc(HGTwainDS ds, HGImage image, HGUInt type, HGPointer param) diff --git a/app/scanner2/device_user.h b/app/scanner2/device_user.h index 9e214752..9ac87b09 100644 --- a/app/scanner2/device_user.h +++ b/app/scanner2/device_user.h @@ -61,6 +61,7 @@ signals: void newImage(void *image); void scanFinishEvent(); void scanWorkingEvent(); + void closeDSReq(); private: QWidget *m_wnd; diff --git a/app/scanner2/mainwindow.cpp b/app/scanner2/mainwindow.cpp index 87c3c18f..092cfba6 100644 --- a/app/scanner2/mainwindow.cpp +++ b/app/scanner2/mainwindow.cpp @@ -86,6 +86,7 @@ MainWindow::MainWindow(const QString& appLang, QWidget *parent) , m_bSideEditing(false) , m_ocrMsgPump(NULL) , m_ocrThread(NULL) + , m_dsEnabled(false) { ui->setupUi(this); @@ -375,6 +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); #if !defined(HG_CMP_MSC) checkRollerLife(); @@ -432,6 +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())); delete m_devUser; m_devUser = nullptr; } @@ -1516,6 +1519,11 @@ void MainWindow::on_scanFinishEvent() } } +void MainWindow::on_closeDSReq() +{ + m_dsEnabled = false; +} + void MainWindow::on_m_pbtn_push_clicked() { int mainWndWidth = this->rect().width(); @@ -3312,12 +3320,20 @@ void MainWindow::on_act_about_triggered() void MainWindow::on_act_scannerSettings_triggered() { - if (nullptr == m_devUser) + if (nullptr == m_devUser || m_dsEnabled) { return; } + m_dsEnabled = true; + + qDebug("m_devUser->ShowSettingDlg()"); HGResult ret = m_devUser->ShowSettingDlg(); + if (HGBASE_ERR_OK != ret) + { + m_dsEnabled = false; + } + bool deviceIsOnline = true; bool openSucceed = true; @@ -4263,6 +4279,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())); m_devUser->Logout(); delete m_devUser; m_devUser = nullptr; @@ -4526,6 +4543,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())); m_devUser->Logout(); delete m_devUser; m_devUser = nullptr; @@ -4548,6 +4566,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); #if !defined(HG_CMP_MSC) checkRollerLife(); #endif diff --git a/app/scanner2/mainwindow.h b/app/scanner2/mainwindow.h index aab30430..2ea0b8c0 100644 --- a/app/scanner2/mainwindow.h +++ b/app/scanner2/mainwindow.h @@ -146,6 +146,7 @@ private slots: void on_abnormalImage(void *image, HGUInt *result); void on_scanFinishEvent(); void on_scanWorkingEvent(); + void on_closeDSReq(); 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); @@ -277,6 +278,7 @@ private: bool m_canClose; DeviceUserMgr *m_devUserMgr; DeviceUser *m_devUser; + bool m_dsEnabled; QAction *m_act_acquireInto2; QComboBox *m_cbtn_acquireIntoCfg; QString m_currLang; diff --git a/modules/twain_user/HGTwain.h b/modules/twain_user/HGTwain.h index b8a1c1ae..18e1bb35 100644 --- a/modules/twain_user/HGTwain.h +++ b/modules/twain_user/HGTwain.h @@ -37,6 +37,7 @@ typedef struct #define HGTWAIN_EVENT_TYPE_WORKING 1L #define HGTWAIN_EVENT_TYPE_SCANFINISHED 2L +#define HGTWAIN_EVENT_TYPE_CLOSEDSREQ 3L #define HGTWAIN_IMAGE_TYPE_NORMAL 0L diff --git a/modules/twain_user/HGTwainImpl.cpp b/modules/twain_user/HGTwainImpl.cpp index 6199495b..b0603bf3 100644 --- a/modules/twain_user/HGTwainImpl.cpp +++ b/modules/twain_user/HGTwainImpl.cpp @@ -298,7 +298,11 @@ LRESULT CALLBACK HGTwainDSMImpl::NewWndProc(HWND hWnd, UINT msg, WPARAM wParam, } else if (MSG_CLOSEDSREQ == twEvent.TWMessage) { - p->m_listDSImpl[i]->Disable(); + if (p->m_listDSImpl[i]->m_eventFunc) + { + p->m_listDSImpl[i]->m_eventFunc((HGTwainDS)p->m_listDSImpl[i], + HGTWAIN_EVENT_TYPE_CLOSEDSREQ, p->m_listDSImpl[i]->m_eventParam); + } } } }