From 7d3fffbb114793ce0ae386d715de83a40fc40ace Mon Sep 17 00:00:00 2001 From: yangjiaxuan <171295266@qq.com> Date: Fri, 18 Aug 2023 12:47:18 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=B7=B3=E8=BF=87=E7=A9=BA?= =?UTF-8?q?=E7=99=BD=E9=A1=B5=E4=B8=8D=E5=87=BA=E5=9B=BE=E6=8A=A5=E9=94=99?= =?UTF-8?q?IO=E5=9B=BD=E4=BA=A7=E5=8F=AA=E8=83=BD=E6=89=93=E5=BC=80?= =?UTF-8?q?=E7=AC=AC=E4=B8=80=E5=8F=B0=E8=AE=BE=E5=A4=87=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 --- modules/sane_user/HGSaneImpl.cpp | 19 ++++++++++++++----- modules/twainui/dialog_device_select.cpp | 5 +++++ modules/twainui/dialog_device_select.h | 3 +++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/modules/sane_user/HGSaneImpl.cpp b/modules/sane_user/HGSaneImpl.cpp index d871739b..caa876f2 100644 --- a/modules/sane_user/HGSaneImpl.cpp +++ b/modules/sane_user/HGSaneImpl.cpp @@ -510,7 +510,7 @@ HGResult HGSaneSourceImpl::OpenSelectedDevice(HGWindow parent, class HGSaneDevic char devName[256] = {0}; for (int i = 0; i < devs.size(); ++i) { - if (devs[i].id = id) + if (devs[i].id == id) { strcpy(devName, devs[i].name.c_str()); m_saneApi.sane_open_api(devs[i].name.c_str(), &handle); @@ -1016,15 +1016,24 @@ void HGAPI HGSaneDeviceImpl::ThreadFunc(HGThread thread, HGPointer param) } else if (SANE_STATUS_EOF == stat2) { - if (0 == readSize && p->m_cancelScan) + if (0 == readSize) { free(buffer); - if (NULL != p->m_scanNotify) - p->m_scanNotify((int)SANE_EVENT_SCAN_FINISHED, (void*)saneAPI.sane_strstatus_api(SANE_STATUS_CANCELLED), (int)SANE_STATUS_CANCELLED); + if (p->m_cancelScan) + { + if (NULL != p->m_scanNotify) + p->m_scanNotify((int)SANE_EVENT_SCAN_FINISHED, (void*)saneAPI.sane_strstatus_api(SANE_STATUS_CANCELLED), (int)SANE_STATUS_CANCELLED); + } + else + { + if (NULL != p->m_scanNotify) + p->m_scanNotify((int)SANE_EVENT_SCAN_FINISHED, NULL, 0); + } + break; } - if (0 == readSize || readSize != params.bytes_per_line * params.lines) + if (readSize != params.bytes_per_line * params.lines) { free(buffer); if (NULL != p->m_scanNotify) diff --git a/modules/twainui/dialog_device_select.cpp b/modules/twainui/dialog_device_select.cpp index 58d0e300..3cc7df50 100644 --- a/modules/twainui/dialog_device_select.cpp +++ b/modules/twainui/dialog_device_select.cpp @@ -113,3 +113,8 @@ void Dialog_device_select::on_pbtn_cancel_clicked() m_devId = -1; reject(); } + +void Dialog_device_select::on_listWidget_itemDoubleClicked(QListWidgetItem *item) +{ + on_pbtn_ok_clicked(); +} diff --git a/modules/twainui/dialog_device_select.h b/modules/twainui/dialog_device_select.h index 5be7ea7b..e9ea5a7a 100644 --- a/modules/twainui/dialog_device_select.h +++ b/modules/twainui/dialog_device_select.h @@ -3,6 +3,7 @@ #include #include "twainui.h" +#include namespace Ui { class Dialog_device_select; @@ -26,6 +27,8 @@ private slots: void on_pbtn_cancel_clicked(); + void on_listWidget_itemDoubleClicked(QListWidgetItem *item); + private: Ui::Dialog_device_select *ui;