添加测试状态引用计数,上报校正信息

This commit is contained in:
yangjiaxuan 2022-12-30 18:30:02 +08:00
parent 9cd6ee5d15
commit fe69f6a5b0
7 changed files with 66 additions and 59 deletions

View File

@ -81,8 +81,8 @@ Form_mainInterface::Form_mainInterface(class MainWindow *mainwnd, SANE_Handle ha
connect(this, SIGNAL(testResult(QString)), this, SLOT(on_testResult(QString)), Qt::QueuedConnection); connect(this, SIGNAL(testResult(QString)), this, SLOT(on_testResult(QString)), Qt::QueuedConnection);
connect(this, SIGNAL(testResultImg(void*)), this, SLOT(on_testResultImg(void*)), Qt::QueuedConnection); connect(this, SIGNAL(testResultImg(void*)), this, SLOT(on_testResultImg(void*)), Qt::QueuedConnection);
connect(this, SIGNAL(testDistortion(QString,void*)), this, SLOT(on_testDistortion(QString,void*)), Qt::QueuedConnection);
connect(this, SIGNAL(testCorrectInfo(QString)), this, SLOT(on_testCorrectInfo(QString)), Qt::QueuedConnection); connect(this, SIGNAL(testCorrectInfo(QString)), this, SLOT(on_testCorrectInfo(QString)), Qt::QueuedConnection);
connect(this, SIGNAL(testFinish()), this, SLOT(on_testFinish()), Qt::QueuedConnection);
QString str; QString str;
if (m_handle) if (m_handle)
@ -160,7 +160,12 @@ void Form_mainInterface::paintEvent(QPaintEvent *event)
void Form_mainInterface::on_testResult(QString text) void Form_mainInterface::on_testResult(QString text)
{ {
if (!text.isEmpty())
QMessageBox::information(this, tr("tips"), text); QMessageBox::information(this, tr("tips"), text);
updateUiEnabled(true);
m_isTesting = false;
m_mainwnd->releaseTesting();
} }
void Form_mainInterface::on_testResultImg(void *img) void Form_mainInterface::on_testResultImg(void *img)
@ -185,12 +190,12 @@ void Form_mainInterface::on_testDistortion(QString name, void *data)
{ {
func_test_go(HGPDTTOOLDB_NAME_SINGLE_PAGE_TEST_1, L"null", m_hg); func_test_go(HGPDTTOOLDB_NAME_SINGLE_PAGE_TEST_1, L"null", m_hg);
} }
} else
void Form_mainInterface::on_testFinish()
{ {
updateUiEnabled(true); updateUiEnabled(true);
m_isTesting = false; m_isTesting = false;
m_mainwnd->releaseTesting();
}
} }
void Form_mainInterface::on_testCorrectInfo(QString info) void Form_mainInterface::on_testCorrectInfo(QString info)
@ -541,17 +546,11 @@ void Form_mainInterface::on_pbtn_start_clicked()
QTableWidgetItem *item = ui->tableWidget->item(row, 1); QTableWidgetItem *item = ui->tableWidget->item(row, 1);
QString title = item->text(); QString title = item->text();
QString name = m_map_title_name.value(title).name; QString name = m_map_title_name.value(title).name;
int ret = func_test_go(name.toStdWString().c_str(), L"null", m_hg); func_test_go(name.toStdWString().c_str(), L"null", m_hg);
if (SCANNER_ERR_OK == ret)
{
updateUiEnabled(false); updateUiEnabled(false);
m_isTesting = true; m_isTesting = true;
} m_mainwnd->addTestingRef();
else
{
updateUiEnabled(true);
m_isTesting = false;
}
} }
void Form_mainInterface::on_pbtn_showImg_clicked() void Form_mainInterface::on_pbtn_showImg_clicked()
@ -568,7 +567,7 @@ void Form_mainInterface::on_pbtn_showImg_clicked()
ui->pbtn_leftRotate->setVisible(true); ui->pbtn_leftRotate->setVisible(true);
ui->pbtn_rightRotate->setVisible(true); ui->pbtn_rightRotate->setVisible(true);
ui->stackedWidget->setCurrentWidget(m_view); ui->stackedWidget->setCurrentWidget(m_view);
HGImage img; HGImage img = nullptr;
HGImgFmt_LoadImage(fileName.toStdString().c_str(), 0, 0, 0, 0, &img); HGImgFmt_LoadImage(fileName.toStdString().c_str(), 0, 0, 0, 0, &img);
m_view->addImage(img); m_view->addImage(img);
QFile file(fileName); QFile file(fileName);

View File

@ -38,13 +38,11 @@ signals:
void testResultImg(void* img); void testResultImg(void* img);
void testDistortion(QString title, void *data); void testDistortion(QString title, void *data);
void testCorrectInfo(QString info); void testCorrectInfo(QString info);
void testFinish();
private slots: private slots:
void on_testResult(QString text); void on_testResult(QString text);
void on_testResultImg(void* img); void on_testResultImg(void* img);
void on_testDistortion(QString title, void *data); void on_testDistortion(QString title, void *data);
void on_testFinish();
void on_testCorrectInfo(QString info); void on_testCorrectInfo(QString info);
private slots: private slots:

View File

@ -25,6 +25,7 @@ void Form_textTips::setViewContent(QString content)
void Form_textTips::addContent(QString content) void Form_textTips::addContent(QString content)
{ {
ui->textBrowser->insertPlainText(content); ui->textBrowser->insertPlainText(content);
ui->textBrowser->moveCursor(QTextCursor::End);
} }

View File

