twain驱动 QT版本引用调整
This commit is contained in:
parent
06e628bf84
commit
f5338f0215
|
@ -1,4 +1,6 @@
|
|||
#include "scanner.h"
|
||||
|
||||
|
||||
#include "scanner.h"
|
||||
|
||||
#include <Windows.h>
|
||||
#include <Shlwapi.h> // for PathFileExistsW
|
||||
|
@ -8,12 +10,13 @@
|
|||
#include "sane_option_trans.h"
|
||||
#include <chrono>
|
||||
#include <mutex>
|
||||
#include "DlgIndicator.h"
|
||||
|
||||
#include "DlgSetting.h"
|
||||
#include "gb_json.h"
|
||||
#include "../../sdk/include/lang/app_language.h"
|
||||
#include <functional>
|
||||
|
||||
#include "DlgIndicator.h"
|
||||
#include "twainui.h"
|
||||
#pragma comment(lib, "Shlwapi.lib")
|
||||
|
||||
|
||||
|
@ -338,10 +341,13 @@ namespace callback
|
|||
// SANE_EVENT_SCAN_FINISHED - void*: (utf8*)message, flag - error code (0 is success)
|
||||
// SANE_EVENT_USB_DATA_RECEIVED- void* unused, be NULL, flag - unused, be 0
|
||||
// SANE_EVENT_IMAGE_OK - void* unused, be NULL, flag - unused, be 0
|
||||
int (*choose_scanner)(const std::vector<DEVQUE>& devs) = NULL; // blocked. return selected DEVQUE::id or -1 if user cancelled
|
||||
int (*choose_scanner)(const std::vector<DEVQUEUI>& devs) = NULL; // blocked. return selected DEVQUE::id or -1 if user cancelled
|
||||
void (*apply_current_config)(const char* dev_name, SANE_Handle device, LPSANEAPI api) = NULL; // 应用设备的当前配置
|
||||
void (*show_setting_ui)(SANE_Handle device, HWND parent, LPSANEAPI api, bool with_scan/*是否显示“扫描”按钮*/, std::function<void(int)> callback) = NULL;
|
||||
void (*show_progress_ui)(HWND parent, std::function<void(int)> callback, std::function<void(int/*event*/, void*/*msg*/, int/*flag*/)>* notify) = NULL;
|
||||
void (*show_setting_ui)(SANE_Handle device, HWND parent, LPSANEAPI api, bool with_scan) = NULL;
|
||||
void (*show_progress_ui)(HWND parent, std::function<void(ui_result)> callback, std::function<void(int/*event*/, void*/*msg*/, int/*flag*/)>* notify) = NULL;
|
||||
|
||||
//std::function<void(ui_result)> ui_result_callback;
|
||||
std::function<void(int/*event*/, void*/*msg*/, int/*flag*/)> notify;
|
||||
static void init_ui(void)
|
||||
{
|
||||
std::string root(hg_sane_middleware::sane_path());
|
||||
|
@ -765,7 +771,7 @@ std::string scanner::choose_scanner(const std::vector<std::string>& scanners)
|
|||
if (scanners.empty())
|
||||
return "";
|
||||
|
||||
std::vector<DEVQUE> devs;
|
||||
std::vector<DEVQUEUI> devs;
|
||||
std::string sel("");
|
||||
int id = 1;
|
||||
|
||||
|
@ -780,7 +786,7 @@ std::string scanner::choose_scanner(const std::vector<std::string>& scanners)
|
|||
scanner::control_read_string(h, IO_CTRL_CODE_GET_SERIAL, sn);
|
||||
if (sn.length())
|
||||
{
|
||||
DEVQUE dev;
|
||||
DEVQUEUI dev;
|
||||
dev.id = id++;
|
||||
dev.name = scanners[i];
|
||||
dev.sn = sn;
|
||||
|
@ -811,9 +817,9 @@ std::string scanner::choose_scanner(const std::vector<std::string>& scanners)
|
|||
}
|
||||
else
|
||||
{
|
||||
dlg_choose_dev dlg(NULL, devs);
|
||||
dlg.show(true, true);
|
||||
sel = dlg.get_selected_device();
|
||||
//dlg_choose_dev dlg(NULL, devs);
|
||||
//dlg.show(true, true);
|
||||
//sel = dlg.get_selected_device();
|
||||
}
|
||||
|
||||
return sel;
|
||||
|
@ -2898,7 +2904,7 @@ COM_API_IMPLEMENT(scanner, bool, ui_show_setting(HWND parent, bool with_scan, bo
|
|||
{
|
||||
on_ui_event(ev, NULL);
|
||||
};
|
||||
callback::show_setting_ui(handle_, parent, &sane_api_, with_scan, cb);
|
||||
callback::show_setting_ui(handle_, parent, &sane_api_, with_scan);
|
||||
}
|
||||
else if (cfg_)
|
||||
{
|
||||
|
@ -2931,6 +2937,13 @@ COM_API_IMPLEMENT(scanner, bool, ui_show_progress(HWND parent))
|
|||
{
|
||||
if (callback::show_progress_ui)
|
||||
{
|
||||
auto ui_process = [](ui_result)
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
|
||||
callback::show_progress_ui(parent, ui_process,&ui_notify);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3021,6 +3034,11 @@ int scanner::handle_device_event(int ev_code, void* data, unsigned int* len)
|
|||
err_ = *len;
|
||||
if (indicator_.get())
|
||||
indicator_->notify_scan_over((char*)data, *len != SCANNER_ERR_OK);
|
||||
else if (callback::show_progress_ui)
|
||||
{
|
||||
ui_notify(ev_code, data, 0);
|
||||
on_ui_event(ev_code, (void*)ev_code);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*len)
|
||||
|
@ -3033,7 +3051,7 @@ int scanner::handle_device_event(int ev_code, void* data, unsigned int* len)
|
|||
on_ui_event(ev_code, (void*)ev_code);
|
||||
}
|
||||
// is_scanning_ = false;
|
||||
|
||||
|
||||
{
|
||||
wchar_t msg[128] = { 0 };
|
||||
swprintf_s(msg, _countof(msg) - 1, L"Scan finished with error: %u\r\n", *len);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
|
||||
#define SANE_OPTION_ID(name) \
|
||||
SANE_OPTION_ID_OVERRIDE(name); \
|
||||
|
@ -57,7 +58,7 @@ class scanner : public ISaneInvoker, virtual public refer
|
|||
gb::scanner_cfg* cfg_;
|
||||
bool twain_set_;
|
||||
SANEAPI sane_api_;
|
||||
|
||||
std::function<void(int, void*, int)> ui_notify;
|
||||
int(__stdcall* scanner_ev_handler_)(int, void*);
|
||||
void* evh_param_;
|
||||
HWND app_wnd_; // for MessageBox
|
||||
|
|
Loading…
Reference in New Issue