code_production/app/HGProductionTool/form_maininterface.cpp

96 lines
2.6 KiB
C++

#include "form_maininterface.h"
#include "ui_form_maininterface.h"
#include <QPainter>
#include "imgfmt/HGImgFmt.h"
#include "HGUIGlobal.h"
#include "form_texttips.h"
#include "test_base.h"
Form_mainInterface::Form_mainInterface(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Form_mainInterface)
{
ui->setupUi(this);
m_textTips = new Form_textTips();
m_view = new HGImgView();
ui->stackedWidget->addWidget(m_textTips);
ui->stackedWidget->addWidget(m_view);
QString path("../../doc/config.json");
AnalysisJson analysisJson(path);
std::vector<AnalysisJson::json_node> list_jsonNode = analysisJson.GetNode();
for(int i = 0; i < list_jsonNode.size(); ++i)
{
AnalysisJson::json_node node = list_jsonNode[i];
ui->listWidget->addItem(node.title);
}
this->setMinimumWidth(400);
ui->listWidget->setMinimumWidth(200);
ui->listWidget->setCurrentRow(0);
ui->pbtn_preStep->setEnabled(false);
}
Form_mainInterface::~Form_mainInterface()
{
delete ui;
}
void Form_mainInterface::paintEvent(QPaintEvent *event)
{
(void)event;
QPainter p(this);
p.setPen(QColor("gray"));
p.drawRect(0, 0, width() -1, height() -1);
}
void Form_mainInterface::on_listWidget_currentRowChanged(int currentRow)
{
(void)currentRow;
ui->pbtn_preStep->setEnabled(ui->listWidget->currentRow() != 0);
ui->pbtn_nextStep->setEnabled(ui->listWidget->currentRow() != ui->listWidget->count() - 1);
QString curItemContent = ui->listWidget->currentItem()->text();
if (curItemContent == HGPDTTOOLDB_TITLE_DIAL_SWITCH)
{
m_textTips->setViewContent(tr("HGPDTTOOLDB_TITLE_DIAL_SWITCH"));
ui->stackedWidget->setCurrentWidget(m_textTips);
}
else if (curItemContent == HGPDTTOOLDB_TITLE_CIS_ORIGINAL_IMAGE)
{
m_textTips->setViewContent(tr("HGPDTTOOLDB_TITLE_CIS_ORIGINAL_IMAGE"));
ui->stackedWidget->setCurrentWidget(m_textTips);
}
else if (curItemContent == HGPDTTOOLDB_TITLE_IMAGE_QUALITY)
{
//addImg
ui->stackedWidget->setCurrentWidget(m_view);
}
}
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()
{
ui->listWidget->item(ui->listWidget->currentRow())->setBackgroundColor("yellow");
on_pbtn_nextStep_clicked();
}