@ -39,37 +39,36 @@ void hgscanner::test_callback(const wchar_t* name, test_event ev, void* data, si
{ {
QString info = QObject::tr("Not find test item"); QString info = QObject::tr("Not find test item");
emit m_interface->testResult(info); emit m_interface->testResult(info);
emit m_interface->testFinish();
} }
else if (ev == TEST_EVENT_IO_FAIL) else if (ev == TEST_EVENT_IO_FAIL)
{ {
QString info;
if (data != nullptr) if (data != nullptr)
{ {
QString info = QString::fromStdWString((const wchar_t*)data); info = QObject::tr("failed: ") + QString::fromStdWString((const wchar_t*)data);
info = QObject::tr("failed: ") + info;
emit m_interface->testResult(info);
} }
emit m_interface->testFinish(); emit m_interface->testResult(info);
} }
else if (ev == TEST_EVENT_MANUAL_CONFIRMATION) else if (ev == TEST_EVENT_MANUAL_CONFIRMATION)
{ {
QString info = QString::fromStdWString((const wchar_t*)data); QString info;
if (data != nullptr)
{
info = QString::fromStdWString((const wchar_t*)data);
}
emit m_interface->testResult(info); emit m_interface->testResult(info);
emit m_interface->testFinish();
} }
else if (ev == TEST_EVENT_RESULT) else if (ev == TEST_EVENT_RESULT)
{ {
QString info;
if (data != nullptr) if (data != nullptr)
{ {
QString info = QString::fromStdWString((const wchar_t*)data);
if (flag) if (flag)
info = QObject::tr("success: ") + info; info = QObject::tr("success: ") + QString::fromStdWString((const wchar_t*)data);
else else
info = QObject::tr("failed: ") + info; info = QObject::tr("failed: ") + QString::fromStdWString((const wchar_t*)data);
emit m_interface->testResult(info);
} }
emit m_interface->testFinish(); emit m_interface->testResult(info);
} }
else if (ev == TEST_EVENT_DISTORTION) else if (ev == TEST_EVENT_DISTORTION)
{ {
@ -78,9 +77,10 @@ void hgscanner::test_callback(const wchar_t* name, test_event ev, void* data, si
} }
else if (ev == TEST_EVENT_FALT_INFO) else if (ev == TEST_EVENT_FALT_INFO)
{ {
QString info;
if (data != nullptr) if (data != nullptr)
{ {
QString info = QString::fromStdWString((const wchar_t*)data); info = QString::fromStdWString((const wchar_t*)data);
emit m_interface->testCorrectInfo(info); emit m_interface->testCorrectInfo(info);
} }
} }

View File

@ -17,6 +17,7 @@ MainWindow::MainWindow(HGPdtToolDbUserMgr pdtToolDbuserMgr, const QString &ftpHo
, m_ftpHost(ftpHost) , m_ftpHost(ftpHost)
, m_ftpPort(ftpPort) , m_ftpPort(ftpPort)
, m_lock(nullptr) , m_lock(nullptr)
, m_testingRef(0)
, m_top_splitter(nullptr) , m_top_splitter(nullptr)
, m_bot_splitter(nullptr) , m_bot_splitter(nullptr)
, m_isLogOut(false) , m_isLogOut(false)
@ -232,31 +233,36 @@ bool MainWindow::RemoveInterface(Form_mainInterface *interface)
return true; return true;
} }
void MainWindow::addTestingRef()
{
++m_testingRef;
ui->act_close->setEnabled(false);
ui->act_manage->setEnabled(false);
ui->act_logOut->setEnabled(false);
ui->act_changePwd->setEnabled(false);
ui->act_export->setEnabled(false);
ui->act_upload->setEnabled(false);
}
void MainWindow::releaseTesting()
{
--m_testingRef;
if (0 == m_testingRef)
{
ui->act_close->setEnabled(true);
ui->act_manage->setEnabled(true);
ui->act_logOut->setEnabled(true);
ui->act_changePwd->setEnabled(true);
ui->act_export->setEnabled(true);
ui->act_upload->setEnabled(true);
}
}
bool MainWindow::isTesting() bool MainWindow::isTesting()
{ {
bool isTesting = false; return (m_testingRef != 0);
for (int i = 0; i < m_top_splitter->count(); ++i)
{
Form_mainInterface *interface = (Form_mainInterface *)m_top_splitter->widget(i);
if (interface->isTesting())
{
isTesting = true;
break;
}
}
if (!isTesting)
{
for (int i = 0; i < m_bot_splitter->count(); ++i)
{
Form_mainInterface *interface = (Form_mainInterface *)m_bot_splitter->widget(i);
if (interface->isTesting())
{
isTesting = true;
break;
}
}
}
return isTesting;
} }
void MainWindow::closeEvent(QCloseEvent *event) void MainWindow::closeEvent(QCloseEvent *event)

View File

@ -30,6 +30,8 @@ public:
Form_mainInterface* FindInterface(SANE_Handle handle); Form_mainInterface* FindInterface(SANE_Handle handle);
bool AddInterface(Form_mainInterface *interface); bool AddInterface(Form_mainInterface *interface);
bool RemoveInterface(Form_mainInterface *interface); bool RemoveInterface(Form_mainInterface *interface);
void addTestingRef();
void releaseTesting();
bool isTesting(); bool isTesting();
protected: protected:
@ -76,6 +78,7 @@ private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
HGPdtToolDbUserMgr m_pdtToolDbuserMgr; HGPdtToolDbUserMgr m_pdtToolDbuserMgr;
HGLock m_lock; HGLock m_lock;
int m_testingRef;
public: public:
QString m_ftpHost; QString m_ftpHost;