From 65df84f277a318115673c85835fca177c4c9169c Mon Sep 17 00:00:00 2001 From: 13038267101 Date: Mon, 8 May 2023 15:31:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=20qt=20twain=20=E9=80=80?= =?UTF-8?q?=E5=87=BA=E7=8A=B6=E6=80=81=E4=B8=8D=E5=AF=B9=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 --- sane/scanner.cpp | 69 +++++++++++++----------------------------------- sane/scanner.h | 2 +- 2 files changed, 19 insertions(+), 52 deletions(-) diff --git a/sane/scanner.cpp b/sane/scanner.cpp index ac75503..6c1475e 100644 --- a/sane/scanner.cpp +++ b/sane/scanner.cpp @@ -705,67 +705,28 @@ void scanner::on_ui_event(int uev, void* sender) { //wchar_t info[128] = { 0 }; //(info, _countof(info) - 1, L"[CRAZY]%d scanner events stored but APP has no action, we try to trigger it ONCE ...\r\n", ev_cnt_); - //ev_cnt_--; + ev_cnt_; h(SANE_EVENT_UI_SCAN_COMMAND, evh_param_); return; } } - - bool indicator = sender == indicator_.get(); if (uev == SANE_EVENT_SCAN_FINISHED || uev == SANE_EVENT_UI_CLOSE_NORMAL || uev == SANE_EVENT_UI_CLOSE_CANCEL) { if (uev == SANE_EVENT_UI_CLOSE_CANCEL) stop(); - if (indicator) - indicator_.reset(); - is_scanning_ = false; - if (err_ && setting_.get()) - { - return; - } } - //int(__stdcall * h)(int, void*) = scanner_ev_handler_; - //if (h) - //{ - // if (SANE_EVENT_UI_CLOSE_SETTING == uev) - // { - // is_scanning_ = false; - // setting_.reset(); - // } - - // h(uev, evh_param_); - // return; - //} - - //if (prev_start_result_ != SANE_STATUS_GOOD && indicator) - // indicator_.reset(); - //else + if (uev == SANE_EVENT_UI_CLOSE_CANCEL || uev == SANE_EVENT_UI_CLOSE_NORMAL || uev == SANE_EVENT_UI_CLOSE_SETTING) { - //if (uev == SANE_EVENT_UI_SCAN_COMMAND) - //{ - // ui_show_progress(NULL); - // start(); - // return; - //} - - if (/*events_.count() > 5 && !is_ui_wait_img_ &&*/ - (uev == SANE_EVENT_UI_CLOSE_CANCEL || uev == SANE_EVENT_UI_CLOSE_NORMAL || uev == SANE_EVENT_UI_CLOSE_SETTING)) - { - // events_.clear(); - ui_hide(); - if(indicator || !indicator_.get()) - uev = SANE_EVENT_SCAN_FINISHED; - else - uev = SANE_EVENT_UI_CLOSE_SETTING; - } - - events_.save(uev, sizeof(uev)); - ev_cnt_++; + events_.clear(); + uev = SANE_EVENT_UI_CLOSE_SETTING; } + events_.save(uev, sizeof(uev)); + ev_cnt_++; + if (ev_cnt_ == events_.count() && @@ -2942,6 +2903,7 @@ COM_API_IMPLEMENT(scanner, bool, ui_show_main(HWND parent)) } COM_API_IMPLEMENT(scanner, bool, ui_show_setting(HWND parent, bool with_scan, bool indicator)) { + is_show_ui_ = with_scan; if (callback::show_setting_ui) { auto ui = [this](ui_result res) @@ -2956,10 +2918,12 @@ COM_API_IMPLEMENT(scanner, bool, ui_show_setting(HWND parent, bool with_scan, bo break; case UI_RESULT_CLOSE_NORMAL: + is_show_ui_ = false; uev = SANE_EVENT_UI_CLOSE_NORMAL; on_ui_event(uev, (void*)uev); break; case UI_RESULT_CLOSE_CANCEL: + is_show_ui_ = false; uev = SANE_EVENT_UI_CLOSE_CANCEL; on_ui_event(uev, (void*)uev); @@ -3033,12 +2997,17 @@ COM_API_IMPLEMENT(scanner, bool, ui_show_progress(HWND parent, bool bIndicator)) break; case UI_RESULT_CLOSE_NORMAL: uev = SANE_EVENT_UI_CLOSE_NORMAL; - on_ui_event(uev, (void*)uev); + if (!is_show_ui_) + { + on_ui_event(uev, (void*)uev); + } break; case UI_RESULT_CLOSE_CANCEL: uev = SANE_EVENT_UI_CLOSE_CANCEL; - on_ui_event(uev, (void*)uev); - + if (!is_show_ui_) + { + on_ui_event(uev, (void*)uev); + } break; case UI_RESULT_START_SCAN: break; @@ -3048,8 +3017,6 @@ COM_API_IMPLEMENT(scanner, bool, ui_show_progress(HWND parent, bool bIndicator)) }; if (callback::show_progress_ui && bIndicator) { - - callback::show_progress_ui(parent, ui_process,&ui_notify); } else diff --git a/sane/scanner.h b/sane/scanner.h index 11f82f1..a0df8ad 100644 --- a/sane/scanner.h +++ b/sane/scanner.h @@ -63,7 +63,7 @@ class scanner : public ISaneInvoker, virtual public refer int(__stdcall* scanner_ev_handler_)(int, void*); void* evh_param_; HWND app_wnd_; // for MessageBox - + bool is_show_ui_; void transport_config_file(void); void update_config(void); void load_config(const wchar_t* file);