code_production/app/HGProductionTool/form_maininterface.cpp

96 lines
2.6 KiB
C++
Raw Normal View History

2022-12-14 06:39:22 +00:00
#include "form_maininterface.h"
#include "ui_form_maininterface.h"
#include <QPainter>
#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-14 06:39:22 +00:00
Form_mainInterface::Form_mainInterface(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Form_mainInterface)
{
ui->setupUi(this);
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-15 09:27:35 +00:00
QString path("../../doc/config.json");
2022-12-14 06:39:22 +00:00
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)
{
2022-12-14 12:28:25 +00:00
(void)currentRow;
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-14 12:28:25 +00:00
QString curItemContent = ui->listWidget->currentItem()->text();
if (curItemContent == HGPDTTOOLDB_TITLE_DIAL_SWITCH)
2022-12-14 06:39:22 +00:00
{
2022-12-14 12:28:25 +00:00
m_textTips->setViewContent(tr("HGPDTTOOLDB_TITLE_DIAL_SWITCH"));
ui->stackedWidget->setCurrentWidget(m_textTips);
2022-12-14 06:39:22 +00:00
}
2022-12-14 12:28:25 +00:00
else if (curItemContent == HGPDTTOOLDB_TITLE_CIS_ORIGINAL_IMAGE)
2022-12-14 06:39:22 +00:00
{
2022-12-14 12:28:25 +00:00
m_textTips->setViewContent(tr("HGPDTTOOLDB_TITLE_CIS_ORIGINAL_IMAGE"));
ui->stackedWidget->setCurrentWidget(m_textTips);
}
else if (curItemContent == HGPDTTOOLDB_TITLE_IMAGE_QUALITY)
{
//addImg
2022-12-14 06:39:22 +00:00
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()
{
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
}