101 lines
3.2 KiB
C++
101 lines
3.2 KiB
C++
#include "expertboxlayoutwin.h"
|
|
#include "moduleunit.h"
|
|
#include "gutil/qgui.h"
|
|
#include "gutil/qjson.h"
|
|
#include "globalfunc.h"
|
|
#include <QPushButton>
|
|
#include <QCheckBox>
|
|
#include <QMessageBox>
|
|
#include <QScrollArea>
|
|
#include <QFileDialog>
|
|
|
|
ExpertBoxLayoutWin::ExpertBoxLayoutWin(QWidget *parent) : BaseWin{parent} {
|
|
setAttribute(Qt::WA_DeleteOnClose);
|
|
setWindowTitle("箱体高级布局");
|
|
resize(1024, 720);
|
|
|
|
auto vBox = new VBox(center);
|
|
vBox->setContentsMargins(0,0,0,0);
|
|
vBox->setSpacing(3);
|
|
vBox->addLayout(addBtns(new QHBoxLayout()));
|
|
|
|
auto hBox = new HBox(vBox);
|
|
vBox = new VBox(hBox);
|
|
|
|
vBox->addWidget(new QLabel("模组编辑"));
|
|
|
|
auto grid = new Grid(vBox);
|
|
auto btnAdd = new QPushButton("添加");
|
|
connect(btnAdd, &QPushButton::clicked, this, [this] {
|
|
auto file = QFileDialog::getOpenFileName(this, tr("打开单元板文件"), gFileHome, tr("单元板文件 (*.module)"));
|
|
if(file.isEmpty()) return;
|
|
QFile qFile(file);
|
|
if(! qFile.open(QFile::ReadOnly)) {
|
|
QMessageBox::critical(this, tr("打开单元板文件失败"), file);
|
|
return;
|
|
}
|
|
QString err;
|
|
auto json = JFrom(&qFile, &err).toObj();
|
|
qFile.close();
|
|
if(! err.isEmpty()) {
|
|
QMessageBox::critical(this, tr("解析 json 失败"), err+" "+file);
|
|
return;
|
|
}
|
|
new ModuleUnit(this, "J1", 0, 0, json["ModuleWidth"].toInt(), json["ModuleHeight"].toInt(), box);
|
|
});
|
|
grid->addWidget(btnAdd, 0, 0);
|
|
auto btnDel = new QPushButton("删除");
|
|
grid->addWidget(btnDel, 0, 1);
|
|
auto btnMove = new QPushButton("移动");
|
|
grid->addWidget(btnMove, 1, 0);
|
|
auto btnRotate = new QPushButton("旋转");
|
|
grid->addWidget(btnRotate, 1, 1);
|
|
|
|
vBox->addWidget(new QLabel("HUB口编辑"));
|
|
|
|
grid = new Grid(vBox);
|
|
auto btnPort = new QPushButton("端口");
|
|
grid->addWidget(btnPort, 0, 0);
|
|
auto btnManual = new QPushButton("手动");
|
|
grid->addWidget(btnManual, 0, 1);
|
|
auto btnUp = new QPushButton("上移");
|
|
grid->addWidget(btnUp, 1, 0);
|
|
auto btnDown = new QPushButton("下移");
|
|
grid->addWidget(btnDown, 1, 1);
|
|
|
|
vBox->addWidget(new QLabel("HUB口编辑"));
|
|
|
|
grid = new Grid(vBox);
|
|
auto fdHasPos = new QCheckBox("位置");
|
|
grid->addWidget(fdHasPos, 0, 0);
|
|
auto fdHasSize = new QCheckBox("大小");
|
|
grid->addWidget(fdHasSize, 0, 1);
|
|
auto fdHasConn = new QCheckBox("连接");
|
|
grid->addWidget(fdHasConn, 1, 0);
|
|
auto fdHasName = new QCheckBox("名称");
|
|
grid->addWidget(fdHasName, 1, 1);
|
|
auto fdHasOutline = new QCheckBox("轮廓");
|
|
grid->addWidget(fdHasOutline, 2, 0);
|
|
auto fdHasRotate = new QCheckBox("旋转");
|
|
grid->addWidget(fdHasRotate, 2, 1);
|
|
|
|
vBox->addStretch();
|
|
|
|
vBox = new VBox(hBox);
|
|
hBox = new HBox(vBox);
|
|
hBox->addStretch();
|
|
|
|
auto scroll = new QScrollArea;
|
|
vBox->addWidget(scroll);
|
|
|
|
box = new QWidget;
|
|
scroll->setWidget(box);
|
|
box->resize(1024, 1024);
|
|
box->setAutoFillBackground(true);
|
|
auto pal = palette();
|
|
pal.setColor(QPalette::Window, QColor(0x222222));
|
|
box->setPalette(pal);
|
|
|
|
new ModuleUnit(this, "J1", 0, 0, 128, 128, box);
|
|
}
|