sane调用,设备离线时点击设置增加提示
This commit is contained in:
parent
014268db63
commit
c3a71fe419
|
@ -2901,20 +2901,39 @@ void MainWindow::on_act_about_triggered()
|
||||||
|
|
||||||
void MainWindow::on_act_scannerSettings_triggered()
|
void MainWindow::on_act_scannerSettings_triggered()
|
||||||
{
|
{
|
||||||
if (nullptr != m_devUser)
|
if (nullptr == m_devUser)
|
||||||
{
|
{
|
||||||
HGResult ret = m_devUser->ShowSettingDlg();
|
return;
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
void MainWindow::on_act_acquire_triggered()
|
||||||
|
|
|
@ -4,4 +4,7 @@
|
||||||
/* 一般错误 */
|
/* 一般错误 */
|
||||||
#define HGSANE_ERR_FAIL 0x00004001L
|
#define HGSANE_ERR_FAIL 0x00004001L
|
||||||
|
|
||||||
|
/* 设备离线 */
|
||||||
|
#define HGSANE_ERR_DEVICEOFFLINE 0x00004002L
|
||||||
|
|
||||||
#endif /* __HGSANEERR_H__ */
|
#endif /* __HGSANEERR_H__ */
|
|
@ -776,10 +776,19 @@ HGResult HGSaneDeviceImpl::ClearDeviceLog()
|
||||||
|
|
||||||
HGResult HGSaneDeviceImpl::ShowSettingDlg(HGWindow parent)
|
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;
|
return HGBASE_ERR_NOTSUPPORT;
|
||||||
}
|
}
|
||||||
|
else if (-3 == ret)
|
||||||
|
{
|
||||||
|
return HGSANE_ERR_DEVICEOFFLINE;
|
||||||
|
}
|
||||||
|
|
||||||
return HGBASE_ERR_OK;
|
return HGBASE_ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,6 +145,15 @@ int show_setting_ui(const SANEAPI* saneApi, SANE_Handle handle, const char *devN
|
||||||
QCoreApplication::installTranslator(&translator2);
|
QCoreApplication::installTranslator(&translator2);
|
||||||
|
|
||||||
hg_settingdialog dlg(saneApi, handle, devName, qParent);
|
hg_settingdialog dlg(saneApi, handle, devName, qParent);
|
||||||
|
if (!dlg.IsValid())
|
||||||
|
{
|
||||||
|
QCoreApplication::removeTranslator(&translator);
|
||||||
|
if (20127 != cp)
|
||||||
|
QCoreApplication::removeTranslator(&translator2);
|
||||||
|
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
|
|
||||||
QCoreApplication::removeTranslator(&translator);
|
QCoreApplication::removeTranslator(&translator);
|
||||||
|
|
Binary file not shown.
|
@ -2946,7 +2946,7 @@ No: add new configuration</oldsource>
|
||||||
<location filename="hg_settingdialog.cpp" line="378"/>
|
<location filename="hg_settingdialog.cpp" line="378"/>
|
||||||
<location filename="hg_settingdialog.cpp" line="2358"/>
|
<location filename="hg_settingdialog.cpp" line="2358"/>
|
||||||
<source>The current parameter settings are inconsistent with the configuration scheme '%1'. To use the configuration scheme '%1' parameters, please click the restore button</source>
|
<source>The current parameter settings are inconsistent with the configuration scheme '%1'. To use the configuration scheme '%1' parameters, please click the restore button</source>
|
||||||
<translation>当前参数设置与配置方案 %1 不一致,如需使用配置方案 %1 参数,请点击恢复按钮</translation>
|
<translation>当前参数设置与配置方案 “%1” 不一致,如需使用配置方案 “%1” 参数,请点击恢复按钮</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="hg_settingdialog.cpp" line="383"/>
|
<location filename="hg_settingdialog.cpp" line="383"/>
|
||||||
|
|
|
@ -25,6 +25,7 @@ hg_settingdialog::hg_settingdialog(const SANEAPI* saneApi, SANE_Handle handle, c
|
||||||
, m_isRefreshUi(false)
|
, m_isRefreshUi(false)
|
||||||
, changed_count_(0)
|
, changed_count_(0)
|
||||||
, cur_cfg_(nullptr)
|
, cur_cfg_(nullptr)
|
||||||
|
, m_deviceIsValid(true)
|
||||||
{
|
{
|
||||||
m_dpiId = -1;
|
m_dpiId = -1;
|
||||||
m_dpiValue = 200;
|
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());
|
dev_que::update_old_cfg(old.toStdString().c_str());
|
||||||
|
|
||||||
int pid = 0;
|
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 };
|
char buf[10] = { 0 };
|
||||||
sprintf(buf, "%x", pid);
|
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()
|
void hg_settingdialog::initUi()
|
||||||
{
|
{
|
||||||
update_opt_value_from_driver();
|
update_opt_value_from_driver();
|
||||||
|
|
|
@ -54,6 +54,8 @@ public:
|
||||||
|
|
||||||
static void apply_scheme(SANE_Handle dev, LPSANEAPI api, gb::sane_config_schm* schm);
|
static void apply_scheme(SANE_Handle dev, LPSANEAPI api, gb::sane_config_schm* schm);
|
||||||
|
|
||||||
|
bool IsValid();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void initUi();
|
void initUi();
|
||||||
void update_opt_value_from_driver();
|
void update_opt_value_from_driver();
|
||||||
|
@ -157,6 +159,7 @@ private:
|
||||||
QComboBox *comb_;
|
QComboBox *comb_;
|
||||||
|
|
||||||
bool m_isRefreshUi;
|
bool m_isRefreshUi;
|
||||||
|
bool m_deviceIsValid;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // HG_SETTING_DIALOG_H
|
#endif // HG_SETTING_DIALOG_H
|
||||||
|
|
Loading…
Reference in New Issue