From f6e1c03277fbb4b50fe6fdd6df074006f5235c77 Mon Sep 17 00:00:00 2001 From: yangjiaxuan <171295266@qq.com> Date: Mon, 22 May 2023 17:41:44 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/twainui/device_menu.h | 8 +------- modules/twainui/hg_settingdialog.cpp | 11 +++++++++-- modules/twainui/twainui.cpp | 14 ++++++++++---- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/modules/twainui/device_menu.h b/modules/twainui/device_menu.h index c9091542..7e96a53d 100644 --- a/modules/twainui/device_menu.h +++ b/modules/twainui/device_menu.h @@ -284,15 +284,9 @@ public: { root_dir_ = std::string(root) + PATH_SYMBOL; } - void add_scanner(const char* sane_name, int pid) + void add_scanner(const char* sane_name) { - char buf[10] = { 0 }; - sprintf(buf, "%x", pid); std::string devName = sane_name; - if (pid != 0) - { - devName = devName.substr(0, devName.find(" - ")) + " - " + buf; - } bool found = false; diff --git a/modules/twainui/hg_settingdialog.cpp b/modules/twainui/hg_settingdialog.cpp index fbe4c05d..7ca27b0a 100644 --- a/modules/twainui/hg_settingdialog.cpp +++ b/modules/twainui/hg_settingdialog.cpp @@ -56,8 +56,15 @@ hg_settingdialog::hg_settingdialog(SANE_Handle handle, const SANEAPI* saneApi, b int pid = 0; saneApi->sane_control_option_api(m_devHandle, (SANE_Int)0x8853, SANE_ACTION_GET_VALUE, &pid, NULL); - dev_que_.add_scanner(devName, pid); - dev_que_.open_scanner(saneApi, handle, devName, false); + char buf[10] = { 0 }; + sprintf(buf, "%x", pid); + std::string deviceName = m_devName; + if (pid != 0) + { + deviceName = deviceName.substr(0, deviceName.find(" ")) + " " + buf; + } + dev_que_.add_scanner(deviceName.c_str()); + dev_que_.open_scanner(saneApi, handle, deviceName.c_str(), false); std::string n(dev_que_.opened_scanner_name()); for(int i = 0; i < dev_que_.scanners(); ++i) diff --git a/modules/twainui/twainui.cpp b/modules/twainui/twainui.cpp index efc5c01c..1129f9cb 100644 --- a/modules/twainui/twainui.cpp +++ b/modules/twainui/twainui.cpp @@ -63,13 +63,19 @@ char *apply_current_config(const char *dev_name, SANE_Handle device, LPSANEAPI a if(QFile::exists(old)) dev_que::update_old_cfg(old.toStdString().c_str()); - std::string devName = dev_name; - int pid = 0; api->sane_control_option_api(device, (SANE_Int)0x8853, SANE_ACTION_GET_VALUE, &pid, NULL); - devQue.add_scanner(devName.c_str(), pid); - devQue.open_scanner(api, device, dev_name, true); + char buf[10] = { 0 }; + sprintf(buf, "%x", pid); + std::string devName = dev_name; + if (pid != 0) + { + devName = devName.substr(0, devName.find(" ")) + " " + buf; + } + + devQue.add_scanner(devName.c_str()); + devQue.open_scanner(api, device, devName.c_str(), true); std::string n(devQue.opened_scanner_name()); for(int i = 0; i < devQue.scanners(); ++i)