ui_setting接口调整
This commit is contained in:
parent
658ef6c120
commit
583c545c28
|
@ -343,7 +343,7 @@ namespace callback
|
||||||
// SANE_EVENT_IMAGE_OK - 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<DEVQUEUI>& 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
|
||||||
int (*apply_current_config)(const char* dev_name, SANE_Handle device, LPSANEAPI api) = NULL; // 应用设备的当前配置
|
int (*apply_current_config)(const char* dev_name, SANE_Handle device, LPSANEAPI api) = NULL; // 应用设备的当前配置
|
||||||
int (*show_setting_ui)(SANE_Handle device, HWND parent, LPSANEAPI api, const char* devname, bool with_scan) = NULL;
|
int (*show_setting_ui)(SANE_Handle device, HWND parent, LPSANEAPI api, const char* devname, bool with_scan, std::function<void(ui_result)> callback) = NULL;
|
||||||
int (*show_progress_ui)(HWND parent, std::function<void(ui_result)> callback, std::function<void(int/*event*/, void*/*msg*/, int/*flag*/)>* notify) = NULL;
|
int (*show_progress_ui)(HWND parent, std::function<void(ui_result)> callback, std::function<void(int/*event*/, void*/*msg*/, int/*flag*/)>* notify) = NULL;
|
||||||
int (*show_messagebox_ui)(HWND parent, int event, void* msg, int flag) = NULL;
|
int (*show_messagebox_ui)(HWND parent, int event, void* msg, int flag) = NULL;
|
||||||
|
|
||||||
|
@ -2944,53 +2944,50 @@ COM_API_IMPLEMENT(scanner, bool, ui_show_setting(HWND parent, bool with_scan, bo
|
||||||
{
|
{
|
||||||
if (callback::show_setting_ui)
|
if (callback::show_setting_ui)
|
||||||
{
|
{
|
||||||
auto cb = [&](int ev)
|
auto ui = [this](ui_result res)
|
||||||
{
|
{
|
||||||
on_ui_event(ev, NULL);
|
int uev = SANE_EVENT_SCAN_FINISHED;
|
||||||
|
switch (res)
|
||||||
|
{
|
||||||
|
case UI_RESULT_FAILED:
|
||||||
|
|
||||||
|
break;
|
||||||
|
case UI_RESULT_OK:
|
||||||
|
|
||||||
|
break;
|
||||||
|
case UI_RESULT_CLOSE_NORMAL:
|
||||||
|
uev = SANE_EVENT_UI_CLOSE_NORMAL;
|
||||||
|
on_ui_event(uev, (void*)uev);
|
||||||
|
break;
|
||||||
|
case UI_RESULT_CLOSE_CANCEL:
|
||||||
|
uev = SANE_EVENT_UI_CLOSE_CANCEL;
|
||||||
|
on_ui_event(uev, (void*)uev);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case UI_RESULT_START_SCAN:
|
||||||
|
on_ui_event(SANE_EVENT_UI_SCAN_COMMAND, NULL);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
int res = callback::show_setting_ui(handle_, parent, &sane_api_, local_trans::u2a(scanner_name_.c_str(), CP_UTF8).c_str(),with_scan, ui);
|
||||||
//auto ui_process = [this](ui_result res)
|
//if (res == ui_result::UI_RESULT_CLOSE_NORMAL)
|
||||||
//{
|
//{
|
||||||
// int uev = SANE_EVENT_SCAN_FINISHED;
|
// int ev = SANE_EVENT_UI_CLOSE_NORMAL;
|
||||||
// switch (res)
|
// on_ui_event(ev, (void*)ev);
|
||||||
// {
|
//}
|
||||||
// case UI_RESULT_FAILED:
|
//else if (res == ui_result::UI_RESULT_START_SCAN)
|
||||||
|
//{
|
||||||
// break;
|
// //callback::show_progress_ui(parent, ui_process, &ui_notify);
|
||||||
// case UI_RESULT_OK:
|
// //start();
|
||||||
// break;
|
// on_ui_event(SANE_EVENT_UI_SCAN_COMMAND, NULL);
|
||||||
// case UI_RESULT_CLOSE_NORMAL:
|
//}
|
||||||
// uev = SANE_EVENT_UI_CLOSE_NORMAL;
|
//else if (res == UI_RESULT_CLOSE_CANCEL)
|
||||||
// on_ui_event(uev, (void*)uev);
|
//{
|
||||||
// break;
|
// int ev = SANE_EVENT_UI_CLOSE_CANCEL;
|
||||||
// case UI_RESULT_CLOSE_CANCEL:
|
// on_ui_event(ev, (void*)ev);
|
||||||
// uev = SANE_EVENT_UI_CLOSE_CANCEL;
|
//}
|
||||||
// sane_api_.sane_cancel_api(handle_);
|
|
||||||
// //on_ui_event(uev, (void*)uev);
|
|
||||||
// break;
|
|
||||||
// case UI_RESULT_START_SCAN:
|
|
||||||
// break;
|
|
||||||
// default:
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
//};
|
|
||||||
int res = callback::show_setting_ui(handle_, parent, &sane_api_, local_trans::u2a(scanner_name_.c_str(), CP_UTF8).c_str(),with_scan);
|
|
||||||
if (res == ui_result::UI_RESULT_CLOSE_NORMAL)
|
|
||||||
{
|
|
||||||
int ev = SANE_EVENT_UI_CLOSE_NORMAL;
|
|
||||||
on_ui_event(ev, (void*)ev);
|
|
||||||
}
|
|
||||||
else if (res == ui_result::UI_RESULT_START_SCAN)
|
|
||||||
{
|
|
||||||
//callback::show_progress_ui(parent, ui_process, &ui_notify);
|
|
||||||
//start();
|
|
||||||
on_ui_event(SANE_EVENT_UI_SCAN_COMMAND, NULL);
|
|
||||||
}
|
|
||||||
else if (res == UI_RESULT_CLOSE_CANCEL)
|
|
||||||
{
|
|
||||||
int ev = SANE_EVENT_UI_CLOSE_CANCEL;
|
|
||||||
on_ui_event(ev, (void*)ev);
|
|
||||||
}
|
|
||||||
//on_ui_event(ev, NULL);
|
//on_ui_event(ev, NULL);
|
||||||
}
|
}
|
||||||
else if (cfg_)
|
else if (cfg_)
|
||||||
|
@ -3096,9 +3093,6 @@ int scanner::handle_device_event(int ev_code, void* data, unsigned int* len)
|
||||||
ui_notify(ev_code, data, *len);
|
ui_notify(ev_code, data, *len);
|
||||||
//else
|
//else
|
||||||
on_ui_event(ev_code, (void*)ev_code);
|
on_ui_event(ev_code, (void*)ev_code);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
log_info(L"Scanning ...\r\n", 0);
|
log_info(L"Scanning ...\r\n", 0);
|
||||||
}
|
}
|
||||||
else if (ev_code == SANE_EVENT_IMAGE_OK)
|
else if (ev_code == SANE_EVENT_IMAGE_OK)
|
||||||
|
|
Loading…
Reference in New Issue