qt/ledset/expertsmartpointsetwin.cpp

556 lines
18 KiB
C++
Raw Normal View History

2022-08-25 18:43:03 +08:00
#include "expertsmartpointsetwin.h"
2022-09-08 23:22:59 +08:00
#include "gqt.h"
2022-08-25 18:43:03 +08:00
#include <QStackedLayout>
#include <QLabel>
#include <QRadioButton>
#include <QPushButton>
#include <QButtonGroup>
2022-08-25 22:52:52 +08:00
#include <QHeaderView>
2022-09-08 23:22:59 +08:00
#include <QMessageBox>
#include <QLineEdit>
#include <QApplication>
#include <QFileDialog>
2022-09-09 23:25:49 +08:00
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonDocument>
2022-09-08 23:22:59 +08:00
2022-12-16 15:08:53 +08:00
ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{expertWin}, expertWin(expertWin) {
2022-08-25 18:43:03 +08:00
setWindowModality(Qt::WindowModal);
setAttribute(Qt::WA_DeleteOnClose);
2022-12-16 15:08:53 +08:00
setWindowTitle(tr("智能走点参数配置"));
2022-08-25 18:43:03 +08:00
resize(900, 600);
2022-12-16 15:08:53 +08:00
ModuleWidth = expertWin->mModule["ModuleWidth"].toInt();
ModuleHeight = expertWin->mModule["ModuleHeight"].toInt();
GroupNum = expertWin->mModule["GroupNum"].toInt();
ScanNum = expertWin->mModule["ScanNum"].toInt();
ChipType = expertWin->mModule["ChipType"].toString();
DecodeMode = expertWin->mModule["DecodeMode"].toString();
GroupMode = expertWin->mModule["GroupMode"].toString();
2022-08-25 18:43:03 +08:00
auto vBox = new QVBoxLayout(center);
vBox->setContentsMargins(0,0,0,0);
vBox->setSpacing(3);
vBox->addLayout(addBtns(new QHBoxLayout()));
auto stack = new QStackedLayout;
vBox->addLayout(stack);
auto page = new QWidget;
stack->addWidget(page);
2022-08-25 22:52:52 +08:00
QPalette bkBlue;
{
auto vBox = new QVBoxLayout(page);
vBox->setContentsMargins(50, 50, 6, 6);
2022-12-16 15:08:53 +08:00
auto lb = new QLabel(tr("基本参数"));
2022-08-25 22:52:52 +08:00
bkBlue = lb->palette();
bkBlue.setColor(QPalette::WindowText, QColor(0x5599ff));
lb->setPalette(bkBlue);
vBox->addWidget(lb);
vBox->addSpacing(50);
auto hBox = new QHBoxLayout;
hBox->addStretch();
{
auto vvv = new QVBoxLayout;
auto hhhh = new QHBoxLayout;
2022-12-16 15:08:53 +08:00
lb = new QLabel(tr("模组宽度: "));
2022-08-25 22:52:52 +08:00
hhhh->addWidget(lb);
fdModuleWidth = new QSpinBox;
fdModuleWidth->setRange(0, 9999);
2022-09-09 23:25:49 +08:00
fdModuleWidth->setValue(ModuleWidth);
2022-08-25 22:52:52 +08:00
hhhh->addWidget(fdModuleWidth);
vvv->addLayout(hhhh);
vvv->addSpacing(30);
hhhh = new QHBoxLayout;
2022-12-16 15:08:53 +08:00
lb = new QLabel(tr("模组高度: "));
2022-08-25 22:52:52 +08:00
hhhh->addWidget(lb);
fdModuleHeight = new QSpinBox;
fdModuleHeight->setRange(0, 9999);
2022-09-09 23:25:49 +08:00
fdModuleHeight->setValue(ModuleHeight);
2022-08-25 22:52:52 +08:00
hhhh->addWidget(fdModuleHeight);
vvv->addLayout(hhhh);
vvv->addSpacing(30);
hhhh = new QHBoxLayout;
2022-12-16 15:08:53 +08:00
lb = new QLabel(tr("数据组数: "));
2022-08-25 22:52:52 +08:00
hhhh->addWidget(lb);
2022-09-09 23:25:49 +08:00
fdGroupNum = new QSpinBox;
fdGroupNum->setRange(0, 9999);
fdGroupNum->setValue(GroupNum);
hhhh->addWidget(fdGroupNum);
2022-08-25 22:52:52 +08:00
vvv->addLayout(hhhh);
vvv->addStretch();
hBox->addLayout(vvv);
}
hBox->addStretch();
{
auto vvv = new QVBoxLayout;
auto hhhh = new QHBoxLayout;
2022-12-16 15:08:53 +08:00
lb = new QLabel(tr("驱动芯片: "));
2022-08-25 22:52:52 +08:00
hhhh->addWidget(lb);
2022-09-09 23:25:49 +08:00
fdChipType = new QComboBox;
fdChipType->addItem("ICND2153");
hhhh->addWidget(fdChipType);
2022-08-25 22:52:52 +08:00
vvv->addLayout(hhhh);
vvv->addSpacing(30);
hhhh = new QHBoxLayout;
2022-12-16 15:08:53 +08:00
lb = new QLabel(tr("译码方式: "));
2022-08-25 22:52:52 +08:00
hhhh->addWidget(lb);
2022-09-09 23:25:49 +08:00
fdDecodeMode = new QComboBox;
2022-12-16 15:08:53 +08:00
fdDecodeMode->addItem(tr("138译码"));
2022-08-25 22:52:52 +08:00
hhhh->addWidget(fdDecodeMode);
vvv->addLayout(hhhh);
vvv->addSpacing(30);
hhhh = new QHBoxLayout;
2022-12-16 15:08:53 +08:00
lb = new QLabel(tr("分组方式: "));
2022-08-25 22:52:52 +08:00
hhhh->addWidget(lb);
2022-09-09 23:25:49 +08:00
fdGroupMode = new QComboBox;
2022-12-16 15:08:53 +08:00
fdGroupMode->addItem(tr("三线并行"));
fdGroupMode->addItem(tr("三色1点串"));
fdGroupMode->addItem(tr("三色8点串"));
fdGroupMode->addItem(tr("三色16点串"));
2022-09-09 23:25:49 +08:00
hhhh->addWidget(fdGroupMode);
2022-08-25 22:52:52 +08:00
vvv->addLayout(hhhh);
vvv->addStretch();
hBox->addLayout(vvv);
}
hBox->addStretch();
vBox->addLayout(hBox);
}
page = new QWidget;
stack->addWidget(page);
2022-08-25 18:43:03 +08:00
{
auto vBox = new QVBoxLayout(page);
2022-08-25 22:52:52 +08:00
vBox->setContentsMargins(50, 50, 6, 6);
2022-08-25 18:43:03 +08:00
2022-12-16 15:08:53 +08:00
auto lb = new QLabel(tr("扫描行数"));
2022-08-25 22:52:52 +08:00
lb->setPalette(bkBlue);
2022-08-25 18:43:03 +08:00
vBox->addWidget(lb);
vBox->addSpacing(50);
auto hBox = new QHBoxLayout;
vBox->addLayout(hBox);
hBox->addStretch();
auto vvv = new QVBoxLayout;
hBox->addLayout(vvv);
2022-12-16 15:08:53 +08:00
lb = new QLabel(tr("根据亮线的行/列数确定扫描行/列数: "));
2022-08-25 18:43:03 +08:00
vvv->addWidget(lb);
vvv->addSpacing(30);
auto hhhh = new QHBoxLayout;
hhhh->addStretch();
2022-12-16 15:08:53 +08:00
auto fdRow = new QRadioButton(tr(""));
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdRow);
hhhh->addStretch();
2022-12-16 15:08:53 +08:00
auto fdCol = new QRadioButton(tr(""));
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdCol);
hhhh->addStretch();
vvv->addLayout(hhhh);
vvv->addSpacing(20);
hhhh = new QHBoxLayout;
hhhh->addStretch();
2022-12-16 15:08:53 +08:00
lb = new QLabel(tr("亮线的行/列数: "));
2022-08-25 18:43:03 +08:00
hhhh->addWidget(lb);
auto fdNum = new QSpinBox;
fdNum->setRange(0, 9999);
fdNum->setValue(1);
hhhh->addWidget(fdNum);
hhhh->addStretch();
vvv->addLayout(hhhh);
vvv->addStretch();
hBox->addStretch();
vvv = new QVBoxLayout;
hBox->addLayout(vvv);
2022-12-16 15:08:53 +08:00
lb = new QLabel(tr("芯片245版本: "));
2022-08-25 18:43:03 +08:00
vvv->addWidget(lb);
vvv->addSpacing(30);
hhhh = new QHBoxLayout;
hhhh->addStretch();
auto fdA = new QRadioButton("A");
hhhh->addWidget(fdA);
hhhh->addStretch();
auto fdD = new QRadioButton("D");
hhhh->addWidget(fdD);
hhhh->addStretch();
vvv->addLayout(hhhh);
vvv->addStretch();
hBox->addStretch();
}
page = new QWidget;
stack->addWidget(page);
{
auto vBox = new QVBoxLayout(page);
2022-08-25 22:52:52 +08:00
vBox->setContentsMargins(50, 50, 6, 6);
2022-08-25 18:43:03 +08:00
2022-12-16 15:08:53 +08:00
auto lb = new QLabel(tr("数据线颜色"));
2022-08-25 22:52:52 +08:00
lb->setPalette(bkBlue);
2022-08-25 18:43:03 +08:00
vBox->addWidget(lb);
vBox->addSpacing(50);
2022-12-16 15:08:53 +08:00
lb = new QLabel(tr("依次点击以下状态, 根据模组颜色选择对应颜色"));
2022-08-25 18:43:03 +08:00
vBox->addWidget(lb, 0, Qt::AlignCenter);
vBox->addSpacing(30);
auto hhhh = new QHBoxLayout;
hhhh->addStretch();
2022-12-16 15:08:53 +08:00
auto fdSta1 = new QRadioButton(tr("状态1"));
2022-09-07 23:10:35 +08:00
fdSta1->setChecked(true);
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdSta1);
hhhh->addStretch();
2022-12-16 15:08:53 +08:00
auto fdR1 = new QRadioButton(tr(""));
2022-09-07 23:10:35 +08:00
fdR1->setChecked(true);
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdR1);
hhhh->addSpacing(20);
2022-12-16 15:08:53 +08:00
auto fdG1 = new QRadioButton(tr("绿"));
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdG1);
hhhh->addSpacing(20);
2022-12-16 15:08:53 +08:00
auto fdB1 = new QRadioButton(tr(""));
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdB1);
hhhh->addSpacing(20);
2022-12-16 15:08:53 +08:00
auto fdNo1 = new QRadioButton(tr(""));
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdNo1);
hhhh->addStretch();
vBox->addLayout(hhhh);
vBox->addSpacing(20);
hhhh = new QHBoxLayout;
hhhh->addStretch();
2022-12-16 15:08:53 +08:00
auto fdSta2 = new QRadioButton(tr("状态2"));
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdSta2);
hhhh->addStretch();
2022-12-16 15:08:53 +08:00
auto fdR2 = new QRadioButton(tr(""));
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdR2);
hhhh->addSpacing(20);
2022-12-16 15:08:53 +08:00
auto fdG2 = new QRadioButton(tr("绿"));
2022-09-07 23:10:35 +08:00
fdG2->setChecked(true);
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdG2);
hhhh->addSpacing(20);
2022-12-16 15:08:53 +08:00
auto fdB2 = new QRadioButton(tr(""));
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdB2);
hhhh->addSpacing(20);
2022-12-16 15:08:53 +08:00
auto fdNo2 = new QRadioButton(tr(""));
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdNo2);
hhhh->addStretch();
vBox->addLayout(hhhh);
vBox->addSpacing(20);
hhhh = new QHBoxLayout;
hhhh->addStretch();
2022-12-16 15:08:53 +08:00
auto fdSta3 = new QRadioButton(tr("状态3"));
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdSta3);
hhhh->addStretch();
2022-12-16 15:08:53 +08:00
auto fdR3 = new QRadioButton(tr(""));
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdR3);
hhhh->addSpacing(20);
2022-12-16 15:08:53 +08:00
auto fdG3 = new QRadioButton(tr("绿"));
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdG3);
hhhh->addSpacing(20);
2022-12-16 15:08:53 +08:00
auto fdB3 = new QRadioButton(tr(""));
2022-09-07 23:10:35 +08:00
fdB3->setChecked(true);
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdB3);
hhhh->addSpacing(20);
2022-12-16 15:08:53 +08:00
auto fdNo3 = new QRadioButton(tr(""));
2022-08-25 18:43:03 +08:00
hhhh->addWidget(fdNo3);
hhhh->addStretch();
vBox->addLayout(hhhh);
vBox->addStretch();
auto btnGrp = new QButtonGroup(page);
btnGrp->addButton(fdR1);
btnGrp->addButton(fdG1);
btnGrp->addButton(fdB1);
btnGrp->addButton(fdNo1);
btnGrp = new QButtonGroup(page);
btnGrp->addButton(fdR2);
btnGrp->addButton(fdG2);
btnGrp->addButton(fdB2);
btnGrp->addButton(fdNo2);
btnGrp = new QButtonGroup(page);
btnGrp->addButton(fdR3);
btnGrp->addButton(fdG3);
btnGrp->addButton(fdB3);
btnGrp->addButton(fdNo3);
}
2022-08-25 22:52:52 +08:00
page = new QWidget;
stack->addWidget(page);
{
auto vBox = new QVBoxLayout(page);
vBox->setContentsMargins(0,0,0,0);
auto hhh = new QHBoxLayout;
2022-09-06 23:40:02 +08:00
auto btnUndo = new QPushButton("回撤");
btnUndo->setMinimumSize(90, 30);
connect(btnUndo, &QPushButton::clicked, this, [this] {
2022-09-07 23:10:35 +08:00
auto lastIdx = tableRow->columnCount()-1;
if(lastIdx==-1) return;
auto last = tableRow->item(1, lastIdx);
if(last->text()=="×") {
virtualCnt--;
} else {
auto point = last->data(Qt::UserRole).toPoint();
table->setItem(point.y(), point.x(), 0);
if(lastIdx==virtualCnt) table->selectionModel()->clearCurrentIndex();
else {
for(int i=lastIdx-1; i>-1; i--) {
auto item = tableRow->item(1, i);
if(item->text()=="×") continue;
auto point = item->data(Qt::UserRole).toPoint();
table->setCurrentCell(point.y(), point.x());
break;
}
}
2022-09-06 23:40:02 +08:00
}
2022-09-07 23:10:35 +08:00
tableRow->setColumnCount(lastIdx);
2022-09-06 23:40:02 +08:00
});
hhh->addWidget(btnUndo);
2022-08-25 22:52:52 +08:00
2022-12-16 15:08:53 +08:00
auto btnAddVoid = new QPushButton(tr("插入虚点"));
2022-09-07 23:10:35 +08:00
btnAddVoid->setMinimumSize(90, 30);
connect(btnAddVoid, &QPushButton::clicked, this, [this] {
virtualCnt++;
auto cnt = tableRow->columnCount();
tableRow->setColumnCount(cnt+1);
tableRow->setItem(0, cnt, new QTableWidgetItem(QString::number(cnt+1)));
2022-12-16 15:08:53 +08:00
tableRow->setItem(1, cnt, new QTableWidgetItem("×"));
2022-09-07 23:10:35 +08:00
});
hhh->addWidget(btnAddVoid);
2022-12-16 15:08:53 +08:00
auto btnReset = new QPushButton(tr("重新走点"));
2022-09-07 23:10:35 +08:00
btnReset->setMinimumSize(90, 30);
connect(btnReset, &QPushButton::clicked, this, [this] {
table->clearContents();
tableRow->setColumnCount(0);
virtualCnt = 0;
});
hhh->addWidget(btnReset);
2022-12-16 15:08:53 +08:00
auto btnOK = new QPushButton(tr("完成"));
2022-09-08 23:22:59 +08:00
btnOK->setMinimumSize(90, 30);
connect(btnOK, &QPushButton::clicked, this, &ExpertSmartPointSetWin::save);
hhh->addWidget(btnOK);
2022-08-25 22:52:52 +08:00
hhh->addStretch();
vBox->addLayout(hhh);
table = new PointTable;
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
2022-09-07 23:10:35 +08:00
table->setSelectionMode(QTableWidget::SingleSelection);
2022-08-25 22:52:52 +08:00
table->horizontalHeader()->setDefaultSectionSize(40);
table->horizontalHeader()->setDefaultAlignment(Qt::AlignCenter);
table->verticalHeader()->setMinimumWidth(40);
table->verticalHeader()->setDefaultAlignment(Qt::AlignCenter);
2022-12-16 15:08:53 +08:00
connect(table, &QTableWidget::currentCellChanged, this, [=](int row, int col) {
2022-09-06 23:40:02 +08:00
if(row < 0) return;
auto item = table->item(row, col);
if(item) return;
2022-09-09 23:25:49 +08:00
if(scans.isEmpty()) {
2022-09-08 23:22:59 +08:00
auto cnt = tableRow->columnCount() + 1;
tableRow->setColumnCount(cnt);
tableRow->setItem(0, cnt-1, new QTableWidgetItem(QString::number(cnt)));
item = new QTableWidgetItem("");
item->setData(Qt::UserRole, QPoint{col, row});
tableRow->setItem(1, cnt-1, item);
auto realCnt = cnt - virtualCnt;
item = new QTableWidgetItem(QString::number(realCnt));
table->setItem(row, col, item);
2022-09-09 23:25:49 +08:00
if(realCnt==ModuleWidth) {
scans.append({col, row});
2022-12-16 15:08:53 +08:00
QMessageBox::information(this, tr("提示"), tr("列走完"));
2022-09-08 23:22:59 +08:00
}
2022-09-09 23:25:49 +08:00
} else if(scans.size() < ScanNum) {
scans.append({col, row});
auto size = scans.size();
2022-09-08 23:22:59 +08:00
item = new QTableWidgetItem("S"+QString::number(size));
table->setItem(row, col, item);
2022-12-16 15:08:53 +08:00
2022-09-09 23:25:49 +08:00
if(size==ScanNum) {
2022-12-16 15:08:53 +08:00
QMessageBox::information(this, tr("提示"), tr("行走完"));
2022-09-08 23:22:59 +08:00
save();
}
}
2022-08-25 22:52:52 +08:00
});
2022-12-16 15:08:53 +08:00
2022-08-25 22:52:52 +08:00
vBox->addWidget(table);
2022-09-07 23:10:35 +08:00
tableRow = new PointTable(2, 0);
tableRow->setEditTriggers(QAbstractItemView::NoEditTriggers);
tableRow->setSelectionMode(QTableWidget::NoSelection);
tableRow->horizontalHeader()->setDefaultSectionSize(40);
tableRow->horizontalHeader()->setVisible(false);
tableRow->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);
tableRow->verticalHeader()->setMinimumWidth(120);
tableRow->setMaximumHeight(80);
auto item = tableRow->verticalHeaderItem(0);
if(item==0) tableRow->setVerticalHeaderItem(0, item = new QTableWidgetItem());
2022-12-16 15:08:53 +08:00
item->setText(tr("第一扫灯数:"));
2022-09-07 23:10:35 +08:00
item = tableRow->verticalHeaderItem(1);
if(item==0) tableRow->setVerticalHeaderItem(1, item = new QTableWidgetItem());
2022-12-16 15:08:53 +08:00
item->setText(tr("实: 虚:"));
2022-09-07 23:10:35 +08:00
vBox->addWidget(tableRow);
2022-08-25 22:52:52 +08:00
}
2022-08-25 18:43:03 +08:00
auto hBox = new QHBoxLayout;
vBox->addLayout(hBox);
hBox->addStretch();
2022-12-16 15:08:53 +08:00
auto btnPrev = new QPushButton(tr("上一步"));
2022-08-25 18:43:03 +08:00
btnPrev->setMinimumSize(90, 30);
hBox->addWidget(btnPrev);
2022-12-16 15:08:53 +08:00
auto btnNext = new QPushButton(tr("下一步"));
2022-08-25 18:43:03 +08:00
btnNext->setMinimumSize(90, 30);
hBox->addWidget(btnNext);
connect(btnPrev, &QPushButton::clicked, this, [stack, btnPrev, btnNext] {
2022-08-25 22:52:52 +08:00
auto idx = stack->currentIndex();
stack->setCurrentIndex(--idx);
2022-09-08 23:22:59 +08:00
btnPrev->setEnabled(idx > 0);
btnNext->setEnabled(idx < stack->count()-1);
2022-08-25 18:43:03 +08:00
});
2022-12-16 15:08:53 +08:00
connect(btnNext, &QPushButton::clicked, this, [=] {
2022-08-25 22:52:52 +08:00
auto idx = stack->currentIndex();
if(idx==0) {
2022-09-09 23:25:49 +08:00
ModuleWidth = fdModuleWidth->value();
ModuleHeight = fdModuleHeight->value();
GroupNum = fdGroupNum->value();
ScanNum = (ModuleHeight + 1) / GroupNum;
ChipType = fdChipType->currentText();
DecodeMode = fdDecodeMode->currentText();
GroupMode = fdGroupMode->currentText();
2022-08-25 22:52:52 +08:00
} else if(idx==2) {
2022-09-09 23:25:49 +08:00
table->setColumnCount(ModuleWidth);
table->setRowCount(ModuleHeight);
2022-08-25 22:52:52 +08:00
}
stack->setCurrentIndex(++idx);
2022-09-08 23:22:59 +08:00
btnPrev->setEnabled(idx > 0);
btnNext->setEnabled(idx < stack->count()-1);
2022-08-25 18:43:03 +08:00
});
auto btnCcl = new QPushButton("取消");
btnCcl->setMinimumSize(90, 30);
hBox->addWidget(btnCcl);
hBox->addSpacing(30);
}
2022-09-08 23:22:59 +08:00
void ExpertSmartPointSetWin::save() {
2022-12-16 15:08:53 +08:00
auto file = QApplication::applicationDirPath()+"/temp.module";
2022-09-09 23:25:49 +08:00
QFile qFile(file);
2022-12-16 15:08:53 +08:00
if(! qFile.open(QFile::WriteOnly)) {
QMessageBox::critical(this, tr("失败"), QString(tr("准备写入 %1 文件失败")).arg(file));
return;
}
2022-09-09 23:25:49 +08:00
QJsonObject obj;
obj.insert("ModuleWidth", ModuleWidth);
obj.insert("ModuleHeight", ModuleHeight);
obj.insert("GroupNum", GroupNum);
obj.insert("ScanNum", ScanNum);
obj.insert("ChipType", ChipType);
obj.insert("DecodeMode", DecodeMode);
obj.insert("GroupMode", GroupMode);
2022-12-16 15:08:53 +08:00
QJsonArray points;
auto cnt = tableRow->columnCount();
if(cnt > ModuleWidth) {
auto add = (cnt+ModuleWidth-1) / ModuleWidth * ModuleWidth - cnt;
for(int i=0; i<add; i++) points.append(-1);
}
for(int i=cnt-1; i>=0; i--) {
2022-09-09 23:25:49 +08:00
auto data = tableRow->item(1, i)->data(Qt::UserRole);
2022-12-16 15:08:53 +08:00
points.append(data.isValid() ? data.toPoint().x() : -1);
2022-09-09 23:25:49 +08:00
}
2022-12-16 15:08:53 +08:00
obj.insert("Points", points);
2022-09-09 23:25:49 +08:00
QJsonArray Scans;
foreach(QPoint scan, scans) Scans.append(scan.y());
obj.insert("Scans", Scans);
2022-12-16 15:08:53 +08:00
auto data = QJsonDocument(obj).toJson(QJsonDocument::Indented);
auto res = qFile.write(data);
2022-09-09 23:25:49 +08:00
qFile.close();
2022-12-16 15:08:53 +08:00
if(res < 0) {
QMessageBox::critical(this, tr("失败"), QString(tr("写入 %1 文件失败")).arg(file));
return;
}
expertWin->mModule = obj;
2022-09-08 23:22:59 +08:00
2022-12-16 15:08:53 +08:00
expertWin->fdModuleWidth->setText(QString::number(ModuleWidth));
expertWin->fdModuleHeight->setText(QString::number(ModuleHeight));
expertWin->fdGroupNum->setText(QString::number(GroupNum));
expertWin->fdScanNum->setText(QString::number(ScanNum));
expertWin->fdChipType->setText(ChipType);
expertWin->fdDecodeMode->setText(DecodeMode);
2022-09-08 23:22:59 +08:00
2022-12-16 15:08:53 +08:00
expertWin->fdCardWidth->setValue(ModuleWidth);
expertWin->fdCardHeight->setValue(ModuleHeight);
2022-09-08 23:22:59 +08:00
2022-12-16 15:08:53 +08:00
auto appDir = QApplication::applicationDirPath();
QDir(appDir).mkdir("ModuleFiles");
file = QFileDialog::getSaveFileName(this, tr("保存文件"), appDir+QString("/ModuleFiles/%1X%2_%3扫.module").arg(ModuleWidth).arg(ModuleHeight).arg(ScanNum), tr("Module file (*.module)"));
if(file.isEmpty()) return;
QFile qFile2(file);
if(! qFile2.open(QFile::WriteOnly)) {
QMessageBox::critical(this, tr("失败"), QString(tr("准备写入 %1 文件失败")).arg(file));
return;
}
res = qFile2.write(data);
qFile2.close();
if(res < 0) {
QMessageBox::critical(this, tr("失败"), QString(tr("写入 %1 文件失败")).arg(file));
return;
}
QMessageBox::information(this, tr("保存成功"), tr("保存成功"));
close();
2022-09-08 23:22:59 +08:00
}