diff --git a/app/scanner2/mainwindow.cpp b/app/scanner2/mainwindow.cpp index feeca746..0e3140b6 100644 --- a/app/scanner2/mainwindow.cpp +++ b/app/scanner2/mainwindow.cpp @@ -2901,20 +2901,39 @@ void MainWindow::on_act_about_triggered() void MainWindow::on_act_scannerSettings_triggered() { - if (nullptr != m_devUser) + if (nullptr == m_devUser) { - HGResult ret = m_devUser->ShowSettingDlg(); - if (HGTWAIN_ERR_DEVICEOFFLINE == ret) - { - QMessageBox::information(this, tr("Prompt"), tr("Device is offline")); - deleteDevUser(); - } - else if (ret == HGTWAIN_ERR_FAIL) - { - QMessageBox::information(this, tr("Prompt"), tr("Open failed")); - deleteDevUser(); - } + return; } + + HGResult ret = m_devUser->ShowSettingDlg(); + bool deviceIsOnline = true; + bool openSucceed = true; + +#if defined(HG_CMP_MSC) + + if (HGTWAIN_ERR_DEVICEOFFLINE == ret) + deviceIsOnline = false; + else if (HGTWAIN_ERR_FAIL == ret) + openSucceed = false; +#else + if (HGSANE_ERR_DEVICEOFFLINE == ret) + deviceIsOnline = false; + else if (HGSANE_ERR_FAIL == ret) + openSucceed = false; + + if (!deviceIsOnline) + { + QMessageBox::information(this, tr("Prompt"), tr("Device is offline")); + deleteDevUser(); + } + else if (!openSucceed) + { + QMessageBox::information(this, tr("Prompt"), tr("Open failed")); + deleteDevUser(); + } +#endif + } void MainWindow::on_act_acquire_triggered() diff --git a/modules/sane_user/HGSaneErr.h b/modules/sane_user/HGSaneErr.h index 827e169d..584a4a0f 100644 --- a/modules/sane_user/HGSaneErr.h +++ b/modules/sane_user/HGSaneErr.h @@ -4,4 +4,7 @@ /* 一般错误 */ #define HGSANE_ERR_FAIL 0x00004001L -#endif /* __HGSANEERR_H__ */ \ No newline at end of file +/* 设备离线 */ +#define HGSANE_ERR_DEVICEOFFLINE 0x00004002L + +#endif /* __HGSANEERR_H__ */ diff --git a/modules/sane_user/HGSaneImpl.cpp b/modules/sane_user/HGSaneImpl.cpp index f32a2afc..3d51e282 100644 --- a/modules/sane_user/HGSaneImpl.cpp +++ b/modules/sane_user/HGSaneImpl.cpp @@ -776,10 +776,19 @@ HGResult HGSaneDeviceImpl::ClearDeviceLog() HGResult HGSaneDeviceImpl::ShowSettingDlg(HGWindow parent) { - if (-2 == show_setting_ui(&m_sourceImpl->m_saneApi, m_devHandle, m_devName.c_str(), parent)) + int ret = show_setting_ui(&m_sourceImpl->m_saneApi, m_devHandle, m_devName.c_str(), parent); + if (-1 == ret) + { + return HGSANE_ERR_FAIL; + } + else if (-2 == ret) { return HGBASE_ERR_NOTSUPPORT; } + else if (-3 == ret) + { + return HGSANE_ERR_DEVICEOFFLINE; + } return HGBASE_ERR_OK; } diff --git a/modules/saneui/HGSaneUI.cpp b/modules/saneui/HGSaneUI.cpp index 22955725..8aaf898e 100644 --- a/modules/saneui/HGSaneUI.cpp +++ b/modules/saneui/HGSaneUI.cpp @@ -145,6 +145,15 @@ int show_setting_ui(const SANEAPI* saneApi, SANE_Handle handle, const char *devN QCoreApplication::installTranslator(&translator2); hg_settingdialog dlg(saneApi, handle, devName, qParent); + if (!dlg.IsValid()) + { + QCoreApplication::removeTranslator(&translator); + if (20127 != cp) + QCoreApplication::removeTranslator(&translator2); + + return -3; + } + dlg.exec(); QCoreApplication::removeTranslator(&translator); diff --git a/modules/saneui/SaneUI_zh_CN.qm b/modules/saneui/SaneUI_zh_CN.qm index 1f174d4b..852dabfb 100644 Binary files a/modules/saneui/SaneUI_zh_CN.qm and b/modules/saneui/SaneUI_zh_CN.qm differ diff --git a/modules/saneui/SaneUI_zh_CN.ts b/modules/saneui/SaneUI_zh_CN.ts index d1ba7567..d664e5d4 100644 --- a/modules/saneui/SaneUI_zh_CN.ts +++ b/modules/saneui/SaneUI_zh_CN.ts @@ -2946,7 +2946,7 @@ No: add new configuration The current parameter settings are inconsistent with the configuration scheme '%1'. To use the configuration scheme '%1' parameters, please click the restore button - 当前参数设置与配置方案 %1 不一致,如需使用配置方案 %1 参数,请点击恢复按钮 + 当前参数设置与配置方案 “%1” 不一致,如需使用配置方案 “%1” 参数,请点击恢复按钮 diff --git a/modules/saneui/hg_settingdialog.cpp b/modules/saneui/hg_settingdialog.cpp index c8bab67c..883c72f7 100644 --- a/modules/saneui/hg_settingdialog.cpp +++ b/modules/saneui/hg_settingdialog.cpp @@ -25,6 +25,7 @@ hg_settingdialog::hg_settingdialog(const SANEAPI* saneApi, SANE_Handle handle, c , m_isRefreshUi(false) , changed_count_(0) , cur_cfg_(nullptr) + , m_deviceIsValid(true) { m_dpiId = -1; m_dpiValue = 200; @@ -62,7 +63,9 @@ hg_settingdialog::hg_settingdialog(const SANEAPI* saneApi, SANE_Handle handle, c dev_que::update_old_cfg(old.toStdString().c_str()); int pid = 0; - m_saneAPI.sane_control_option_api(m_devHandle, (SANE_Int)0x8853, SANE_ACTION_GET_VALUE, &pid, NULL); + SANE_Status ret = m_saneAPI.sane_control_option_api(m_devHandle, (SANE_Int)0x8853, SANE_ACTION_GET_VALUE, &pid, NULL); + if (SANE_STATUS_GOOD != ret) + m_deviceIsValid = false; char buf[10] = { 0 }; sprintf(buf, "%x", pid); @@ -166,6 +169,11 @@ void hg_settingdialog::apply_scheme(SANE_Handle dev, LPSANEAPI api, gb::sane_con } } +bool hg_settingdialog::IsValid() +{ + return m_deviceIsValid; +} + void hg_settingdialog::initUi() { update_opt_value_from_driver(); diff --git a/modules/saneui/hg_settingdialog.h b/modules/saneui/hg_settingdialog.h index 17d0b25b..0701e807 100644 --- a/modules/saneui/hg_settingdialog.h +++ b/modules/saneui/hg_settingdialog.h @@ -54,6 +54,8 @@ public: static void apply_scheme(SANE_Handle dev, LPSANEAPI api, gb::sane_config_schm* schm); + bool IsValid(); + public: void initUi(); void update_opt_value_from_driver(); @@ -157,6 +159,7 @@ private: QComboBox *comb_; bool m_isRefreshUi; + bool m_deviceIsValid; }; #endif // HG_SETTING_DIALOG_H