scantool改为静态编译,解决扫描指示器界面刷新异常;非7010设备不再添加到界面

This commit is contained in:
yangjiaxuan 2024-05-29 14:31:13 +08:00
parent c7bda6e9ff
commit 1e329882af
3 changed files with 13 additions and 16 deletions

View File

@ -112,7 +112,7 @@ MainWindow::MainWindow(QWidget *parent)
connect(this, SIGNAL(scanInfo(QString, bool)), this, SLOT(on_scanInfo(QString, bool))); connect(this, SIGNAL(scanInfo(QString, bool)), this, SLOT(on_scanInfo(QString, bool)));
connect(this, SIGNAL(scanImage(unsigned int)), this, SLOT(on_scanImage(unsigned int))); connect(this, SIGNAL(scanImage(unsigned int)), this, SLOT(on_scanImage(unsigned int)));
connect(this, SIGNAL(scanFinish()), this, SLOT(on_scanFinish())); connect(this, SIGNAL(scanFinish()), this, SLOT(on_scanFinish()));
connect(this, SIGNAL(saneEventCloseDevice(void*)), this, SLOT(on_saneEventCloseDevice(void*))); connect(this, SIGNAL(saneEventCloseDevice(void*, bool)), this, SLOT(on_saneEventCloseDevice(void*, bool)));
SANE_Int version_code = 0; SANE_Int version_code = 0;
sane_init_ex(&version_code, sane_ex_callback, this); sane_init_ex(&version_code, sane_ex_callback, this);
@ -1125,7 +1125,8 @@ int MainWindow::sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigne
break; break;
case SANE_EVENT_SCANNER_CLOSED: case SANE_EVENT_SCANNER_CLOSED:
{ {
emit p->saneEventCloseDevice((void*)hdev); bool isOnline = *(bool*)data;
emit p->saneEventCloseDevice((void*)hdev, isOnline);
} }
break; break;
case SANE_EVENT_IMAGE_OK: case SANE_EVENT_IMAGE_OK:
@ -1260,16 +1261,12 @@ void MainWindow::timerEvent(QTimerEvent *e)
this->killTimer(m_timerId); this->killTimer(m_timerId);
m_timerId = -1; m_timerId = -1;
} }
else if (SCANNER_ERR_DEVICE_NOT_SUPPORT == status)
{
this->killTimer(m_timerId);
m_timerId = -1;
}
} }
} }
void MainWindow::on_deviceArrive(QString devName) void MainWindow::on_deviceArrive(QString devName)
{ {
if (devName.contains("306") || devName.contains("307"))
ui->comboBox->addItem(devName); ui->comboBox->addItem(devName);
} }
@ -1387,10 +1384,6 @@ void MainWindow::on_comboBox_currentIndexChanged(const QString &arg1)
ui->pushButtonAdd->setEnabled(true); ui->pushButtonAdd->setEnabled(true);
ui->pushButtonModify->setEnabled(true); ui->pushButtonModify->setEnabled(true);
} }
else if (SCANNER_ERR_DEVICE_NOT_SUPPORT == status)
{
QMessageBox::information(this, tr("Tips"), tr("Do not supported to open %1").arg(arg1));
}
else else
{ {
m_timerId = this->startTimer(5000); m_timerId = this->startTimer(5000);
@ -1424,7 +1417,7 @@ void MainWindow::on_showMainWindowDlg()
Show(); Show();
} }
void MainWindow::on_saneEventCloseDevice(void* devHandle) void MainWindow::on_saneEventCloseDevice(void* devHandle, bool isOnline)
{ {
assert(nullptr != m_devHandle || nullptr != devHandle); assert(nullptr != m_devHandle || nullptr != devHandle);
if (devHandle != m_devHandle) if (devHandle != m_devHandle)
@ -1446,6 +1439,7 @@ void MainWindow::on_saneEventCloseDevice(void* devHandle)
m_timerId = -1; m_timerId = -1;
} }
if (isOnline)
m_timerId = this->startTimer(5000); m_timerId = this->startTimer(5000);
} }

View File

@ -60,7 +60,7 @@ signals:
void scanImage(unsigned int count); void scanImage(unsigned int count);
void scanFinish(); void scanFinish();
void closeDevice(); void closeDevice();
void saneEventCloseDevice(void* devHandle); void saneEventCloseDevice(void* devHandle, bool isOnline);
private slots: private slots:
void on_deviceArrive(QString devName); void on_deviceArrive(QString devName);
@ -74,7 +74,7 @@ private slots:
void on_pushButtonScan_clicked(); void on_pushButtonScan_clicked();
void on_trayActivated(QSystemTrayIcon::ActivationReason reason); void on_trayActivated(QSystemTrayIcon::ActivationReason reason);
void on_showMainWindowDlg(); void on_showMainWindowDlg();
void on_saneEventCloseDevice(void* devHandle); void on_saneEventCloseDevice(void* devHandle, bool isOnline);
void on_pushButtonAdd_clicked(); void on_pushButtonAdd_clicked();
void on_pushButtonModify_clicked(); void on_pushButtonModify_clicked();
void on_pushButtonRemove_clicked(); void on_pushButtonRemove_clicked();

View File

@ -247,6 +247,9 @@ if "%OEM%" == "hw" (
cd /d HGTwainUI cd /d HGTwainUI
%QT_STATIC_PATH%/x86-windows-static-md/tools/qt5/bin/qmake -r -tp vc HGTwainUI.pro %QT_STATIC_PATH%/x86-windows-static-md/tools/qt5/bin/qmake -r -tp vc HGTwainUI.pro
MSBuild.exe HGTwainUI.vcxproj -t:rebuild /m:8 /p:Configuration=Release MSBuild.exe HGTwainUI.vcxproj -t:rebuild /m:8 /p:Configuration=Release
cd /d ../HGScanTool
%QT_STATIC_PATH%/x86-windows-static-md/tools/qt5/bin/qmake -r -tp vc HGScanTool.pro
MSBuild.exe HGScanTool.vcxproj -t:rebuild /m:8 /p:Configuration=Release
cd /d ../ cd /d ../
) )
) )