解决停止扫描后,提示是否继续的对话框有时显示不出来按钮的问题

This commit is contained in:
luoliangyi 2023-12-04 09:07:03 +08:00
parent 4ce0b0cba1
commit 801b302e58
4 changed files with 25 additions and 11 deletions

View File

@ -86,6 +86,11 @@ QString DeviceUser::GetName()
return QString(devName); return QString(devName);
} }
HGResult DeviceUser::Clear()
{
return HGTwain_DisableDS(m_twainDS);
}
HGResult DeviceUser::ShowSettingDlg() HGResult DeviceUser::ShowSettingDlg()
{ {
return HGTwain_EnableDSUIOnly(m_twainDS, (HWND)m_wnd->winId(), DSEventFunc, this); return HGTwain_EnableDSUIOnly(m_twainDS, (HWND)m_wnd->winId(), DSEventFunc, this);
@ -158,7 +163,6 @@ void HGAPI DeviceUser::DSEventFunc(HGTwainDS ds, HGUInt event, HGPointer param)
DeviceUser* p = (DeviceUser*)param; DeviceUser* p = (DeviceUser*)param;
if (HGTWAIN_EVENT_TYPE_SCANFINISHED == event) if (HGTWAIN_EVENT_TYPE_SCANFINISHED == event)
{ {
HGTwain_DisableDS(p->m_twainDS);
emit p->scanFinishEvent(); emit p->scanFinishEvent();
} }
else if (HGTWAIN_EVENT_TYPE_WORKING == event) else if (HGTWAIN_EVENT_TYPE_WORKING == event)
@ -167,8 +171,7 @@ void HGAPI DeviceUser::DSEventFunc(HGTwainDS ds, HGUInt event, HGPointer param)
} }
else if (HGTWAIN_EVENT_TYPE_CLOSEDSREQ == event) else if (HGTWAIN_EVENT_TYPE_CLOSEDSREQ == event)
{ {
HGTwain_DisableDS(p->m_twainDS); emit p->clearRes();
emit p->closeDSReq();
} }
} }
@ -291,6 +294,11 @@ QString DeviceUser::GetName()
return QString(devName); return QString(devName);
} }
HGResult DeviceUser::Clear()
{
return HGBASE_ERR_OK;
}
HGResult DeviceUser::ShowSettingDlg() HGResult DeviceUser::ShowSettingDlg()
{ {
return HGSane_ShowDeviceSettingDlg(m_saneDev, m_wnd); return HGSane_ShowDeviceSettingDlg(m_saneDev, m_wnd);

View File

@ -39,6 +39,7 @@ public:
HGResult Close(); HGResult Close();
// 获取设备名字 // 获取设备名字
QString GetName(); QString GetName();
HGResult Clear();
// 弹出配置对话框 // 弹出配置对话框
HGResult ShowSettingDlg(); HGResult ShowSettingDlg();
// 弹出扫描对话框 // 弹出扫描对话框
@ -61,7 +62,7 @@ signals:
void newImage(void *image); void newImage(void *image);
void scanFinishEvent(); void scanFinishEvent();
void scanWorkingEvent(); void scanWorkingEvent();
void closeDSReq(); void clearRes();
private: private:
QWidget *m_wnd; QWidget *m_wnd;
@ -104,6 +105,7 @@ public:
HGResult Close(); HGResult Close();
// 获取设备名字 // 获取设备名字
QString GetName(); QString GetName();
HGResult Clear();
// 弹出配置对话框 // 弹出配置对话框
HGResult ShowSettingDlg(); HGResult ShowSettingDlg();
// 弹出扫描对话框 // 弹出扫描对话框
@ -128,6 +130,7 @@ signals:
void abnormalImage(void *image, HGUInt *result); void abnormalImage(void *image, HGUInt *result);
void scanFinishEvent(); void scanFinishEvent();
void scanWorkingEvent(); void scanWorkingEvent();
void clearRes();
private: private:
QWidget *m_wnd; QWidget *m_wnd;

View File

@ -376,7 +376,7 @@ MainWindow::MainWindow(const QString& appLang, QWidget *parent)
connect(m_devUser, SIGNAL(abnormalImage(void*,HGUInt*)), this, SLOT(on_abnormalImage(void*,HGUInt*)), Qt::BlockingQueuedConnection); connect(m_devUser, SIGNAL(abnormalImage(void*,HGUInt*)), this, SLOT(on_abnormalImage(void*,HGUInt*)), Qt::BlockingQueuedConnection);
connect(m_devUser, SIGNAL(scanWorkingEvent()), this, SLOT(on_scanWorkingEvent()), Qt::QueuedConnection); connect(m_devUser, SIGNAL(scanWorkingEvent()), this, SLOT(on_scanWorkingEvent()), Qt::QueuedConnection);
connect(m_devUser, SIGNAL(scanFinishEvent()), this, SLOT(on_scanFinishEvent()), Qt::QueuedConnection); connect(m_devUser, SIGNAL(scanFinishEvent()), this, SLOT(on_scanFinishEvent()), Qt::QueuedConnection);
connect(m_devUser, SIGNAL(closeDSReq()), this, SLOT(on_closeDSReq()), Qt::QueuedConnection); connect(m_devUser, SIGNAL(clearRes()), this, SLOT(on_clearRes()), Qt::QueuedConnection);
#if !defined(HG_CMP_MSC) #if !defined(HG_CMP_MSC)
checkRollerLife(); checkRollerLife();
@ -434,7 +434,7 @@ MainWindow::~MainWindow()
disconnect(m_devUser, SIGNAL(abnormalImage(void*,HGUInt*)), this, SLOT(on_abnormalImage(void*,HGUInt*))); disconnect(m_devUser, SIGNAL(abnormalImage(void*,HGUInt*)), this, SLOT(on_abnormalImage(void*,HGUInt*)));
disconnect(m_devUser, SIGNAL(scanWorkingEvent()), this, SLOT(on_scanWorkingEvent())); disconnect(m_devUser, SIGNAL(scanWorkingEvent()), this, SLOT(on_scanWorkingEvent()));
disconnect(m_devUser, SIGNAL(scanFinishEvent()), this, SLOT(on_scanFinishEvent())); disconnect(m_devUser, SIGNAL(scanFinishEvent()), this, SLOT(on_scanFinishEvent()));
disconnect(m_devUser, SIGNAL(closeDSReq()), this, SLOT(on_closeDSReq())); disconnect(m_devUser, SIGNAL(clearRes()), this, SLOT(on_clearRes()));
delete m_devUser; delete m_devUser;
m_devUser = nullptr; m_devUser = nullptr;
} }
@ -1345,6 +1345,8 @@ void MainWindow::on_scanWorkingEvent()
void MainWindow::on_scanFinishEvent() void MainWindow::on_scanFinishEvent()
{ {
m_devUser->Clear();
HGBase_EnterLock(m_lockPreviewImage); HGBase_EnterLock(m_lockPreviewImage);
HGBase_DestroyImage(m_previewImage); HGBase_DestroyImage(m_previewImage);
m_previewImage = nullptr; m_previewImage = nullptr;
@ -1519,8 +1521,9 @@ void MainWindow::on_scanFinishEvent()
} }
} }
void MainWindow::on_closeDSReq() void MainWindow::on_clearRes()
{ {
m_devUser->Clear();
m_dsEnabled = false; m_dsEnabled = false;
} }
@ -4279,7 +4282,7 @@ void MainWindow::deleteDevUser()
disconnect(m_devUser, SIGNAL(abnormalImage(void*,HGUInt*)), this, SLOT(on_abnormalImage(void*,HGUInt*))); disconnect(m_devUser, SIGNAL(abnormalImage(void*,HGUInt*)), this, SLOT(on_abnormalImage(void*,HGUInt*)));
disconnect(m_devUser, SIGNAL(scanWorkingEvent()), this, SLOT(on_scanWorkingEvent())); disconnect(m_devUser, SIGNAL(scanWorkingEvent()), this, SLOT(on_scanWorkingEvent()));
disconnect(m_devUser, SIGNAL(scanFinishEvent()), this, SLOT(on_scanFinishEvent())); disconnect(m_devUser, SIGNAL(scanFinishEvent()), this, SLOT(on_scanFinishEvent()));
disconnect(m_devUser, SIGNAL(closeDSReq()), this, SLOT(on_closeDSReq())); disconnect(m_devUser, SIGNAL(clearRes()), this, SLOT(on_clearRes()));
m_devUser->Logout(); m_devUser->Logout();
delete m_devUser; delete m_devUser;
m_devUser = nullptr; m_devUser = nullptr;
@ -4543,7 +4546,7 @@ void MainWindow::on_act_selectDevice_triggered()
disconnect(m_devUser, SIGNAL(abnormalImage(void*,HGUInt*)), this, SLOT(on_abnormalImage(void*,HGUInt*))); disconnect(m_devUser, SIGNAL(abnormalImage(void*,HGUInt*)), this, SLOT(on_abnormalImage(void*,HGUInt*)));
disconnect(m_devUser, SIGNAL(scanWorkingEvent()), this, SLOT(on_scanWorkingEvent())); disconnect(m_devUser, SIGNAL(scanWorkingEvent()), this, SLOT(on_scanWorkingEvent()));
disconnect(m_devUser, SIGNAL(scanFinishEvent()), this, SLOT(on_scanFinishEvent())); disconnect(m_devUser, SIGNAL(scanFinishEvent()), this, SLOT(on_scanFinishEvent()));
disconnect(m_devUser, SIGNAL(closeDSReq()), this, SLOT(on_closeDSReq())); disconnect(m_devUser, SIGNAL(clearRes()), this, SLOT(on_clearRes()));
m_devUser->Logout(); m_devUser->Logout();
delete m_devUser; delete m_devUser;
m_devUser = nullptr; m_devUser = nullptr;
@ -4566,7 +4569,7 @@ void MainWindow::on_act_selectDevice_triggered()
connect(m_devUser, SIGNAL(abnormalImage(void*,HGUInt*)), this, SLOT(on_abnormalImage(void*,HGUInt*)), Qt::BlockingQueuedConnection); connect(m_devUser, SIGNAL(abnormalImage(void*,HGUInt*)), this, SLOT(on_abnormalImage(void*,HGUInt*)), Qt::BlockingQueuedConnection);
connect(m_devUser, SIGNAL(scanWorkingEvent()), this, SLOT(on_scanWorkingEvent()), Qt::QueuedConnection); connect(m_devUser, SIGNAL(scanWorkingEvent()), this, SLOT(on_scanWorkingEvent()), Qt::QueuedConnection);
connect(m_devUser, SIGNAL(scanFinishEvent()), this, SLOT(on_scanFinishEvent()), Qt::QueuedConnection); connect(m_devUser, SIGNAL(scanFinishEvent()), this, SLOT(on_scanFinishEvent()), Qt::QueuedConnection);
connect(m_devUser, SIGNAL(closeDSReq()), this, SLOT(on_closeDSReq()), Qt::QueuedConnection); connect(m_devUser, SIGNAL(clearRes()), this, SLOT(on_clearRes()), Qt::QueuedConnection);
#if !defined(HG_CMP_MSC) #if !defined(HG_CMP_MSC)
checkRollerLife(); checkRollerLife();
#endif #endif

View File

@ -146,7 +146,7 @@ private slots:
void on_abnormalImage(void *image, HGUInt *result); void on_abnormalImage(void *image, HGUInt *result);
void on_scanFinishEvent(); void on_scanFinishEvent();
void on_scanWorkingEvent(); void on_scanWorkingEvent();
void on_closeDSReq(); void on_clearRes();
void on_m_pbtn_push_clicked(); void on_m_pbtn_push_clicked();
void on_dialog_sideBar_applyToImage(HGImage img, int brightness, int contrast, double gamma, bool enhanceText); void on_dialog_sideBar_applyToImage(HGImage img, int brightness, int contrast, double gamma, bool enhanceText);
void on_dialog_sideBar_finish(bool ok); void on_dialog_sideBar_finish(bool ok);