2022-12-14 06:39:22 +00:00
|
|
|
#include "form_maininterface.h"
|
|
|
|
#include "ui_form_maininterface.h"
|
|
|
|
#include <QPainter>
|
2022-12-16 11:01:30 +00:00
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QInputDialog>
|
|
|
|
#include "base/HGBase.h"
|
2022-12-14 06:39:22 +00:00
|
|
|
#include "imgfmt/HGImgFmt.h"
|
|
|
|
#include "HGUIGlobal.h"
|
|
|
|
#include "form_texttips.h"
|
2022-12-14 12:28:25 +00:00
|
|
|
#include "test_base.h"
|
2022-12-16 11:01:30 +00:00
|
|
|
#include "hgscanner.h"
|
|
|
|
#include "mainwindow.h"
|
2022-12-14 06:39:22 +00:00
|
|
|
|
2022-12-17 05:48:03 +00:00
|
|
|
Form_mainInterface::Form_mainInterface(class MainWindow *mainwnd, SANE_Handle handle, HGPdtToolDbUserMgr pdtToolDbuserMgr, HGPdtToolDbDevice pdtToolDbDevice,
|
2022-12-16 11:01:30 +00:00
|
|
|
const QString &serialNum, const QString &devType)
|
|
|
|
: QWidget(mainwnd)
|
2022-12-14 06:39:22 +00:00
|
|
|
, ui(new Ui::Form_mainInterface)
|
2022-12-16 11:01:30 +00:00
|
|
|
, m_mainwnd(mainwnd)
|
|
|
|
, m_handle(handle)
|
2022-12-17 05:48:03 +00:00
|
|
|
, m_pdtToolDbuserMgr(pdtToolDbuserMgr)
|
2022-12-16 11:01:30 +00:00
|
|
|
, m_pdtToolDbDevice(pdtToolDbDevice)
|
|
|
|
, m_serialNum(serialNum)
|
|
|
|
, m_devType(devType)
|
2022-12-14 06:39:22 +00:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
2022-12-22 02:48:06 +00:00
|
|
|
ui->label_sn->setText(tr("Device type:") + m_devType + tr(" SerialNum:") + m_serialNum);
|
2022-12-16 11:01:30 +00:00
|
|
|
this->setMinimumWidth(400);
|
2022-12-14 12:28:25 +00:00
|
|
|
m_textTips = new Form_textTips();
|
|
|
|
m_view = new HGImgView();
|
|
|
|
ui->stackedWidget->addWidget(m_textTips);
|
|
|
|
ui->stackedWidget->addWidget(m_view);
|
|
|
|
|
2022-12-14 06:39:22 +00:00
|
|
|
ui->listWidget->setMinimumWidth(200);
|
|
|
|
ui->listWidget->setCurrentRow(0);
|
|
|
|
ui->pbtn_preStep->setEnabled(false);
|
2022-12-16 11:01:30 +00:00
|
|
|
|
2022-12-17 05:48:03 +00:00
|
|
|
downloadCfgFile();
|
2022-12-14 06:39:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Form_mainInterface::~Form_mainInterface()
|
|
|
|
{
|
2022-12-16 11:01:30 +00:00
|
|
|
//sane_close(m_handle);
|
|
|
|
HGPdtToolDb_CloseDevice(m_pdtToolDbDevice);
|
|
|
|
|
2022-12-14 06:39:22 +00:00
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2022-12-16 11:01:30 +00:00
|
|
|
QString Form_mainInterface::getSn()
|
|
|
|
{
|
|
|
|
return m_serialNum;
|
|
|
|
}
|
|
|
|
|
2022-12-14 06:39:22 +00:00
|
|
|
void Form_mainInterface::paintEvent(QPaintEvent *event)
|
|
|
|
{
|
|
|
|
(void)event;
|
|
|
|
QPainter p(this);
|
|
|
|
p.setPen(QColor("gray"));
|
|
|
|
p.drawRect(0, 0, width() -1, height() -1);
|
|
|
|
}
|
|
|
|
|
2022-12-16 11:01:30 +00:00
|
|
|
void Form_mainInterface::on_listWidget_currentTextChanged(const QString ¤tText)
|
2022-12-14 06:39:22 +00:00
|
|
|
{
|
|
|
|
ui->pbtn_preStep->setEnabled(ui->listWidget->currentRow() != 0);
|
|
|
|
ui->pbtn_nextStep->setEnabled(ui->listWidget->currentRow() != ui->listWidget->count() - 1);
|
|
|
|
|
2022-12-16 11:01:30 +00:00
|
|
|
QString testName;
|
|
|
|
if (currentText == HGPDTTOOLDB_TITLE_DIAL_SWITCH)
|
2022-12-14 06:39:22 +00:00
|
|
|
{
|
2022-12-16 11:01:30 +00:00
|
|
|
m_textTips->setViewContent(m_map_title_name.value(currentText).desc);
|
|
|
|
testName = m_map_title_name.value(currentText).name;
|
2022-12-14 12:28:25 +00:00
|
|
|
ui->stackedWidget->setCurrentWidget(m_textTips);
|
2022-12-14 06:39:22 +00:00
|
|
|
}
|
2022-12-16 11:01:30 +00:00
|
|
|
else if (currentText == HGPDTTOOLDB_NAME_SINGLE_PAGE_TEST_1)
|
2022-12-14 12:28:25 +00:00
|
|
|
{
|
|
|
|
//addImg
|
2022-12-16 11:01:30 +00:00
|
|
|
testName = m_map_title_name.value(currentText).name;
|
2022-12-14 06:39:22 +00:00
|
|
|
ui->stackedWidget->setCurrentWidget(m_view);
|
|
|
|
}
|
2022-12-16 11:01:30 +00:00
|
|
|
|
|
|
|
ui_helper* helper;
|
|
|
|
hgscanner* hg = new hgscanner(m_handle);
|
|
|
|
helper = dynamic_cast<hgscanner*>(hg);
|
|
|
|
|
|
|
|
QString s("test-31");
|
|
|
|
// func_test_go(s.toStdWString().c_str(), L"null", helper);
|
2022-12-14 06:39:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Form_mainInterface::on_pbtn_preStep_clicked()
|
|
|
|
{
|
|
|
|
ui->listWidget->setCurrentRow(ui->listWidget->currentRow() - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Form_mainInterface::on_pbtn_nextStep_clicked()
|
|
|
|
{
|
|
|
|
ui->listWidget->setCurrentRow(ui->listWidget->currentRow() + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Form_mainInterface::on_pbtn_fail_clicked()
|
|
|
|
{
|
|
|
|
ui->listWidget->item(ui->listWidget->currentRow())->setBackgroundColor("red");
|
|
|
|
}
|
|
|
|
|
|
|
|
void Form_mainInterface::on_pbtn_pass_clicked()
|
|
|
|
{
|
2022-12-14 12:28:25 +00:00
|
|
|
ui->listWidget->item(ui->listWidget->currentRow())->setBackgroundColor("yellow");
|
|
|
|
on_pbtn_nextStep_clicked();
|
2022-12-14 06:39:22 +00:00
|
|
|
}
|
|
|
|
|
2022-12-17 05:48:03 +00:00
|
|
|
void Form_mainInterface::downloadCfgFile()
|
2022-12-16 11:01:30 +00:00
|
|
|
{
|
2022-12-17 05:48:03 +00:00
|
|
|
HGChar cfgPath[512] = {0};
|
|
|
|
HGBase_GetConfigPath(cfgPath, 512);
|
|
|
|
HGBase_CreateDir(cfgPath);
|
|
|
|
strcat(cfgPath, m_devType.toStdString().c_str());
|
|
|
|
strcat(cfgPath, ".json");
|
|
|
|
|
|
|
|
HGResult ret = HGPdtToolDb_DownloadFile(m_pdtToolDbuserMgr, m_devType.toStdString().c_str(), cfgPath);
|
2022-12-22 02:48:06 +00:00
|
|
|
if(ret == HGBASE_ERR_OK)
|
|
|
|
{
|
2022-12-17 05:48:03 +00:00
|
|
|
AnalysisJson analysisJson(QString::fromStdString(cfgPath));
|
|
|
|
|
|
|
|
std::vector<AnalysisJson::json_node> list_jsonNode = analysisJson.GetNode();
|
|
|
|
for(int i = 0; i < (int)list_jsonNode.size(); ++i)
|
|
|
|
{
|
|
|
|
AnalysisJson::json_node node = list_jsonNode[i];
|
|
|
|
ui->listWidget->addItem(node.title);
|
|
|
|
m_map_title_name.insert(node.title, node);
|
|
|
|
}
|
2022-12-22 02:48:06 +00:00
|
|
|
}
|
2022-12-16 11:01:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Form_mainInterface::on_pbtn_stop_clicked()
|
|
|
|
{
|
|
|
|
m_mainwnd->RemoveInterface(this);
|
|
|
|
}
|
2022-12-17 05:48:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|