ledset
This commit is contained in:
parent
2a82c3b603
commit
8fa52c5c8c
|
@ -82,7 +82,6 @@ ExpertBoxLayoutWin::ExpertBoxLayoutWin(QWidget *parent) : BaseWin{parent} {
|
||||||
|
|
||||||
auto unit = new ModuleUnit(this, name, idx, 0, 128, 128, screen);
|
auto unit = new ModuleUnit(this, name, idx, 0, 128, 128, screen);
|
||||||
unit->setAutoFillBackground(true);
|
unit->setAutoFillBackground(true);
|
||||||
pal.setColor(QPalette::Window, colors[rr]);
|
|
||||||
unit->setPalette(pal);
|
unit->setPalette(pal);
|
||||||
idx += 128;
|
idx += 128;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "expertscreenconnwin.h"
|
#include "expertscreenconnwin.h"
|
||||||
#include "gqt.h"
|
#include "gutil/qgui.h"
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
@ -14,11 +14,9 @@
|
||||||
QColor cardColors[] {QColor(0xff2222), QColor(0xffaa00), QColor(0x00bb00), QColor(0x00bbcc), QColor(0x0044ff), QColor(0xffffff), QColor(0xffff00)};
|
QColor cardColors[] {QColor(0xff2222), QColor(0xffaa00), QColor(0x00bb00), QColor(0x00bbcc), QColor(0x0044ff), QColor(0xffffff), QColor(0xffff00)};
|
||||||
|
|
||||||
ExpertScreenConnWin::ExpertScreenConnWin(QWidget *parent) : QWidget{parent} {
|
ExpertScreenConnWin::ExpertScreenConnWin(QWidget *parent) : QWidget{parent} {
|
||||||
auto vv = new QVBoxLayout(this);
|
auto vv = new VBox(this);
|
||||||
vv->setContentsMargins(4, 4, 4, 4);
|
vv->setContentsMargins(4, 4, 4, 4);
|
||||||
|
auto hh = new HBox(vv);
|
||||||
auto hh = new QHBoxLayout;
|
|
||||||
vv->addLayout(hh);
|
|
||||||
|
|
||||||
auto leftWgt = new QWidget;
|
auto leftWgt = new QWidget;
|
||||||
auto poli = leftWgt->sizePolicy();
|
auto poli = leftWgt->sizePolicy();
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "expertsmartpointsetwin.h"
|
#include "expertsmartpointsetwin.h"
|
||||||
|
#include "gutil/qgui.h"
|
||||||
|
#include "globalfunc.h"
|
||||||
#include <QStackedLayout>
|
#include <QStackedLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
|
@ -9,9 +11,49 @@
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QJsonObject>
|
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
|
||||||
|
struct ModUnitMap {
|
||||||
|
byte UUID{ie(16)};
|
||||||
|
byte type{ipp(4)};
|
||||||
|
byte len{ipp(4)};
|
||||||
|
byte w{ipp(2)};
|
||||||
|
byte h{ipp(2)};
|
||||||
|
byte ex1{ipp(4)};
|
||||||
|
byte ChipType{ipp(2)};
|
||||||
|
byte decodeMode{ipp(2)};
|
||||||
|
byte ex3{ipp(4)};
|
||||||
|
byte smartset{ipp(4)};
|
||||||
|
byte smartset2{ipp(4)};
|
||||||
|
byte 走点len{ipp(4)};
|
||||||
|
byte endFlag{ipp(4)};
|
||||||
|
byte end{fi};
|
||||||
|
} modUnitMap;
|
||||||
|
struct ModMap {
|
||||||
|
byte start{ie(4)};
|
||||||
|
byte 保留{ipp(2)};
|
||||||
|
byte len{ipp(2)};
|
||||||
|
byte 换行时间{ipp(2)};
|
||||||
|
byte 换行时刻{ipp(2)};
|
||||||
|
byte 最小OE宽度{ipp(2)};
|
||||||
|
byte 放电时间{ipp(2)};
|
||||||
|
byte GLK占空比{fi++};
|
||||||
|
byte 灰度等级{fi++};
|
||||||
|
byte 数据时钟相位向后偏{fi++};
|
||||||
|
byte 数据时钟相位向前偏{fi++};
|
||||||
|
byte 时钟分频系数{fi++};
|
||||||
|
byte 倍频数{fi++};
|
||||||
|
byte 帧率{fi++};
|
||||||
|
byte 校正类型{fi++};
|
||||||
|
byte 芯片通道数{ipp(3)};
|
||||||
|
byte 模组类型数目{ipp()};
|
||||||
|
byte Unit{ipp(modUnitMap.end)};
|
||||||
|
byte 保留2{ie(4)};
|
||||||
|
byte check{ie(4)};
|
||||||
|
byte end{fi};
|
||||||
|
} modMap;
|
||||||
|
|
||||||
ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{expertWin}, expertWin(expertWin) {
|
ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{expertWin}, expertWin(expertWin) {
|
||||||
setWindowModality(Qt::WindowModal);
|
setWindowModality(Qt::WindowModal);
|
||||||
|
@ -27,124 +69,392 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e
|
||||||
DecodeMode = expertWin->mModule["DecodeMode"].toString();
|
DecodeMode = expertWin->mModule["DecodeMode"].toString();
|
||||||
GroupMode = expertWin->mModule["GroupMode"].toString();
|
GroupMode = expertWin->mModule["GroupMode"].toString();
|
||||||
|
|
||||||
auto vBox = new QVBoxLayout(center);
|
auto vBox = new VBox(center);
|
||||||
vBox->setContentsMargins(0,0,0,0);
|
vBox->setContentsMargins(0,0,0,0);
|
||||||
vBox->setSpacing(3);
|
vBox->setSpacing(3);
|
||||||
vBox->addLayout(addBtns(new QHBoxLayout()));
|
vBox->addLayout(addBtns(new QHBoxLayout()));
|
||||||
|
|
||||||
auto stack = new QStackedLayout;
|
auto stack = new QStackedLayout(vBox);
|
||||||
vBox->addLayout(stack);
|
auto vv = new VBox(stack);
|
||||||
|
vv->setContentsMargins(50, 50, 6, 6);
|
||||||
|
|
||||||
|
auto lb = new QLabel(tr("基本参数"));
|
||||||
|
gFontSize(lb, 16);
|
||||||
|
auto bkBlue = lb->palette();
|
||||||
|
bkBlue.setColor(QPalette::WindowText, QColor(0x5599ff));
|
||||||
|
lb->setPalette(bkBlue);
|
||||||
|
vv->addWidget(lb);
|
||||||
|
vv->addSpacing(50);
|
||||||
|
|
||||||
|
auto grid = new Grid(vv);
|
||||||
|
grid->setVerticalSpacing(30);
|
||||||
|
grid->setColumnStretch(0, 1);
|
||||||
|
grid->setColumnStretch(3, 1);
|
||||||
|
grid->setColumnStretch(6, 1);
|
||||||
|
|
||||||
|
lb = new QLabel(tr("模组宽度: "));
|
||||||
|
grid->addWidget(lb, 0, 1);
|
||||||
|
|
||||||
|
fdModuleWidth = new QSpinBox;
|
||||||
|
fdModuleWidth->setRange(0, 9999);
|
||||||
|
fdModuleWidth->setValue(ModuleWidth);
|
||||||
|
grid->addWidget(fdModuleWidth, 0, 2);
|
||||||
|
|
||||||
|
lb = new QLabel(tr("模组高度: "));
|
||||||
|
grid->addWidget(lb, 1, 1);
|
||||||
|
|
||||||
|
fdModuleHeight = new QSpinBox;
|
||||||
|
fdModuleHeight->setRange(0, 9999);
|
||||||
|
fdModuleHeight->setValue(ModuleHeight);
|
||||||
|
grid->addWidget(fdModuleHeight, 1, 2);
|
||||||
|
|
||||||
|
lb = new QLabel(tr("数据组数: "));
|
||||||
|
grid->addWidget(lb, 2, 1);
|
||||||
|
|
||||||
|
fdGroupNum = new QSpinBox;
|
||||||
|
fdGroupNum->setRange(0, 9999);
|
||||||
|
fdGroupNum->setValue(GroupNum);
|
||||||
|
grid->addWidget(fdGroupNum, 2, 2);
|
||||||
|
|
||||||
|
|
||||||
|
lb = new QLabel(tr("驱动芯片: "));
|
||||||
|
grid->addWidget(lb, 0, 4);
|
||||||
|
|
||||||
|
auto hhhh = new HBox;
|
||||||
|
hhhh->setSpacing(0);
|
||||||
|
|
||||||
|
fdChipType = new QLineEdit("ICND2153");
|
||||||
|
fdChipType->setMinimumWidth(150);
|
||||||
|
hhhh->addWidget(fdChipType);
|
||||||
|
|
||||||
|
auto btn = new QPushButton("...");
|
||||||
|
btn->setMaximumWidth(30);
|
||||||
|
connect(btn, &QPushButton::clicked, this, [=] {
|
||||||
|
QDialog dlg(this);
|
||||||
|
dlg.setWindowFlag(Qt::WindowMaximizeButtonHint);
|
||||||
|
dlg.setWindowTitle("选择芯片类型");
|
||||||
|
dlg.resize(800, 600);
|
||||||
|
|
||||||
|
auto vBox = new VBox(&dlg);
|
||||||
|
vBox->setContentsMargins(0,0,0,0);
|
||||||
|
|
||||||
|
auto table = new Table(24, 10);
|
||||||
|
table->setColFit();
|
||||||
|
table->setRowFit();
|
||||||
|
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||||
|
table->setAlternatingRowColors(true);
|
||||||
|
table->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
|
int rr = 0, cc = 0;
|
||||||
|
table->setHeaderText(cc, "ICN系列");
|
||||||
|
table->setText(rr++, cc, "ICN2026");
|
||||||
|
table->setText(rr++, cc, "ICN2027");
|
||||||
|
table->setText(rr++, cc, "ICN2028");
|
||||||
|
table->setText(rr++, cc, "ICN2037");
|
||||||
|
table->setText(rr++, cc, "ICN2038");
|
||||||
|
table->setText(rr++, cc, "ICN2038S");
|
||||||
|
table->setText(rr++, cc, "ICN2053");
|
||||||
|
table->setText(rr++, cc, "ICN2058");
|
||||||
|
table->setText(rr++, cc, "ICN2088");
|
||||||
|
table->setText(rr++, cc, "ICND2045");
|
||||||
|
table->setText(rr++, cc, "ICND2046");
|
||||||
|
table->setText(rr++, cc, "ICND2047");
|
||||||
|
table->setText(rr++, cc, "ICND2049");
|
||||||
|
table->setText(rr++, cc, "ICND2055");
|
||||||
|
table->setText(rr++, cc, "ICND2059");
|
||||||
|
table->setText(rr++, cc, "ICND2065");
|
||||||
|
table->setText(rr++, cc, "ICND2069");
|
||||||
|
table->setText(rr++, cc, "ICND2076");
|
||||||
|
table->setText(rr++, cc, "ICND2110");
|
||||||
|
table->setText(rr++, cc, "ICND2112");
|
||||||
|
table->setText(rr++, cc, "ICND2153");
|
||||||
|
table->setText(rr++, cc, "ICND2153_three");
|
||||||
|
table->setText(rr++, cc, "ICND2163");
|
||||||
|
table->setText(rr++, cc, "ICND2200");
|
||||||
|
rr = 0; cc++;
|
||||||
|
table->setHeaderText(cc, "SM系列");
|
||||||
|
table->setText(rr++, cc, "SM16017_NEW");
|
||||||
|
table->setText(rr++, cc, "SM16017S");
|
||||||
|
table->setText(rr++, cc, "SM16159S");
|
||||||
|
table->setText(rr++, cc, "SM16169S");
|
||||||
|
table->setText(rr++, cc, "SM16207S");
|
||||||
|
table->setText(rr++, cc, "SM16218");
|
||||||
|
table->setText(rr++, cc, "SM16227S");
|
||||||
|
table->setText(rr++, cc, "SM16237DS");
|
||||||
|
table->setText(rr++, cc, "SM16237S");
|
||||||
|
table->setText(rr++, cc, "SM16259S");
|
||||||
|
table->setText(rr++, cc, "SM16259S");
|
||||||
|
table->setText(rr++, cc, "SM16369");
|
||||||
|
table->setText(rr++, cc, "SM16380");
|
||||||
|
table->setText(rr++, cc, "SM16388");
|
||||||
|
table->setText(rr++, cc, "SM16389");
|
||||||
|
table->setText(rr++, cc, "SM16509/16399");
|
||||||
|
rr = 0; cc++;
|
||||||
|
table->setHeaderText(cc, "LS系列");
|
||||||
|
table->setText(rr++, cc, "LS9918S");
|
||||||
|
table->setText(rr++, cc, "LS9919S");
|
||||||
|
table->setText(rr++, cc, "LS9926S");
|
||||||
|
table->setText(rr++, cc, "LS9929C");
|
||||||
|
table->setText(rr++, cc, "LS9929S");
|
||||||
|
table->setText(rr++, cc, "LS9930S");
|
||||||
|
table->setText(rr++, cc, "LS9931S");
|
||||||
|
table->setText(rr++, cc, "LS9935B");
|
||||||
|
table->setText(rr++, cc, "LS9935S");
|
||||||
|
table->setText(rr++, cc, "LS9936S");
|
||||||
|
table->setText(rr++, cc, "LS9961S");
|
||||||
|
rr = 0; cc++;
|
||||||
|
table->setHeaderText(cc, "MBI系列");
|
||||||
|
table->setText(rr++, cc, "MBI5041/5042");
|
||||||
|
table->setText(rr++, cc, "MBI5051");
|
||||||
|
table->setText(rr++, cc, "MBI5124");
|
||||||
|
table->setText(rr++, cc, "MBI5151");
|
||||||
|
table->setText(rr++, cc, "MBI5153");
|
||||||
|
table->setText(rr++, cc, "MBI5155");
|
||||||
|
table->setText(rr++, cc, "MBI5158");
|
||||||
|
table->setText(rr++, cc, "MBI5252");
|
||||||
|
table->setText(rr++, cc, "MBI5253");
|
||||||
|
table->setText(rr++, cc, "MBI5253B");
|
||||||
|
table->setText(rr++, cc, "MBI5254");
|
||||||
|
table->setText(rr++, cc, "MBI5264");
|
||||||
|
table->setText(rr++, cc, "MBI5268");
|
||||||
|
table->setText(rr++, cc, "MBI5353");
|
||||||
|
table->setText(rr++, cc, "MBI5353B");
|
||||||
|
table->setText(rr++, cc, "MBI6322");
|
||||||
|
table->setText(rr++, cc, "MBI6328");
|
||||||
|
table->setText(rr++, cc, "MBI6334");
|
||||||
|
rr = 0; cc++;
|
||||||
|
table->setHeaderText(cc, "SUM系列");
|
||||||
|
table->setText(rr++, cc, "SUM2017");
|
||||||
|
table->setText(rr++, cc, "SUM2017T");
|
||||||
|
table->setText(rr++, cc, "SUM2017TD");
|
||||||
|
table->setText(rr++, cc, "SUM2028");
|
||||||
|
table->setText(rr++, cc, "SUM2030");
|
||||||
|
table->setText(rr++, cc, "SUM2030T");
|
||||||
|
table->setText(rr++, cc, "SUM2032");
|
||||||
|
table->setText(rr++, cc, "SUM2033");
|
||||||
|
table->setText(rr++, cc, "SUM2035");
|
||||||
|
table->setText(rr++, cc, "SUM2036");
|
||||||
|
table->setText(rr++, cc, "SUM2037");
|
||||||
|
table->setText(rr++, cc, "SUM2117");
|
||||||
|
table->setText(rr++, cc, "SUM2130");
|
||||||
|
table->setText(rr++, cc, "SUM2131");
|
||||||
|
table->setText(rr++, cc, "SUM2135");
|
||||||
|
table->setText(rr++, cc, "SUM6086");
|
||||||
|
rr = 0; cc++;
|
||||||
|
table->setHeaderText(cc, "FM系列");
|
||||||
|
table->setText(rr++, cc, "FM6128");
|
||||||
|
table->setText(rr++, cc, "FM6129");
|
||||||
|
table->setText(rr++, cc, "FM6153");
|
||||||
|
table->setText(rr++, cc, "FM6182");
|
||||||
|
table->setText(rr++, cc, "FM6253");
|
||||||
|
table->setText(rr++, cc, "FM6353");
|
||||||
|
table->setText(rr++, cc, "FM6356");
|
||||||
|
table->setText(rr++, cc, "FM6363");
|
||||||
|
table->setText(rr++, cc, "FM6555");
|
||||||
|
table->setText(rr++, cc, "FM6565/6569");
|
||||||
|
table->setText(rr++, cc, "FM6565CE");
|
||||||
|
rr = 0; cc++;
|
||||||
|
table->setHeaderText(cc, "DP系列");
|
||||||
|
table->setText(rr++, cc, "DP5135");
|
||||||
|
table->setText(rr++, cc, "DP5220X");
|
||||||
|
table->setText(rr++, cc, "DP5525");
|
||||||
|
rr = 0; cc++;
|
||||||
|
table->setHeaderText(cc, "MY系列");
|
||||||
|
table->setText(rr++, cc, "MY9758");
|
||||||
|
table->setText(rr++, cc, "MY9862");
|
||||||
|
table->setText(rr++, cc, "MY9866");
|
||||||
|
rr = 0; cc++;
|
||||||
|
table->setHeaderText(cc, "LYD系列");
|
||||||
|
table->setText(rr++, cc, "LYD6168B");
|
||||||
|
table->setText(rr++, cc, "LYD6168C");
|
||||||
|
table->setText(rr++, cc, "LYD6168D");
|
||||||
|
table->setText(rr++, cc, "LYD6168E");
|
||||||
|
table->setText(rr++, cc, "LYD6188");
|
||||||
|
table->setText(rr++, cc, "LYD6188PC");
|
||||||
|
rr = 0; cc++;
|
||||||
|
table->setHeaderText(cc, "其他系列");
|
||||||
|
table->setText(rr++, cc, "通用");
|
||||||
|
table->setText(rr++, cc, "A5065");
|
||||||
|
table->setText(rr++, cc, "AXS6018");
|
||||||
|
table->setText(rr++, cc, "CFD135A");
|
||||||
|
table->setText(rr++, cc, "CFD455A");
|
||||||
|
table->setText(rr++, cc, "CNS7153");
|
||||||
|
table->setText(rr++, cc, "CNS7253");
|
||||||
|
table->setText(rr++, cc, "CNS7263");
|
||||||
|
table->setText(rr++, cc, "CS2017");
|
||||||
|
table->setText(rr++, cc, "CS2033");
|
||||||
|
table->setText(rr++, cc, "D26188");
|
||||||
|
table->setText(rr++, cc, "HX8055");
|
||||||
|
table->setText(rr++, cc, "HX8864");
|
||||||
|
table->setText(rr++, cc, "HX8896");
|
||||||
|
table->setText(rr++, cc, "RT5965");
|
||||||
|
table->setText(rr++, cc, "RT5967");
|
||||||
|
table->setText(rr++, cc, "SCL8081A");
|
||||||
|
table->setText(rr++, cc, "XM11202G");
|
||||||
|
|
||||||
|
auto def = fdChipType->text();
|
||||||
|
QTableWidgetItem *item;
|
||||||
|
if(! def.isEmpty()) for(int r=0; r<table->rowCount(); r++) for(int c=0; c<table->columnCount(); c++) if((item = table->item(r, c)) && item->text()==def) item->setSelected(true);
|
||||||
|
connect(table, &Table::cellDoubleClicked, &dlg, [=, &dlg](int row, int column) {
|
||||||
|
auto text = table->text(row, column);
|
||||||
|
if(text.isEmpty()) return;
|
||||||
|
fdChipType->setText(text);
|
||||||
|
chipType = (column<<8) | row;
|
||||||
|
dlg.accept();
|
||||||
|
});
|
||||||
|
vBox->addWidget(table);
|
||||||
|
|
||||||
|
auto btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Close);
|
||||||
|
connect(btnBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject);
|
||||||
|
connect(btnBox, &QDialogButtonBox::accepted, &dlg, [&, table] {
|
||||||
|
auto items = table->selectedItems();
|
||||||
|
if(items.isEmpty()) {
|
||||||
|
QMessageBox::warning(&dlg, "Warning", "请选择芯片类型");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fdChipType->setText(items[0]->text());
|
||||||
|
auto ranges = table->selectedRanges();
|
||||||
|
chipType = (ranges[0].leftColumn()<<8) | ranges[0].topRow();
|
||||||
|
dlg.accept();
|
||||||
|
});
|
||||||
|
vBox->addWidget(btnBox);
|
||||||
|
|
||||||
|
dlg.exec();
|
||||||
|
});
|
||||||
|
hhhh->addWidget(btn);
|
||||||
|
grid->addLayout(hhhh, 0, 5);
|
||||||
|
|
||||||
|
lb = new QLabel(tr("译码方式: "));
|
||||||
|
grid->addWidget(lb, 1, 4);
|
||||||
|
|
||||||
|
hhhh = new HBox;
|
||||||
|
hhhh->setSpacing(0);
|
||||||
|
|
||||||
|
fdDecodeMode = new QLineEdit(tr("138译码"));
|
||||||
|
hhhh->addWidget(fdDecodeMode);
|
||||||
|
|
||||||
|
btn = new QPushButton("...");
|
||||||
|
btn->setMaximumWidth(30);
|
||||||
|
connect(btn, &QPushButton::clicked, this, [=] {
|
||||||
|
QDialog dlg(this);
|
||||||
|
dlg.setWindowFlag(Qt::WindowMaximizeButtonHint);
|
||||||
|
dlg.setWindowTitle("选择译码方式");
|
||||||
|
dlg.resize(600, 400);
|
||||||
|
|
||||||
|
auto vBox = new VBox(&dlg);
|
||||||
|
vBox->setContentsMargins(0,0,0,0);
|
||||||
|
|
||||||
|
auto table = new Table(9, 7);
|
||||||
|
table->setColFit();
|
||||||
|
table->setRowFit();
|
||||||
|
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||||
|
table->setAlternatingRowColors(true);
|
||||||
|
table->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
|
int rr = 0, cc = 0;
|
||||||
|
table->setHeaderText(cc, "系列"+QString::number(cc+1));
|
||||||
|
table->setText(rr++, cc, "138译码");
|
||||||
|
table->setText(rr++, cc, "ICN2012");
|
||||||
|
table->setText(rr++, cc, "MW4958");
|
||||||
|
table->setText(rr++, cc, "SM5166P");
|
||||||
|
table->setText(rr++, cc, "TC7260");
|
||||||
|
table->setText(rr++, cc, "TC7258E");
|
||||||
|
table->setText(rr++, cc, "TC7258EN");
|
||||||
|
table->setText(rr++, cc, "HX6012");
|
||||||
|
table->setText(rr++, cc, "ICN2016");
|
||||||
|
rr = 0; cc++;
|
||||||
|
table->setHeaderText(cc, "系列"+QString::number(cc+1));
|
||||||
|
table->setText(rr++, cc, "595译码");
|
||||||
|
rr = 0; cc++;
|
||||||
|
table->setHeaderText(cc, "系列"+QString::number(cc+1));
|
||||||
|
table->setText(rr++, cc, "5958译码");
|
||||||
|
table->setText(rr++, cc, "5960译码");
|
||||||
|
table->setText(rr++, cc, "TC7558");
|
||||||
|
table->setText(rr++, cc, "RT5957");
|
||||||
|
table->setText(rr++, cc, "HX6058");
|
||||||
|
table->setText(rr++, cc, "HX6158H");
|
||||||
|
table->setText(rr++, cc, "MBI5988");
|
||||||
|
rr = 0; cc++;
|
||||||
|
table->setHeaderText(cc, "系列"+QString::number(cc+1));
|
||||||
|
table->setText(rr++, cc, "直接输出 (低)");
|
||||||
|
table->setText(rr++, cc, "直接输出 (高)");
|
||||||
|
table->setText(rr++, cc, "静态无译码");
|
||||||
|
rr = 0; cc++;
|
||||||
|
table->setHeaderText(cc, "系列"+QString::number(cc+1));
|
||||||
|
table->setText(rr++, cc, "ICND2018");
|
||||||
|
table->setText(rr++, cc, "ICND3018");
|
||||||
|
table->setText(rr++, cc, "ICND2019");
|
||||||
|
table->setText(rr++, cc, "TC7559");
|
||||||
|
table->setText(rr++, cc, "TC7519");
|
||||||
|
table->setText(rr++, cc, "SM5366");
|
||||||
|
table->setText(rr++, cc, "DP32020");
|
||||||
|
table->setText(rr++, cc, "DP7298A");
|
||||||
|
table->setText(rr++, cc, "SM5368");
|
||||||
|
rr = 0; cc++;
|
||||||
|
table->setHeaderText(cc, "系列"+QString::number(cc+1));
|
||||||
|
table->setText(rr++, cc, "ICND2013");
|
||||||
|
table->setText(rr++, cc, "TC7262");
|
||||||
|
table->setText(rr++, cc, "ICND2017");
|
||||||
|
table->setText(rr++, cc, "DP7268E");
|
||||||
|
table->setText(rr++, cc, "DP32019");
|
||||||
|
table->setText(rr++, cc, "HX6013");
|
||||||
|
rr = 0; cc++;
|
||||||
|
table->setHeaderText(cc, "系列"+QString::number(cc+1));
|
||||||
|
table->setText(rr++, cc, "SM5266P");
|
||||||
|
table->setText(rr++, cc, "FM7239");
|
||||||
|
table->setText(rr++, cc, "LS9736");
|
||||||
|
table->setText(rr++, cc, "D7266");
|
||||||
|
table->setText(rr++, cc, "CFD21338SPC");
|
||||||
|
table->setText(rr++, cc, "LS9737_1");
|
||||||
|
|
||||||
|
auto def = fdDecodeMode->text();
|
||||||
|
QTableWidgetItem *item;
|
||||||
|
if(! def.isEmpty()) for(int r=0; r<table->rowCount(); r++) for(int c=0; c<table->columnCount(); c++) if((item = table->item(r, c)) && item->text()==def) item->setSelected(true);
|
||||||
|
connect(table, &Table::cellDoubleClicked, &dlg, [=, &dlg](int row, int column) {
|
||||||
|
auto text = table->text(row, column);
|
||||||
|
if(text.isEmpty()) return;
|
||||||
|
fdDecodeMode->setText(text);
|
||||||
|
decodeMode = (column<<8) | row;
|
||||||
|
dlg.accept();
|
||||||
|
});
|
||||||
|
vBox->addWidget(table);
|
||||||
|
|
||||||
|
auto btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Close);
|
||||||
|
connect(btnBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject);
|
||||||
|
connect(btnBox, &QDialogButtonBox::accepted, &dlg, [&, table] {
|
||||||
|
auto items = table->selectedItems();
|
||||||
|
if(items.isEmpty()) {
|
||||||
|
QMessageBox::warning(&dlg, "Warning", "请选择译码方式");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fdDecodeMode->setText(items[0]->text());
|
||||||
|
auto ranges = table->selectedRanges();
|
||||||
|
decodeMode = (ranges[0].leftColumn()<<8) | ranges[0].topRow();
|
||||||
|
dlg.accept();
|
||||||
|
});
|
||||||
|
vBox->addWidget(btnBox);
|
||||||
|
|
||||||
|
dlg.exec();
|
||||||
|
});
|
||||||
|
hhhh->addWidget(btn);
|
||||||
|
grid->addLayout(hhhh, 1, 5);
|
||||||
|
|
||||||
|
lb = new QLabel(tr("分组方式: "));
|
||||||
|
grid->addWidget(lb, 2, 4);
|
||||||
|
|
||||||
|
fdGroupMode = new QComboBox;
|
||||||
|
fdGroupMode->addItem(tr("三线并行"));
|
||||||
|
fdGroupMode->addItem(tr("三色1点串"));
|
||||||
|
fdGroupMode->addItem(tr("三色8点串"));
|
||||||
|
fdGroupMode->addItem(tr("三色16点串"));
|
||||||
|
grid->addWidget(fdGroupMode, 2, 5);
|
||||||
|
|
||||||
|
vv->addStretch();
|
||||||
|
|
||||||
auto page = new QWidget;
|
|
||||||
stack->addWidget(page);
|
|
||||||
QPalette bkBlue;
|
|
||||||
{
|
{
|
||||||
auto vBox = new QVBoxLayout(page);
|
auto vBox = new VBox(stack);
|
||||||
vBox->setContentsMargins(50, 50, 6, 6);
|
|
||||||
|
|
||||||
auto lb = new QLabel(tr("基本参数"));
|
|
||||||
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;
|
|
||||||
|
|
||||||
lb = new QLabel(tr("模组宽度: "));
|
|
||||||
hhhh->addWidget(lb);
|
|
||||||
|
|
||||||
fdModuleWidth = new QSpinBox;
|
|
||||||
fdModuleWidth->setRange(0, 9999);
|
|
||||||
fdModuleWidth->setValue(ModuleWidth);
|
|
||||||
hhhh->addWidget(fdModuleWidth);
|
|
||||||
|
|
||||||
vvv->addLayout(hhhh);
|
|
||||||
vvv->addSpacing(30);
|
|
||||||
hhhh = new QHBoxLayout;
|
|
||||||
|
|
||||||
lb = new QLabel(tr("模组高度: "));
|
|
||||||
hhhh->addWidget(lb);
|
|
||||||
|
|
||||||
fdModuleHeight = new QSpinBox;
|
|
||||||
fdModuleHeight->setRange(0, 9999);
|
|
||||||
fdModuleHeight->setValue(ModuleHeight);
|
|
||||||
hhhh->addWidget(fdModuleHeight);
|
|
||||||
|
|
||||||
vvv->addLayout(hhhh);
|
|
||||||
vvv->addSpacing(30);
|
|
||||||
hhhh = new QHBoxLayout;
|
|
||||||
|
|
||||||
lb = new QLabel(tr("数据组数: "));
|
|
||||||
hhhh->addWidget(lb);
|
|
||||||
|
|
||||||
fdGroupNum = new QSpinBox;
|
|
||||||
fdGroupNum->setRange(0, 9999);
|
|
||||||
fdGroupNum->setValue(GroupNum);
|
|
||||||
hhhh->addWidget(fdGroupNum);
|
|
||||||
|
|
||||||
vvv->addLayout(hhhh);
|
|
||||||
vvv->addStretch();
|
|
||||||
|
|
||||||
hBox->addLayout(vvv);
|
|
||||||
}
|
|
||||||
hBox->addStretch();
|
|
||||||
{
|
|
||||||
auto vvv = new QVBoxLayout;
|
|
||||||
auto hhhh = new QHBoxLayout;
|
|
||||||
|
|
||||||
lb = new QLabel(tr("驱动芯片: "));
|
|
||||||
hhhh->addWidget(lb);
|
|
||||||
|
|
||||||
fdChipType = new QComboBox;
|
|
||||||
fdChipType->addItem("ICND2153");
|
|
||||||
hhhh->addWidget(fdChipType);
|
|
||||||
|
|
||||||
vvv->addLayout(hhhh);
|
|
||||||
vvv->addSpacing(30);
|
|
||||||
hhhh = new QHBoxLayout;
|
|
||||||
|
|
||||||
lb = new QLabel(tr("译码方式: "));
|
|
||||||
hhhh->addWidget(lb);
|
|
||||||
|
|
||||||
fdDecodeMode = new QComboBox;
|
|
||||||
fdDecodeMode->addItem(tr("138译码"));
|
|
||||||
hhhh->addWidget(fdDecodeMode);
|
|
||||||
|
|
||||||
vvv->addLayout(hhhh);
|
|
||||||
vvv->addSpacing(30);
|
|
||||||
hhhh = new QHBoxLayout;
|
|
||||||
|
|
||||||
lb = new QLabel(tr("分组方式: "));
|
|
||||||
hhhh->addWidget(lb);
|
|
||||||
|
|
||||||
fdGroupMode = new QComboBox;
|
|
||||||
fdGroupMode->addItem(tr("三线并行"));
|
|
||||||
fdGroupMode->addItem(tr("三色1点串"));
|
|
||||||
fdGroupMode->addItem(tr("三色8点串"));
|
|
||||||
fdGroupMode->addItem(tr("三色16点串"));
|
|
||||||
hhhh->addWidget(fdGroupMode);
|
|
||||||
|
|
||||||
vvv->addLayout(hhhh);
|
|
||||||
vvv->addStretch();
|
|
||||||
|
|
||||||
hBox->addLayout(vvv);
|
|
||||||
}
|
|
||||||
hBox->addStretch();
|
|
||||||
vBox->addLayout(hBox);
|
|
||||||
}
|
|
||||||
|
|
||||||
page = new QWidget;
|
|
||||||
stack->addWidget(page);
|
|
||||||
{
|
|
||||||
auto vBox = new QVBoxLayout(page);
|
|
||||||
vBox->setContentsMargins(50, 50, 6, 6);
|
vBox->setContentsMargins(50, 50, 6, 6);
|
||||||
|
|
||||||
auto lb = new QLabel(tr("扫描行数"));
|
auto lb = new QLabel(tr("扫描行数"));
|
||||||
|
gFontSize(lb, 16);
|
||||||
lb->setPalette(bkBlue);
|
lb->setPalette(bkBlue);
|
||||||
vBox->addWidget(lb);
|
vBox->addWidget(lb);
|
||||||
vBox->addSpacing(50);
|
vBox->addSpacing(50);
|
||||||
|
@ -209,14 +519,12 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e
|
||||||
vvv->addStretch();
|
vvv->addStretch();
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
}
|
}
|
||||||
|
|
||||||
page = new QWidget;
|
|
||||||
stack->addWidget(page);
|
|
||||||
{
|
{
|
||||||
auto vBox = new QVBoxLayout(page);
|
auto vBox = new VBox(stack);
|
||||||
vBox->setContentsMargins(50, 50, 6, 6);
|
vBox->setContentsMargins(50, 50, 6, 6);
|
||||||
|
|
||||||
auto lb = new QLabel(tr("数据线颜色"));
|
auto lb = new QLabel(tr("数据线颜色"));
|
||||||
|
gFontSize(lb, 16);
|
||||||
lb->setPalette(bkBlue);
|
lb->setPalette(bkBlue);
|
||||||
vBox->addWidget(lb);
|
vBox->addWidget(lb);
|
||||||
vBox->addSpacing(50);
|
vBox->addSpacing(50);
|
||||||
|
@ -304,27 +612,24 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e
|
||||||
vBox->addLayout(hhhh);
|
vBox->addLayout(hhhh);
|
||||||
vBox->addStretch();
|
vBox->addStretch();
|
||||||
|
|
||||||
auto btnGrp = new QButtonGroup(page);
|
auto btnGrp = new QButtonGroup(fdNo1);
|
||||||
btnGrp->addButton(fdR1);
|
btnGrp->addButton(fdR1);
|
||||||
btnGrp->addButton(fdG1);
|
btnGrp->addButton(fdG1);
|
||||||
btnGrp->addButton(fdB1);
|
btnGrp->addButton(fdB1);
|
||||||
btnGrp->addButton(fdNo1);
|
btnGrp->addButton(fdNo1);
|
||||||
btnGrp = new QButtonGroup(page);
|
btnGrp = new QButtonGroup(fdNo2);
|
||||||
btnGrp->addButton(fdR2);
|
btnGrp->addButton(fdR2);
|
||||||
btnGrp->addButton(fdG2);
|
btnGrp->addButton(fdG2);
|
||||||
btnGrp->addButton(fdB2);
|
btnGrp->addButton(fdB2);
|
||||||
btnGrp->addButton(fdNo2);
|
btnGrp->addButton(fdNo2);
|
||||||
btnGrp = new QButtonGroup(page);
|
btnGrp = new QButtonGroup(fdNo3);
|
||||||
btnGrp->addButton(fdR3);
|
btnGrp->addButton(fdR3);
|
||||||
btnGrp->addButton(fdG3);
|
btnGrp->addButton(fdG3);
|
||||||
btnGrp->addButton(fdB3);
|
btnGrp->addButton(fdB3);
|
||||||
btnGrp->addButton(fdNo3);
|
btnGrp->addButton(fdNo3);
|
||||||
}
|
}
|
||||||
|
|
||||||
page = new QWidget;
|
|
||||||
stack->addWidget(page);
|
|
||||||
{
|
{
|
||||||
auto vBox = new QVBoxLayout(page);
|
auto vBox = new VBox(stack);
|
||||||
vBox->setContentsMargins(0,0,0,0);
|
vBox->setContentsMargins(0,0,0,0);
|
||||||
|
|
||||||
auto hhh = new QHBoxLayout;
|
auto hhh = new QHBoxLayout;
|
||||||
|
@ -381,7 +686,7 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e
|
||||||
hhh->addStretch();
|
hhh->addStretch();
|
||||||
vBox->addLayout(hhh);
|
vBox->addLayout(hhh);
|
||||||
|
|
||||||
table = new NumTable;
|
table = new Table;
|
||||||
table->setNoEdit();
|
table->setNoEdit();
|
||||||
table->setSelectionMode(QTableWidget::SingleSelection);
|
table->setSelectionMode(QTableWidget::SingleSelection);
|
||||||
table->setColWidth(40);
|
table->setColWidth(40);
|
||||||
|
@ -418,7 +723,7 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e
|
||||||
|
|
||||||
vBox->addWidget(table);
|
vBox->addWidget(table);
|
||||||
|
|
||||||
tableRow = new NumTable(2, 0);
|
tableRow = new Table(2, 0);
|
||||||
tableRow->setNoEdit();
|
tableRow->setNoEdit();
|
||||||
tableRow->setSelectionMode(QTableWidget::NoSelection);
|
tableRow->setSelectionMode(QTableWidget::NoSelection);
|
||||||
tableRow->horizontalHeader()->setDefaultSectionSize(40);
|
tableRow->horizontalHeader()->setDefaultSectionSize(40);
|
||||||
|
@ -435,9 +740,7 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e
|
||||||
vBox->addWidget(tableRow);
|
vBox->addWidget(tableRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto hBox = new QHBoxLayout;
|
auto hBox = new HBox(vBox);
|
||||||
vBox->addLayout(hBox);
|
|
||||||
|
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
auto btnPrev = new QPushButton(tr("上一步"));
|
auto btnPrev = new QPushButton(tr("上一步"));
|
||||||
|
@ -461,9 +764,29 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e
|
||||||
ModuleHeight = fdModuleHeight->value();
|
ModuleHeight = fdModuleHeight->value();
|
||||||
GroupNum = fdGroupNum->value();
|
GroupNum = fdGroupNum->value();
|
||||||
ScanNum = (ModuleHeight + 1) / GroupNum;
|
ScanNum = (ModuleHeight + 1) / GroupNum;
|
||||||
ChipType = fdChipType->currentText();
|
ChipType = fdChipType->text();
|
||||||
DecodeMode = fdDecodeMode->currentText();
|
DecodeMode = fdDecodeMode->text();
|
||||||
GroupMode = fdGroupMode->currentText();
|
GroupMode = fdGroupMode->currentText();
|
||||||
|
// 开始标识 保留 长度 换行间/刻 OE宽 放电间 芯片通道数 模组类型数
|
||||||
|
auto msg = QByteArray::fromHex("5555 01 AD 0062 FFFFFFFF 0000ABCD B1000000 0000 415F94A7 AD000000 005C AA55AA55 0000 0036 1770 0000 0280 0000 32 10 00 00 0A 00 00 00 001000 01 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB 00000000 00000008 00400020 00001400 FF00FF00 3C000000 00000000 1B022020 00000040 55AA55AA 00000000 B4B5C0AE DEEBB684");
|
||||||
|
auto unitptr = msg.data()+headMap.end+modMap.Unit;
|
||||||
|
auto w = (quint16_be*)(unitptr+modUnitMap.w);
|
||||||
|
qDebug()<<"w"<<QString::number(*w, 16);
|
||||||
|
*w = ModuleWidth;
|
||||||
|
auto h = (quint16_be*)(unitptr+modUnitMap.h);
|
||||||
|
qDebug()<<"h"<<QString::number(*h, 16);
|
||||||
|
*h = ModuleHeight;
|
||||||
|
auto groupNum = unitptr+modUnitMap.smartset2 + 1;
|
||||||
|
qDebug()<<"groupNum"<<QString::number(*groupNum, 16);
|
||||||
|
*groupNum = GroupNum;
|
||||||
|
// auto res = sendMsg(msg, {0x1E0, 30000, [=](const QByteArray data) {
|
||||||
|
// qDebug()<<"data"<<data;
|
||||||
|
|
||||||
|
// }});
|
||||||
|
// if(res) {
|
||||||
|
// QMessageBox::critical(this, "Error", QString(tr("发送失败: "))+pcap_geterr(pcapSend));
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
} else if(idx==2) {
|
} else if(idx==2) {
|
||||||
table->setColumnCount(ModuleWidth);
|
table->setColumnCount(ModuleWidth);
|
||||||
table->setRowCount(ModuleHeight);
|
table->setRowCount(ModuleHeight);
|
||||||
|
|
|
@ -14,12 +14,14 @@ public:
|
||||||
|
|
||||||
ExpertWin *expertWin;
|
ExpertWin *expertWin;
|
||||||
|
|
||||||
NumTable *table, *tableRow;
|
Table *table, *tableRow;
|
||||||
int virtualCnt = 0;
|
int virtualCnt = 0;
|
||||||
QList<QPoint> scans;
|
QList<QPoint> scans;
|
||||||
|
|
||||||
QSpinBox *fdModuleWidth, *fdModuleHeight, *fdGroupNum;
|
QSpinBox *fdModuleWidth, *fdModuleHeight, *fdGroupNum;
|
||||||
QComboBox *fdChipType, *fdDecodeMode, *fdGroupMode;
|
QLineEdit *fdChipType, *fdDecodeMode;
|
||||||
|
int chipType, decodeMode;
|
||||||
|
QComboBox *fdGroupMode;
|
||||||
int ModuleWidth{16}, ModuleHeight{8}, GroupNum{2}, ScanNum{4};
|
int ModuleWidth{16}, ModuleHeight{8}, GroupNum{2}, ScanNum{4};
|
||||||
QString ChipType, DecodeMode, GroupMode;
|
QString ChipType, DecodeMode, GroupMode;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
#include "globalfunc.h"
|
#include "globalfunc.h"
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
#include "basewin.h"
|
|
||||||
#define HAVE_REMOTE
|
#define HAVE_REMOTE
|
||||||
#include "pcap.h"
|
#include "pcap.h"
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
|
||||||
|
HeadMap headMap;
|
||||||
pcap_t *pcapSend{0};
|
pcap_t *pcapSend{0};
|
||||||
PcapReThread *reThd{0};
|
PcapReThread *reThd{0};
|
||||||
|
|
||||||
|
@ -17,13 +18,13 @@ QByteArray getNetDev(QWidget *parent, QByteArray def, bool justReturnIfHave) {
|
||||||
return QByteArray();
|
return QByteArray();
|
||||||
}
|
}
|
||||||
auto table = new Table{
|
auto table = new Table{
|
||||||
{"name", "网卡名称", 400},
|
{"name", "网卡名称"},
|
||||||
{"desc", "网卡描述", 300},
|
{"desc", "网卡描述"},
|
||||||
{"loopback","Loopback"},
|
{"loopback", "Loopback"},
|
||||||
{"ip","IP"},
|
{"ip", "IP"},
|
||||||
{"netmask","Netmask"},
|
{"netmask", "Netmask"},
|
||||||
{"broadaddr","Broad Addr"},
|
{"broadaddr", "Broad Addr"},
|
||||||
{"dstaddr","Dst Addr"}
|
{"dstaddr", "Dst Addr"}
|
||||||
};
|
};
|
||||||
|
|
||||||
pcap_if_t *device = 0;
|
pcap_if_t *device = 0;
|
||||||
|
@ -71,12 +72,12 @@ QByteArray getNetDev(QWidget *parent, QByteArray def, bool justReturnIfHave) {
|
||||||
table->deleteLater();
|
table->deleteLater();
|
||||||
return table->item(0, "name")->text().toLocal8Bit();
|
return table->item(0, "name")->text().toLocal8Bit();
|
||||||
} else {
|
} else {
|
||||||
auto dlg = new BaseDlg(parent);
|
QDialog dlg(parent);
|
||||||
dlg->setAttribute(Qt::WA_DeleteOnClose);
|
dlg.setWindowFlag(Qt::WindowMaximizeButtonHint);
|
||||||
dlg->setWindowTitle("选择网卡");
|
dlg.setWindowTitle("选择网卡");
|
||||||
dlg->resize(900, 300);
|
dlg.resize(900, 300);
|
||||||
|
|
||||||
auto vBox = new QVBoxLayout(dlg->center);
|
auto vBox = new QVBoxLayout(&dlg);
|
||||||
vBox->setContentsMargins(0,0,0,0);
|
vBox->setContentsMargins(0,0,0,0);
|
||||||
vBox->setSpacing(3);
|
vBox->setSpacing(3);
|
||||||
vBox->addSpacing(30);
|
vBox->addSpacing(30);
|
||||||
|
@ -86,47 +87,27 @@ QByteArray getNetDev(QWidget *parent, QByteArray def, bool justReturnIfHave) {
|
||||||
table->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
table->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||||
if(! def.isEmpty()) for(int r=0; r<table->rowCount(); r++) if(table->item(r, "name")->text()==def) table->selectRow(r);
|
if(! def.isEmpty()) for(int r=0; r<table->rowCount(); r++) if(table->item(r, "name")->text()==def) table->selectRow(r);
|
||||||
QByteArray name;
|
QByteArray name;
|
||||||
dlg->connect(table, &Table::cellDoubleClicked, dlg, [dlg, table, &name](int row) {
|
QObject::connect(table, &Table::cellDoubleClicked, &dlg, [&, table](int row) {
|
||||||
name = table->item(row, "name")->text().toLocal8Bit();
|
name = table->item(row, "name")->text().toLocal8Bit();
|
||||||
dlg->accept();
|
dlg.accept();
|
||||||
});
|
});
|
||||||
vBox->addWidget(table);
|
vBox->addWidget(table);
|
||||||
|
|
||||||
auto hBox = new QHBoxLayout;
|
|
||||||
hBox->addStretch();
|
auto btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Close);
|
||||||
auto btnOk = new QPushButton("确定");
|
QObject::connect(btnBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject);
|
||||||
btnOk->setMinimumWidth(80);
|
QObject::connect(btnBox, &QDialogButtonBox::accepted, &dlg, [&, table] {
|
||||||
dlg->connect(btnOk, &QPushButton::clicked, dlg, [dlg, table, &name] {
|
|
||||||
auto sels = table->selectedRanges();
|
auto sels = table->selectedRanges();
|
||||||
if(sels.isEmpty()) {
|
if(sels.isEmpty()) {
|
||||||
QMessageBox::warning(dlg, "Warning", "请选择网卡");
|
QMessageBox::warning(&dlg, "Warning", "请选择网卡");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
name = table->item(sels[0].topRow(), "name")->text().toLocal8Bit();
|
name = table->item(sels[0].topRow(), "name")->text().toLocal8Bit();
|
||||||
dlg->accept();
|
dlg.accept();
|
||||||
});
|
});
|
||||||
hBox->addWidget(btnOk);
|
vBox->addWidget(btnBox);
|
||||||
|
|
||||||
hBox->addStretch();
|
dlg.exec();
|
||||||
|
|
||||||
auto btnClose = new QPushButton("关闭");
|
|
||||||
btnClose->setMinimumWidth(80);
|
|
||||||
dlg->connect(btnClose, &QPushButton::clicked, dlg, &QDialog::reject);
|
|
||||||
hBox->addWidget(btnClose);
|
|
||||||
hBox->addStretch();
|
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
|
||||||
dlg->exec();
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int sendMsg(QByteArray msg, const Resp &resp) {
|
|
||||||
return sendMsgNet(msg, resp);
|
|
||||||
}
|
|
||||||
|
|
||||||
int sendMsgNet(QByteArray msg, const Resp &resp) {
|
|
||||||
reThd->addResp(resp);
|
|
||||||
return pcap_sendpacket(pcapSend, (u_char*)msg.data(), msg.size());
|
|
||||||
}
|
|
||||||
|
|
|
@ -2,17 +2,64 @@
|
||||||
#define GLOBALFUNC_H
|
#define GLOBALFUNC_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QByteArray>
|
#include <QtEndian>
|
||||||
|
|
||||||
#include "pcaprethread.h"
|
#include "pcaprethread.h"
|
||||||
|
|
||||||
|
struct Head {
|
||||||
|
byte pre[2]{0x55, 0x55};
|
||||||
|
byte ver{1};
|
||||||
|
byte srv{0};
|
||||||
|
quint16_be len{0};
|
||||||
|
byte tgtAddr[4]{0xff, 0xff, 0xff, 0xff};
|
||||||
|
byte srcAddr[4]{0, 0, 0, 0};
|
||||||
|
byte ptr[4]{0, 0, 0, 0};
|
||||||
|
byte ans[2]{0, 0};
|
||||||
|
quint32_be chk{0};
|
||||||
|
byte bodyh[4]{0, 0, 0, 0};
|
||||||
|
quint16_be bodylen{0};
|
||||||
|
};
|
||||||
|
struct Msg1024 : Head {
|
||||||
|
byte body[1024-sizeof(Head)]{0};
|
||||||
|
};
|
||||||
|
static byte fi = 0;
|
||||||
|
inline byte ie(byte size = 1) {
|
||||||
|
fi = size;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
inline byte ipp(byte size = 1) {
|
||||||
|
auto rtn = fi;
|
||||||
|
fi += size;
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
|
struct HeadMap {
|
||||||
|
byte pre{ipp(2)};
|
||||||
|
byte ver{fi++};
|
||||||
|
byte srv{fi++};
|
||||||
|
byte len{ipp(2)};
|
||||||
|
byte tgtAddr{ipp(4)};
|
||||||
|
byte srcAddr{ipp(4)};
|
||||||
|
byte ptr{ipp(4)};
|
||||||
|
byte ans{ipp(2)};
|
||||||
|
byte chk{ipp(4)};
|
||||||
|
byte body{ipp(4)};
|
||||||
|
byte bodylen{ipp(2)};
|
||||||
|
byte end{fi};
|
||||||
|
};
|
||||||
|
extern HeadMap headMap;
|
||||||
extern pcap_t *pcapSend;
|
extern pcap_t *pcapSend;
|
||||||
extern PcapReThread *reThd;
|
extern PcapReThread *reThd;
|
||||||
|
|
||||||
|
|
||||||
QByteArray getNetDev(QWidget *parent, QByteArray, bool);
|
QByteArray getNetDev(QWidget *parent, QByteArray, bool);
|
||||||
|
|
||||||
int sendMsg(QByteArray, const Resp &resp);
|
inline int sendMsgNet(const byte *msg, int size, const Resp &resp) {
|
||||||
int sendMsgNet(QByteArray, const Resp &resp);
|
reThd->addResp(resp);
|
||||||
|
return pcap_sendpacket(pcapSend, msg, size);
|
||||||
|
}
|
||||||
|
inline int sendMsg(const byte *msg, int size, const Resp &resp) {
|
||||||
|
return sendMsgNet(msg, size, resp);
|
||||||
|
}
|
||||||
|
inline int sendMsg(QByteArray &msg, const Resp &resp) {
|
||||||
|
return sendMsg((byte*)msg.data(), msg.size(), resp);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // GLOBALFUNC_H
|
#endif // GLOBALFUNC_H
|
||||||
|
|
|
@ -1,33 +1,39 @@
|
||||||
#include "qgui.h"
|
#include "qgui.h"
|
||||||
|
#include <QResizeEvent>
|
||||||
|
|
||||||
const int AlignRight = Qt::AlignRight | Qt::AlignVCenter;
|
const int AlignRight = Qt::AlignRight | Qt::AlignVCenter;
|
||||||
|
|
||||||
Table::Table(std::initializer_list<ColAttr> colAttrs, int rows, QWidget *parent) : NumTable{rows, (int)colAttrs.size(), parent} {
|
Table::Table(std::initializer_list<ColAttr> colAttrs, int rows, QWidget *parent) : QTableWidget{rows, (int)colAttrs.size(), parent} {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(typename std::initializer_list<ColAttr>::const_iterator it = colAttrs.begin(); it != colAttrs.end(); ++it) {
|
for(typename std::initializer_list<ColAttr>::const_iterator it = colAttrs.begin(); it != colAttrs.end(); ++it) {
|
||||||
auto item = horizontalHeaderItem(i);
|
auto item = horizontalHeaderItem(i);
|
||||||
if(item==0) setHorizontalHeaderItem(i, item = new QTableWidgetItem());
|
if(item==0) setHorizontalHeaderItem(i, item = new QTableWidgetItem());
|
||||||
item->setText(it->text);
|
item->setText(it->text);
|
||||||
item->setData(0x99, it->width);
|
|
||||||
if(it->width > 0) horizontalHeader()->resizeSection(i, it->width);
|
if(it->width > 0) horizontalHeader()->resizeSection(i, it->width);
|
||||||
if(it->resizeMode > -1) horizontalHeader()->setSectionResizeMode(i, (QHeaderView::ResizeMode)it->resizeMode);
|
if(it->resizeMode != QHeaderView::Interactive) {
|
||||||
|
if(it->resizeMode==QHeaderView::Stretch && it->width>0) {
|
||||||
|
item->setData(0x99, it->width > 0 ? it->width : 100);
|
||||||
|
noStretch = false;
|
||||||
|
} else horizontalHeader()->setSectionResizeMode(i, (QHeaderView::ResizeMode)it->resizeMode);
|
||||||
|
}
|
||||||
mFieldMap.insert(it->field, i++);
|
mFieldMap.insert(it->field, i++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Table::sizeHintForColumn(int column) const {
|
void Table::resizeEvent(QResizeEvent *event) {
|
||||||
auto item = horizontalHeaderItem(column);
|
QTableWidget::resizeEvent(event);
|
||||||
if(item==0) return QTableWidget::sizeHintForColumn(column);
|
if(noStretch || event->size().width() == event->oldSize().width()) return;
|
||||||
int width = item->data(0x99).toInt();
|
resizeSec();
|
||||||
if(width==0) return QTableWidget::sizeHintForColumn(column);
|
}
|
||||||
auto header = horizontalHeader();
|
|
||||||
if(header->sectionResizeMode(column) != QHeaderView::ResizeToContents) return QTableWidget::sizeHintForColumn(column);
|
void Table::resizeSec() {
|
||||||
int colCnt = columnCount();
|
auto header = horizontalHeader();
|
||||||
int remainWidth = header->width(), stretchWidth = width;
|
int colCnt = columnCount(), remainWidth = header->width(), stretchWidth = 0, secWidth;
|
||||||
for(int cc=0; cc<colCnt; cc++) if(cc!=column && (item = horizontalHeaderItem(cc))) {
|
QTableWidgetItem *item;
|
||||||
if(header->sectionResizeMode(cc) == QHeaderView::ResizeToContents) stretchWidth += item->data(0x99).toInt();
|
for(int cc=0; cc<colCnt; cc++) if((item = horizontalHeaderItem(cc))) {
|
||||||
else remainWidth -= item->data(0x99).toInt();
|
if((secWidth = item->data(0x99).toInt()) > 0) stretchWidth += secWidth;
|
||||||
}
|
else remainWidth -= header->sectionSize(cc);
|
||||||
if(remainWidth<=0) return QTableWidget::sizeHintForColumn(column);
|
}
|
||||||
return width * remainWidth / stretchWidth;
|
if(remainWidth<=0 || stretchWidth==0) return;
|
||||||
|
for(int cc=0; cc<colCnt; cc++) if((item = horizontalHeaderItem(cc)) && (secWidth = item->data(0x99).toInt()) > 0) header->resizeSection(cc, secWidth * remainWidth / stretchWidth);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,20 @@
|
||||||
|
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QStackedLayout>
|
#include <QStackedLayout>
|
||||||
|
#include <QListWidget>
|
||||||
#include <QTableWidget>
|
#include <QTableWidget>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
|
#define MainMust \
|
||||||
|
#if(QT_VERSION_MAJOR > 5) \
|
||||||
|
QImageReader::setAllocationLimit(0);\
|
||||||
|
#else\
|
||||||
|
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);\
|
||||||
|
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);\
|
||||||
|
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);\
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
extern const int AlignRight;
|
extern const int AlignRight;
|
||||||
|
|
||||||
|
@ -13,6 +25,11 @@ inline int setCurrentData(QComboBox *combo, const QVariant &data) {
|
||||||
if(idx>-1) combo->setCurrentIndex(idx);
|
if(idx>-1) combo->setCurrentIndex(idx);
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
inline void gFontSize(QWidget *wgt, int size) {
|
||||||
|
auto ft = wgt->font();
|
||||||
|
ft.setPixelSize(size);
|
||||||
|
wgt->setFont(ft);
|
||||||
|
}
|
||||||
|
|
||||||
class VBox : public QBoxLayout {
|
class VBox : public QBoxLayout {
|
||||||
public:
|
public:
|
||||||
|
@ -26,6 +43,11 @@ public:
|
||||||
wgt->setLayout(this);
|
wgt->setLayout(this);
|
||||||
parent->addWidget(wgt);
|
parent->addWidget(wgt);
|
||||||
};
|
};
|
||||||
|
inline QLabel *addLabel(const QString &text) {
|
||||||
|
auto lb = new QLabel(text);
|
||||||
|
addWidget(lb);
|
||||||
|
return lb;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
class HBox : public QBoxLayout {
|
class HBox : public QBoxLayout {
|
||||||
public:
|
public:
|
||||||
|
@ -39,10 +61,15 @@ public:
|
||||||
wgt->setLayout(this);
|
wgt->setLayout(this);
|
||||||
parent->addWidget(wgt);
|
parent->addWidget(wgt);
|
||||||
};
|
};
|
||||||
|
inline QLabel *addLabel(const QString &text) {
|
||||||
|
auto lb = new QLabel(text);
|
||||||
|
addWidget(lb);
|
||||||
|
return lb;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
class Grid : public QGridLayout {
|
class Grid : public QGridLayout {
|
||||||
public:
|
public:
|
||||||
inline Grid(QWidget *parent=0) : QGridLayout(parent) {}
|
using QGridLayout::QGridLayout;
|
||||||
inline Grid(QBoxLayout *parent) {
|
inline Grid(QBoxLayout *parent) {
|
||||||
parent->addLayout(this);
|
parent->addLayout(this);
|
||||||
};
|
};
|
||||||
|
@ -53,74 +80,46 @@ public:
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
class NumTable : public QTableWidget {
|
inline QFont qfont(const QString &family, int pixelSize, bool bold = false, bool italic = false) {
|
||||||
|
QFont font(family);
|
||||||
|
font.setPixelSize(pixelSize);
|
||||||
|
if(bold) font.setBold(true);
|
||||||
|
if(italic) font.setItalic(true);
|
||||||
|
return font;
|
||||||
|
}
|
||||||
|
|
||||||
|
class ListWgt : public QListWidget {
|
||||||
|
public:
|
||||||
|
using QListWidget::QListWidget;
|
||||||
|
|
||||||
|
using QListWidget::addItem;
|
||||||
|
inline auto addItem(const QString &text, const QVariant &value) {
|
||||||
|
auto item = new QListWidgetItem(text);
|
||||||
|
item->setData(Qt::UserRole, value);
|
||||||
|
insertItem(count(), item);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ColAttr {
|
||||||
|
ColAttr(QString field, QString text, int width=0, QHeaderView::ResizeMode resizeMode = QHeaderView::Interactive) : field(field), text(text), width(width), resizeMode(resizeMode) {}
|
||||||
|
ColAttr(QString field, QString text, QHeaderView::ResizeMode resizeMode) : field(field), text(text), resizeMode(resizeMode) {}
|
||||||
|
QString field;
|
||||||
|
QString text;
|
||||||
|
int width{0};
|
||||||
|
QHeaderView::ResizeMode resizeMode;
|
||||||
|
};
|
||||||
|
class Table : public QTableWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit NumTable(QWidget *parent = 0) : QTableWidget{parent} {}
|
using QTableWidget::QTableWidget;
|
||||||
NumTable(int rows, int columns, QWidget *parent = 0) : QTableWidget{rows, columns, parent} {}
|
Table() {}
|
||||||
|
Table(std::initializer_list<ColAttr> colAttrs, int rows = 0, QWidget *parent = 0);
|
||||||
|
|
||||||
inline auto setNoEdit() {
|
inline auto setNoEdit() {
|
||||||
setEditTriggers(QAbstractItemView::NoEditTriggers);
|
setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
inline auto setColWidth(int value) {
|
|
||||||
horizontalHeader()->setDefaultSectionSize(value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
inline auto setRowHeight(int value) {
|
|
||||||
verticalHeader()->setDefaultSectionSize(value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline auto setHeaderText(int column, QString text) {
|
|
||||||
auto item = horizontalHeaderItem(column);
|
|
||||||
if(item==0) setHorizontalHeaderItem(column, item = new QTableWidgetItem());
|
|
||||||
item->setText(text);
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline auto itemValid(int row, int column) {
|
|
||||||
auto item = QTableWidget::item(row, column);
|
|
||||||
if(item==0) setItem(row, column, item = new QTableWidgetItem);
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
inline auto text(int row, int column) {
|
|
||||||
auto item = QTableWidget::item(row, column);
|
|
||||||
if(item==0) return QString();
|
|
||||||
return item->text();
|
|
||||||
}
|
|
||||||
inline auto setText(int row, int column, const QString &text) {
|
|
||||||
auto item = QTableWidget::item(row, column);
|
|
||||||
if(item) item->setText(text);
|
|
||||||
else setItem(row, column, item = new QTableWidgetItem(text));
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline auto data(int row, int col) {
|
|
||||||
auto item = QTableWidget::item(row, col);
|
|
||||||
if(item==0) return QVariant();
|
|
||||||
return item->data(Qt::UserRole);
|
|
||||||
}
|
|
||||||
inline auto setData(int row, int col, const QVariant &value) {
|
|
||||||
auto item = QTableWidget::item(row, col);
|
|
||||||
if(item==0) setItem(row, col, item = new QTableWidgetItem);
|
|
||||||
item->setData(Qt::UserRole, value);
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ColAttr {
|
|
||||||
QString field;
|
|
||||||
QString text;
|
|
||||||
int width{0};
|
|
||||||
int resizeMode{-1};
|
|
||||||
};
|
|
||||||
class Table : public NumTable {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit Table(QWidget *parent = nullptr) : NumTable{parent} {}
|
|
||||||
Table(std::initializer_list<ColAttr> colAttrs, int rows = 0, QWidget *parent = nullptr);
|
|
||||||
|
|
||||||
inline auto setDefs() {
|
inline auto setDefs() {
|
||||||
setSelectionBehavior(QTableWidget::SelectRows);
|
setSelectionBehavior(QTableWidget::SelectRows);
|
||||||
setEditTriggers(QAbstractItemView::NoEditTriggers);
|
setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||||
|
@ -152,13 +151,16 @@ public:
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline auto setHeaderText(QString column, QString text) {
|
inline auto setHeaderText(int col, QString text) {
|
||||||
auto col = mFieldMap[column];
|
|
||||||
auto item = horizontalHeaderItem(col);
|
auto item = horizontalHeaderItem(col);
|
||||||
if(item==0) setHorizontalHeaderItem(col, item = new QTableWidgetItem());
|
if(item==0) setHorizontalHeaderItem(col, item = new QTableWidgetItem());
|
||||||
item->setText(text);
|
item->setText(text);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
inline auto setHeaderText(QString column, QString text) {
|
||||||
|
auto col = mFieldMap[column];
|
||||||
|
return setHeaderText(col, text);
|
||||||
|
}
|
||||||
|
|
||||||
inline auto appendRow() {
|
inline auto appendRow() {
|
||||||
auto value = rowCount();
|
auto value = rowCount();
|
||||||
|
@ -166,64 +168,93 @@ public:
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using QTableWidget::item;
|
||||||
inline auto item(int row, QString column) {
|
inline auto item(int row, QString column) {
|
||||||
auto col = mFieldMap[column];
|
auto col = mFieldMap[column];
|
||||||
return QTableWidget::item(row, col);
|
return item(row, col);
|
||||||
}
|
}
|
||||||
|
inline auto itemValid(int row, int col) {
|
||||||
|
auto anitem = item(row, col);
|
||||||
|
if(anitem==0) setItem(row, col, anitem = new QTableWidgetItem);
|
||||||
|
return anitem;
|
||||||
|
}
|
||||||
|
inline auto itemValid(int row, QString column) {
|
||||||
|
auto col = mFieldMap[column];
|
||||||
|
return itemValid(row, col);
|
||||||
|
}
|
||||||
|
using QTableWidget::setItem;
|
||||||
inline void setItem(int row, QString column, QTableWidgetItem *item) {
|
inline void setItem(int row, QString column, QTableWidgetItem *item) {
|
||||||
auto col = mFieldMap[column];
|
auto col = mFieldMap[column];
|
||||||
QTableWidget::setItem(row, col, item);
|
setItem(row, col, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline auto text(int row, int col) {
|
||||||
|
auto itm = item(row, col);
|
||||||
|
if(itm==0) return QString();
|
||||||
|
return itm->text();
|
||||||
}
|
}
|
||||||
inline auto text(int row, QString column) {
|
inline auto text(int row, QString column) {
|
||||||
auto col = mFieldMap[column];
|
auto col = mFieldMap[column];
|
||||||
auto item = QTableWidget::item(row, col);
|
return text(row, col);
|
||||||
if(item==0) return QString();
|
}
|
||||||
return item->text();
|
|
||||||
|
inline auto setText(int row, int col, const QString &text) {
|
||||||
|
auto itm = item(row, col);
|
||||||
|
if(itm) itm->setText(text);
|
||||||
|
else setItem(row, col, itm = new QTableWidgetItem(text));
|
||||||
|
return itm;
|
||||||
}
|
}
|
||||||
inline auto setText(int row, QString column, const QString &text) {
|
inline auto setText(int row, QString column, const QString &text) {
|
||||||
auto col = mFieldMap[column];
|
auto col = mFieldMap[column];
|
||||||
auto item = QTableWidget::item(row, col);
|
return setText(row, col, text);
|
||||||
if(item) item->setText(text);
|
|
||||||
else QTableWidget::setItem(row, col, item = new QTableWidgetItem(text));
|
|
||||||
return item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline auto data(int row, int col) {
|
||||||
|
auto itm = item(row, col);
|
||||||
|
if(itm==0) return QVariant();
|
||||||
|
return itm->data(Qt::UserRole);
|
||||||
|
}
|
||||||
inline auto data(int row, QString column) {
|
inline auto data(int row, QString column) {
|
||||||
auto col = mFieldMap[column];
|
auto col = mFieldMap[column];
|
||||||
auto item = QTableWidget::item(row, col);
|
return data(row, col);
|
||||||
if(item==0) return QVariant();
|
}
|
||||||
return item->data(Qt::UserRole);
|
|
||||||
|
inline auto setData(int row, int col, const QVariant &value) {
|
||||||
|
auto itm = item(row, col);
|
||||||
|
if(itm==0) setItem(row, col, itm = new QTableWidgetItem);
|
||||||
|
itm->setData(Qt::UserRole, value);
|
||||||
|
return itm;
|
||||||
}
|
}
|
||||||
inline auto setData(int row, QString column, const QVariant &value) {
|
inline auto setData(int row, QString column, const QVariant &value) {
|
||||||
auto col = mFieldMap[column];
|
auto col = mFieldMap[column];
|
||||||
auto item = QTableWidget::item(row, col);
|
return setData(row, col, value);
|
||||||
if(item==0) QTableWidget::setItem(row, col, item = new QTableWidgetItem);
|
|
||||||
item->setData(Qt::UserRole, value);
|
|
||||||
return item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using QTableWidget::cellWidget;
|
||||||
inline auto cellWidget(int row, QString column) {
|
inline auto cellWidget(int row, QString column) {
|
||||||
auto col = mFieldMap[column];
|
auto col = mFieldMap[column];
|
||||||
return QTableWidget::cellWidget(row, col);
|
return cellWidget(row, col);
|
||||||
}
|
}
|
||||||
|
using QTableWidget::setCellWidget;
|
||||||
inline void setCellWidget(int row, QString column, QWidget *widget) {
|
inline void setCellWidget(int row, QString column, QWidget *widget) {
|
||||||
auto col = mFieldMap[column];
|
auto col = mFieldMap[column];
|
||||||
QTableWidget::setCellWidget(row, col, widget);
|
setCellWidget(row, col, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QString,int> mFieldMap;
|
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
inline void clearRows() {setRowCount(0);}
|
inline void clearRows() {setRowCount(0);}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int sizeHintForColumn(int column) const override;
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
|
void resizeSec();
|
||||||
|
QMap<QString,int> mFieldMap;
|
||||||
|
bool noStretch{true};
|
||||||
};
|
};
|
||||||
|
|
||||||
class ResizeEmitedWgt : public QWidget {
|
class ResizeEmitedWgt : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ResizeEmitedWgt(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()) : QWidget{parent, f} {}
|
using QWidget::QWidget;
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *) override {emit resized();}
|
void resizeEvent(QResizeEvent *) override {emit resized();}
|
||||||
signals:
|
signals:
|
||||||
|
@ -260,8 +291,8 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
inline Wrp& font(int size){
|
inline Wrp& font(int size){
|
||||||
QFont font = obj->font();
|
auto font = obj->font();
|
||||||
font.setPointSize(size);
|
font.setPixelSize(size);
|
||||||
obj->setFont(font);
|
obj->setFont(font);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
QT += core gui
|
QT += core gui widgets
|
||||||
QT += network
|
QT += network
|
||||||
QT += widgets
|
|
||||||
|
|
||||||
CONFIG += c++11
|
CONFIG += c++17
|
||||||
CONFIG += lrelease
|
CONFIG += lrelease
|
||||||
CONFIG += embed_translations
|
CONFIG += embed_translations
|
||||||
|
|
||||||
|
@ -18,18 +17,22 @@ LIBS += -L$$PWD/WpdPack_4_1_2/Lib/\
|
||||||
-lWs2_32
|
-lWs2_32
|
||||||
|
|
||||||
msvc {
|
msvc {
|
||||||
|
contains(QT_ARCH, i386) {
|
||||||
|
QMAKE_LFLAGS += /LARGEADDRESSAWARE
|
||||||
|
}
|
||||||
QMAKE_CXXFLAGS += -execution-charset:utf-8
|
QMAKE_CXXFLAGS += -execution-charset:utf-8
|
||||||
QMAKE_CXXFLAGS += -source-charset:utf-8
|
QMAKE_CXXFLAGS += -source-charset:utf-8
|
||||||
|
|
||||||
CONFIG += force_debug_info
|
CONFIG += force_debug_info
|
||||||
CONFIG += separate_debug_info
|
CONFIG += separate_debug_info
|
||||||
}
|
}
|
||||||
win* {
|
|
||||||
LIBS += -lDbghelp
|
|
||||||
}
|
|
||||||
win32 {
|
win32 {
|
||||||
QMAKE_LFLAGS += /LARGEADDRESSAWARE
|
CONFIG -= debug_and_release
|
||||||
|
LIBS += -lDbghelp
|
||||||
|
|
||||||
|
RC_ICONS = 128.ico
|
||||||
}
|
}
|
||||||
|
RESOURCES += res.qrc
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
basewin.cpp \
|
basewin.cpp \
|
||||||
|
@ -77,10 +80,7 @@ EXTRA_TRANSLATIONS += \
|
||||||
translations/qt_ja.ts \
|
translations/qt_ja.ts \
|
||||||
translations/qt_en.ts
|
translations/qt_en.ts
|
||||||
|
|
||||||
RESOURCES += \
|
|
||||||
res.qrc
|
|
||||||
|
|
||||||
RC_ICONS = 128.ico
|
|
||||||
|
|
||||||
# Default rules for deployment.
|
# Default rules for deployment.
|
||||||
qnx: target.path = /tmp/$${TARGET}/bin
|
qnx: target.path = /tmp/$${TARGET}/bin
|
||||||
|
|
|
@ -6,14 +6,15 @@
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QStyleFactory>
|
#include <QStyleFactory>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
#ifdef _MSC_VER //MSVC编译器
|
#ifdef _MSC_VER //MSVC编译器
|
||||||
#define _WINSOCKAPI_
|
#define _WINSOCKAPI_
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <DbgHelp.h>
|
#include <DbgHelp.h>
|
||||||
#if _MSC_VER >= 1600
|
// #if _MSC_VER >= 1600
|
||||||
#pragma execution_character_set("utf-8")
|
// #pragma execution_character_set("utf-8")
|
||||||
#endif
|
// #endif
|
||||||
LONG WINAPI handleException(_EXCEPTION_POINTERS *excep) {
|
LONG WINAPI handleException(_EXCEPTION_POINTERS *excep) {
|
||||||
QString errCode = QString::number(excep->ExceptionRecord->ExceptionCode, 16);
|
QString errCode = QString::number(excep->ExceptionRecord->ExceptionCode, 16);
|
||||||
QString errAddr = QString::number((uint)excep->ExceptionRecord->ExceptionAddress, 16);
|
QString errAddr = QString::number((uint)excep->ExceptionRecord->ExceptionAddress, 16);
|
||||||
|
@ -29,9 +30,13 @@ LONG WINAPI handleException(_EXCEPTION_POINTERS *excep) {
|
||||||
#endif
|
#endif
|
||||||
void test();
|
void test();
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
qputenv("QT_QPA_PLATFORM", "windows:darkmode=2");
|
||||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||||
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||||
|
QApplication::setOrganizationName("Shanghai Xixun Electronic Technology");
|
||||||
|
QApplication::setOrganizationDomain("www.ledok.cn");
|
||||||
|
QApplication::setApplicationName("LedSet Express");
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
a.setStyle(QStyleFactory::create("Fusion"));
|
a.setStyle(QStyleFactory::create("Fusion"));
|
||||||
a.setWindowIcon(QIcon(":/128.ico"));
|
a.setWindowIcon(QIcon(":/128.ico"));
|
||||||
|
@ -42,9 +47,6 @@ QTableView {gridline-color:#777;}
|
||||||
|
|
||||||
QMessageBox {background: #333;}
|
QMessageBox {background: #333;}
|
||||||
|
|
||||||
QGroupBox {border: 1px solid #777; border-radius: 3px; margin-top: 0.5em; padding-top: 0.4em;}
|
|
||||||
QGroupBox::title {color: #fff; subcontrol-origin: margin; left: 0.5em;}
|
|
||||||
|
|
||||||
QRadioButton::indicator {border-image: url(:/imgs/radio-un.png); width: 1em; height: 1em;}
|
QRadioButton::indicator {border-image: url(:/imgs/radio-un.png); width: 1em; height: 1em;}
|
||||||
QRadioButton::indicator:checked {border-image: url(:/imgs/radio-check.png);}
|
QRadioButton::indicator:checked {border-image: url(:/imgs/radio-check.png);}
|
||||||
QCheckBox::indicator {border-image: url(:/imgs/checkbox-un.png); width: 1em; height: 1em;}
|
QCheckBox::indicator {border-image: url(:/imgs/checkbox-un.png); width: 1em; height: 1em;}
|
||||||
|
@ -53,13 +55,16 @@ QCheckBox::indicator:checked {border-image: url(:/imgs/checkbox-check.png);}
|
||||||
QPushButton[ss="min"]{padding: 0; width: 30px; height: 25px; }
|
QPushButton[ss="min"]{padding: 0; width: 30px; height: 25px; }
|
||||||
QPushButton[ss="close"]{padding: 0; width: 30px; height: 25px; }
|
QPushButton[ss="close"]{padding: 0; width: 30px; height: 25px; }
|
||||||
|
|
||||||
QPushButton[ss="blue"] {background: #069;}
|
QPushButton[ss="blue"] {background: #059;}
|
||||||
|
|
||||||
|
QGroupBox {border: 1px solid #777; border-radius: 3px; margin-top: 0.5em; padding-top: 0.4em;}
|
||||||
|
QGroupBox::title {color: #fff; subcontrol-origin: margin; left: 0.5em;}
|
||||||
)rrr");
|
)rrr");
|
||||||
/*
|
/*
|
||||||
*/
|
*/
|
||||||
QFont font;
|
QFont font;
|
||||||
font.setFamilies(QStringList{"Arial","Microsoft YaHei UI"});
|
font.setFamilies(QStringList{"Arial","Microsoft YaHei UI"});
|
||||||
font.setPixelSize(14);
|
//font.setPixelSize(14);
|
||||||
a.setFont(font);
|
a.setFont(font);
|
||||||
QPalette plt = a.palette();
|
QPalette plt = a.palette();
|
||||||
plt.setBrush(QPalette::Window, QColor(0x333333));
|
plt.setBrush(QPalette::Window, QColor(0x333333));
|
||||||
|
@ -68,7 +73,7 @@ QPushButton[ss="blue"] {background: #069;}
|
||||||
plt.setBrush(QPalette::AlternateBase, QColor(0x333333));
|
plt.setBrush(QPalette::AlternateBase, QColor(0x333333));
|
||||||
plt.setBrush(QPalette::Text, QColor(0xffffff));
|
plt.setBrush(QPalette::Text, QColor(0xffffff));
|
||||||
plt.setBrush(QPalette::PlaceholderText, QColor(0xaaaaaa));
|
plt.setBrush(QPalette::PlaceholderText, QColor(0xaaaaaa));
|
||||||
plt.setBrush(QPalette::Button, QColor(0x555555));
|
plt.setBrush(QPalette::Button, QColor(0x444444));
|
||||||
plt.setBrush(QPalette::ButtonText, QColor(0xffffff));
|
plt.setBrush(QPalette::ButtonText, QColor(0xffffff));
|
||||||
plt.setBrush(QPalette::ToolTipBase, QColor(0x444466));
|
plt.setBrush(QPalette::ToolTipBase, QColor(0x444466));
|
||||||
plt.setBrush(QPalette::ToolTipText, QColor(0xeeeeee));
|
plt.setBrush(QPalette::ToolTipText, QColor(0xeeeeee));
|
||||||
|
|
|
@ -14,12 +14,12 @@
|
||||||
#include <QPainterPath>
|
#include <QPainterPath>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QDebug>
|
|
||||||
#include "globalfunc.h"
|
#include "globalfunc.h"
|
||||||
#include "basewin.h"
|
#include "basewin.h"
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QtEndian>
|
||||||
|
|
||||||
class ImgBtn : public QToolButton {
|
class ImgBtn : public QToolButton {
|
||||||
public:
|
public:
|
||||||
|
@ -57,6 +57,9 @@ inline QLabel *newSubLabel(QString txt){
|
||||||
}
|
}
|
||||||
ImgBtn *addImg(QHBoxLayout *parent, const QIcon &icon, const QString &text) {
|
ImgBtn *addImg(QHBoxLayout *parent, const QIcon &icon, const QString &text) {
|
||||||
auto imgBtn = new ImgBtn();
|
auto imgBtn = new ImgBtn();
|
||||||
|
auto ft = imgBtn->font();
|
||||||
|
ft.setPixelSize(14);
|
||||||
|
imgBtn->setFont(ft);
|
||||||
imgBtn->setIcon(icon);
|
imgBtn->setIcon(icon);
|
||||||
imgBtn->setText(text);
|
imgBtn->setText(text);
|
||||||
imgBtn->setFixedSize(76, 100);
|
imgBtn->setFixedSize(76, 100);
|
||||||
|
@ -67,7 +70,11 @@ ImgBtn *addImg(QHBoxLayout *parent, const QIcon &icon, const QString &text) {
|
||||||
|
|
||||||
MainWin::MainWin() {
|
MainWin::MainWin() {
|
||||||
setWindowTitle("LedSet Express");
|
setWindowTitle("LedSet Express");
|
||||||
resize(860, 540);
|
resize(900, 600);
|
||||||
|
|
||||||
|
auto ft = font();
|
||||||
|
ft.setPixelSize(14);
|
||||||
|
setFont(ft);
|
||||||
|
|
||||||
auto vBox = new QVBoxLayout(center);
|
auto vBox = new QVBoxLayout(center);
|
||||||
vBox->setContentsMargins(0,0,0,0);
|
vBox->setContentsMargins(0,0,0,0);
|
||||||
|
@ -117,10 +124,11 @@ MainWin::MainWin() {
|
||||||
{"type", "发送卡型号"},
|
{"type", "发送卡型号"},
|
||||||
{"name", "名称"},
|
{"name", "名称"},
|
||||||
{"link", "连接方式"},
|
{"link", "连接方式"},
|
||||||
{"vcs", "接收卡数量"},
|
{"vcsNum", "接收卡数量"},
|
||||||
{"Pinfo", "网口统计P1~Pn"},
|
{"netPorts", "网口统计P1~Pn"},
|
||||||
{"Oinfo", "其他信息", QHeaderView::Stretch},
|
{"info", "其他信息", QHeaderView::Stretch},
|
||||||
};
|
};
|
||||||
|
table->setDefs();
|
||||||
vBox->addWidget(table);
|
vBox->addWidget(table);
|
||||||
|
|
||||||
auto hstatus = new QHBoxLayout;
|
auto hstatus = new QHBoxLayout;
|
||||||
|
@ -188,20 +196,19 @@ MainWin::MainWin() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWin::getCard() {
|
void MainWin::getCard() {
|
||||||
auto msg = QByteArray::fromHex("55 55 01 0D 00 08 FF FF FF FF 00 00 AB CD A0 00 00 00 00 00 38 CB 84 7E 00 00 00 00 00 00 AB CD CD 04 04 46");
|
table->setRowCount(0);
|
||||||
auto res = sendMsg(msg, {0x1E0, [=](const QByteArray data) {
|
auto msg = QByteArray::fromHex("5555 01 0D 0008 FFFFFFFF 0000ABCD A0000000 0000 38CB847E 00000000 0000ABCD CD040446");
|
||||||
if(((u_char)data[10])==0xA0 && data[11]==0 && data[12]==0 && data[13]==0) {
|
auto res = sendMsg(msg, {0x1E0, 30000, [=](const QByteArray data) {
|
||||||
auto rr = 0;
|
if(*(quint32_be*)(data.data()+headMap.ptr) != 0xA0000000) return;
|
||||||
table->setRowCount(rr+1);
|
auto rr = 0;
|
||||||
uint32_t virtualVCM = data[6]<<8 | data[7] ;
|
table->setRowCount(rr+1);
|
||||||
table->setText(rr, "type", tr("虚拟设备"));
|
int virtualVCM = *(quint16_be*)(data.data()+headMap.srcAddr);
|
||||||
table->setText(rr, "name", tr("网口:")+QString::number(virtualVCM));
|
table->setText(rr, "type", tr("虚拟设备"));
|
||||||
table->setText(rr, "link", "千兆网直连");
|
table->setText(rr, "name", tr("网口:")+QString::number(virtualVCM));
|
||||||
uint32_t vcsNum = data[20] << 24 | data[21] <<16 | data[22] <<8 | data[23] ;
|
table->setText(rr, "link", "千兆网直连");
|
||||||
table->setText(rr, "vcs", QString::number(vcsNum));
|
table->setText(rr, "vcsNum", QString::number(*(quint32_be*)(data.data()+headMap.body)));
|
||||||
table->setText(rr, "Pinfo", "P:"+QString::number(virtualVCM));
|
table->setText(rr, "netPorts", "P:"+QString::number(virtualVCM));
|
||||||
table->setText(rr, "Oinfo", "备注:可直接配屏,无需发送卡");
|
table->setText(rr, "info", "备注:可直接配屏,无需发送卡");
|
||||||
}
|
|
||||||
}});
|
}});
|
||||||
if(res) {
|
if(res) {
|
||||||
QMessageBox::critical(this, "Error", QString(tr("发送失败: "))+pcap_geterr(pcapSend));
|
QMessageBox::critical(this, "Error", QString(tr("发送失败: "))+pcap_geterr(pcapSend));
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "moduleunit.h"
|
#include "moduleunit.h"
|
||||||
#include "expertwin.h"
|
#include "expertboxlayoutwin.h"
|
||||||
#include <QDirIterator>
|
#include <QDirIterator>
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
|
||||||
ModuleUnit::ModuleUnit(ExpertWin *expertWin, const QString &name, int x, int y, int w, int h, QWidget *parent) : QWidget{parent}, expertWin{expertWin}, name{name}, mX{x}, mY{y}, mW{w}, mH{h} {
|
ModuleUnit::ModuleUnit(ExpertBoxLayoutWin *expertWin, const QString &name, int x, int y, int w, int h, QWidget *parent) : QWidget{parent}, expertWin{expertWin}, name{name}, mX{x}, mY{y}, mW{w}, mH{h} {
|
||||||
setGeometry(x, y, w, h);
|
setGeometry(x, y, w, h);
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
auto font = this->font();
|
auto font = this->font();
|
||||||
|
@ -91,219 +91,219 @@ void ModuleUnit::mouseReleaseEvent(QMouseEvent *event) {
|
||||||
}
|
}
|
||||||
#define SnapSpace 6
|
#define SnapSpace 6
|
||||||
void ModuleUnit::mouseMoveEvent(QMouseEvent *e){
|
void ModuleUnit::mouseMoveEvent(QMouseEvent *e){
|
||||||
if(! (e->buttons() & Qt::LeftButton)) {
|
// if(! (e->buttons() & Qt::LeftButton)) {
|
||||||
setFrmSec(e->pos());
|
// setFrmSec(e->pos());
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
if(mFrmSec==Qt::NoSection || mPressRel.x()==INT_MIN) return;
|
// if(mFrmSec==Qt::NoSection || mPressRel.x()==INT_MIN) return;
|
||||||
auto mousePos = e->globalPos();
|
// auto mousePos = e->globalPos();
|
||||||
auto dstHor = mPressRel.x() + mousePos.x();
|
// auto dstHor = mPressRel.x() + mousePos.x();
|
||||||
auto dstVer = mPressRel.y() + mousePos.y();
|
// auto dstVer = mPressRel.y() + mousePos.y();
|
||||||
mLRSnap = mTBSnap = 0;
|
// mLRSnap = mTBSnap = 0;
|
||||||
foreach(auto ele, mOtherEles) ele->clearSnap();
|
// foreach(auto ele, mOtherEles) ele->clearSnap();
|
||||||
if(mFrmSec==Qt::TitleBarArea) {
|
// if(mFrmSec==Qt::TitleBarArea) {
|
||||||
dstHor = qBound(0, dstHor, expertWin->screenWidth - width());
|
// dstHor = qBound(0, dstHor, expertWin->screenWidth - width());
|
||||||
dstVer = qBound(0, dstVer, expertWin->screenHeight - height());
|
// dstVer = qBound(0, dstVer, expertWin->screenHeight - height());
|
||||||
if(dstHor==0) mLRSnap = 1;
|
// if(dstHor==0) mLRSnap = 1;
|
||||||
else if(dstHor==expertWin->screenWidth - width()) mLRSnap = 2;
|
// else if(dstHor==expertWin->screenWidth - width()) mLRSnap = 2;
|
||||||
if(dstVer==0) mTBSnap = 1;
|
// if(dstVer==0) mTBSnap = 1;
|
||||||
else if(dstVer==expertWin->screenHeight - height()) mTBSnap = 2;
|
// else if(dstVer==expertWin->screenHeight - height()) mTBSnap = 2;
|
||||||
if(mLRSnap==0) foreach(ModuleUnit *ele, mOtherEles) {//左右
|
// if(mLRSnap==0) foreach(ModuleUnit *ele, mOtherEles) {//左右
|
||||||
if(abs(dstHor - ele->x()) < SnapSpace && ele->x() <= expertWin->screenWidth - width()) {
|
// if(abs(dstHor - ele->x()) < SnapSpace && ele->x() <= expertWin->screenWidth - width()) {
|
||||||
dstHor = ele->x();
|
// dstHor = ele->x();
|
||||||
mLRSnap = 1;
|
// mLRSnap = 1;
|
||||||
ele->mLRSnap = 1;
|
// ele->mLRSnap = 1;
|
||||||
ele->update();
|
// ele->update();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
auto eleRight = ele->x() + ele->width();
|
// auto eleRight = ele->x() + ele->width();
|
||||||
if(abs(dstHor - eleRight) < SnapSpace && eleRight <= expertWin->screenWidth - width()) {
|
// if(abs(dstHor - eleRight) < SnapSpace && eleRight <= expertWin->screenWidth - width()) {
|
||||||
dstHor = eleRight;
|
// dstHor = eleRight;
|
||||||
mLRSnap = 1;
|
// mLRSnap = 1;
|
||||||
ele->mLRSnap = 2;
|
// ele->mLRSnap = 2;
|
||||||
ele->update();
|
// ele->update();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
auto right = dstHor + width();
|
// auto right = dstHor + width();
|
||||||
if(abs(right - ele->x()) < SnapSpace && ele->x() - width() >= 0) {
|
// if(abs(right - ele->x()) < SnapSpace && ele->x() - width() >= 0) {
|
||||||
dstHor = ele->x() - width();
|
// dstHor = ele->x() - width();
|
||||||
mLRSnap = 2;
|
// mLRSnap = 2;
|
||||||
ele->mLRSnap = 1;
|
// ele->mLRSnap = 1;
|
||||||
ele->update();
|
// ele->update();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
if(abs(right - eleRight) < SnapSpace && eleRight - width() >= 0) {
|
// if(abs(right - eleRight) < SnapSpace && eleRight - width() >= 0) {
|
||||||
dstHor = eleRight - width();
|
// dstHor = eleRight - width();
|
||||||
mLRSnap = 2;
|
// mLRSnap = 2;
|
||||||
ele->mLRSnap = 2;
|
// ele->mLRSnap = 2;
|
||||||
ele->update();
|
// ele->update();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if(mTBSnap==0) foreach(ModuleUnit *ele, mOtherEles) {//上下
|
// if(mTBSnap==0) foreach(ModuleUnit *ele, mOtherEles) {//上下
|
||||||
if(abs(dstVer-ele->y()) < SnapSpace && ele->y() <= expertWin->screenHeight - height()) {
|
// if(abs(dstVer-ele->y()) < SnapSpace && ele->y() <= expertWin->screenHeight - height()) {
|
||||||
dstVer = ele->y();
|
// dstVer = ele->y();
|
||||||
mTBSnap = 1;
|
// mTBSnap = 1;
|
||||||
ele->mTBSnap = 1;
|
// ele->mTBSnap = 1;
|
||||||
ele->update();
|
// ele->update();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
auto eleBtm = ele->y() + ele->height();
|
// auto eleBtm = ele->y() + ele->height();
|
||||||
if(abs(dstVer - eleBtm) < SnapSpace && eleBtm <= expertWin->screenHeight - height()) {
|
// if(abs(dstVer - eleBtm) < SnapSpace && eleBtm <= expertWin->screenHeight - height()) {
|
||||||
dstVer = eleBtm;
|
// dstVer = eleBtm;
|
||||||
mTBSnap = 1;
|
// mTBSnap = 1;
|
||||||
ele->mTBSnap = 2;
|
// ele->mTBSnap = 2;
|
||||||
ele->update();
|
// ele->update();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
auto btm = dstVer + height();
|
// auto btm = dstVer + height();
|
||||||
if(abs(btm - ele->y()) < SnapSpace && ele->y() - height() >= 0) {
|
// if(abs(btm - ele->y()) < SnapSpace && ele->y() - height() >= 0) {
|
||||||
dstVer = ele->y() - height();
|
// dstVer = ele->y() - height();
|
||||||
mTBSnap = 2;
|
// mTBSnap = 2;
|
||||||
ele->mTBSnap = 1;
|
// ele->mTBSnap = 1;
|
||||||
ele->update();
|
// ele->update();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
if(abs(btm - eleBtm) < SnapSpace && eleBtm - height() >= 0) {
|
// if(abs(btm - eleBtm) < SnapSpace && eleBtm - height() >= 0) {
|
||||||
dstVer = eleBtm - height();
|
// dstVer = eleBtm - height();
|
||||||
mTBSnap = 2;
|
// mTBSnap = 2;
|
||||||
ele->mTBSnap = 2;
|
// ele->mTBSnap = 2;
|
||||||
ele->update();
|
// ele->update();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
move(dstHor, dstVer);
|
// move(dstHor, dstVer);
|
||||||
mX = qRound(dstHor / expertWin->rate);
|
// mX = qRound(dstHor / expertWin->rate);
|
||||||
mY = qRound(dstVer / expertWin->rate);
|
// mY = qRound(dstVer / expertWin->rate);
|
||||||
update();
|
// update();
|
||||||
} else if(mFrmSec==Qt::BottomRightSection) {
|
// } else if(mFrmSec==Qt::BottomRightSection) {
|
||||||
if(dstHor < m_handleLen) dstHor = m_handleLen;
|
// if(dstHor < m_handleLen) dstHor = m_handleLen;
|
||||||
if(dstVer < m_handleLen) dstVer = m_handleLen;
|
// if(dstVer < m_handleLen) dstVer = m_handleLen;
|
||||||
if(expertWin->screenWidth>0 && expertWin->screenHeight>0) {
|
// if(expertWin->screenWidth>0 && expertWin->screenHeight>0) {
|
||||||
dstHor = qMin(dstHor, expertWin->screenWidth - x());
|
// dstHor = qMin(dstHor, expertWin->screenWidth - x());
|
||||||
dstVer = qMin(dstVer, expertWin->screenHeight - y());
|
// dstVer = qMin(dstVer, expertWin->screenHeight - y());
|
||||||
}
|
// }
|
||||||
resize(dstHor, dstVer);
|
// resize(dstHor, dstVer);
|
||||||
mW = qRound(dstHor / expertWin->rate);
|
// mW = qRound(dstHor / expertWin->rate);
|
||||||
mH = qRound(dstVer / expertWin->rate);
|
// mH = qRound(dstVer / expertWin->rate);
|
||||||
} else if(mFrmSec==Qt::RightSection) {
|
// } else if(mFrmSec==Qt::RightSection) {
|
||||||
if(dstHor < m_handleLen) dstHor = m_handleLen;
|
// if(dstHor < m_handleLen) dstHor = m_handleLen;
|
||||||
if(expertWin->screenWidth>0 && expertWin->screenHeight>0) dstHor = qMin(dstHor, expertWin->screenWidth - x());
|
// if(expertWin->screenWidth>0 && expertWin->screenHeight>0) dstHor = qMin(dstHor, expertWin->screenWidth - x());
|
||||||
auto right = x() + dstHor;
|
// auto right = x() + dstHor;
|
||||||
if(right < expertWin->screenWidth-8) foreach(ModuleUnit *ele, mOtherEles) {//左右
|
// if(right < expertWin->screenWidth-8) foreach(ModuleUnit *ele, mOtherEles) {//左右
|
||||||
if(abs(right - ele->x()) < SnapSpace) {
|
// if(abs(right - ele->x()) < SnapSpace) {
|
||||||
dstHor = ele->x() - x();
|
// dstHor = ele->x() - x();
|
||||||
mLRSnap = 2;
|
// mLRSnap = 2;
|
||||||
ele->mLRSnap = 1;
|
// ele->mLRSnap = 1;
|
||||||
ele->update();
|
// ele->update();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
auto eleRight = ele->x() + ele->width();
|
// auto eleRight = ele->x() + ele->width();
|
||||||
if(abs(right - eleRight) < SnapSpace) {
|
// if(abs(right - eleRight) < SnapSpace) {
|
||||||
dstHor = eleRight - x();
|
// dstHor = eleRight - x();
|
||||||
mLRSnap = 2;
|
// mLRSnap = 2;
|
||||||
ele->mLRSnap = 2;
|
// ele->mLRSnap = 2;
|
||||||
ele->update();
|
// ele->update();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
resize(dstHor, mPressRel.y());
|
// resize(dstHor, mPressRel.y());
|
||||||
mW = qRound(dstHor / expertWin->rate);
|
// mW = qRound(dstHor / expertWin->rate);
|
||||||
} else if(mFrmSec==Qt::BottomSection) {
|
// } else if(mFrmSec==Qt::BottomSection) {
|
||||||
if(dstVer < m_handleLen) dstVer = m_handleLen;
|
// if(dstVer < m_handleLen) dstVer = m_handleLen;
|
||||||
if(expertWin->screenWidth>0 && expertWin->screenHeight>0) dstVer = qMin(dstVer, expertWin->screenHeight - y());
|
// if(expertWin->screenWidth>0 && expertWin->screenHeight>0) dstVer = qMin(dstVer, expertWin->screenHeight - y());
|
||||||
auto btm = y() + dstVer;
|
// auto btm = y() + dstVer;
|
||||||
if(btm < expertWin->screenHeight-8) foreach(ModuleUnit *ele, mOtherEles) {//上下
|
// if(btm < expertWin->screenHeight-8) foreach(ModuleUnit *ele, mOtherEles) {//上下
|
||||||
auto eleBtm = ele->y() + ele->height();
|
// auto eleBtm = ele->y() + ele->height();
|
||||||
if(abs(btm - ele->y()) < SnapSpace) {
|
// if(abs(btm - ele->y()) < SnapSpace) {
|
||||||
dstVer = ele->y() - y();
|
// dstVer = ele->y() - y();
|
||||||
mTBSnap = 2;
|
// mTBSnap = 2;
|
||||||
ele->mTBSnap = 1;
|
// ele->mTBSnap = 1;
|
||||||
ele->update();
|
// ele->update();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
if(abs(btm - eleBtm) < SnapSpace) {
|
// if(abs(btm - eleBtm) < SnapSpace) {
|
||||||
dstVer = eleBtm - y();
|
// dstVer = eleBtm - y();
|
||||||
mTBSnap = 2;
|
// mTBSnap = 2;
|
||||||
ele->mTBSnap = 2;
|
// ele->mTBSnap = 2;
|
||||||
ele->update();
|
// ele->update();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
resize(mPressRel.rx(), dstVer);
|
// resize(mPressRel.rx(), dstVer);
|
||||||
mH = qRound(dstVer / expertWin->rate);
|
// mH = qRound(dstVer / expertWin->rate);
|
||||||
} else {
|
// } else {
|
||||||
auto geo = geometry();
|
// auto geo = geometry();
|
||||||
if(mFrmSec==Qt::LeftSection) {
|
// if(mFrmSec==Qt::LeftSection) {
|
||||||
dstHor = qMin(dstHor, geo.right() - m_handleLen);
|
// dstHor = qMin(dstHor, geo.right() - m_handleLen);
|
||||||
if(dstHor < 0) dstHor = 0;
|
// if(dstHor < 0) dstHor = 0;
|
||||||
if(dstHor > 8) foreach(ModuleUnit *ele, mOtherEles) {//左右
|
// if(dstHor > 8) foreach(ModuleUnit *ele, mOtherEles) {//左右
|
||||||
if(abs(dstHor - ele->x()) < SnapSpace) {
|
// if(abs(dstHor - ele->x()) < SnapSpace) {
|
||||||
dstHor = ele->x();
|
// dstHor = ele->x();
|
||||||
mLRSnap = 1;
|
// mLRSnap = 1;
|
||||||
ele->mLRSnap = 1;
|
// ele->mLRSnap = 1;
|
||||||
ele->update();
|
// ele->update();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
auto eleRight = ele->x() + ele->width();
|
// auto eleRight = ele->x() + ele->width();
|
||||||
if(abs(dstHor - eleRight) < SnapSpace) {
|
// if(abs(dstHor - eleRight) < SnapSpace) {
|
||||||
dstHor = eleRight;
|
// dstHor = eleRight;
|
||||||
mLRSnap = 1;
|
// mLRSnap = 1;
|
||||||
ele->mLRSnap = 2;
|
// ele->mLRSnap = 2;
|
||||||
ele->update();
|
// ele->update();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
geo.setLeft(dstHor);
|
// geo.setLeft(dstHor);
|
||||||
} else if(mFrmSec==Qt::TopSection) {
|
// } else if(mFrmSec==Qt::TopSection) {
|
||||||
dstVer = qMin(dstVer, geo.bottom() - m_handleLen);
|
// dstVer = qMin(dstVer, geo.bottom() - m_handleLen);
|
||||||
if(dstVer < 0) dstVer = 0;
|
// if(dstVer < 0) dstVer = 0;
|
||||||
if(dstVer > 8) foreach(ModuleUnit *ele, mOtherEles) {//上下
|
// if(dstVer > 8) foreach(ModuleUnit *ele, mOtherEles) {//上下
|
||||||
if(abs(dstVer - ele->y()) < SnapSpace) {
|
// if(abs(dstVer - ele->y()) < SnapSpace) {
|
||||||
dstVer = ele->y();
|
// dstVer = ele->y();
|
||||||
mTBSnap = 1;
|
// mTBSnap = 1;
|
||||||
ele->mTBSnap = 1;
|
// ele->mTBSnap = 1;
|
||||||
ele->update();
|
// ele->update();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
auto eleBtm = ele->y() + ele->height();
|
// auto eleBtm = ele->y() + ele->height();
|
||||||
if(abs(dstVer - eleBtm) < SnapSpace) {
|
// if(abs(dstVer - eleBtm) < SnapSpace) {
|
||||||
dstVer = eleBtm;
|
// dstVer = eleBtm;
|
||||||
mTBSnap = 1;
|
// mTBSnap = 1;
|
||||||
ele->mTBSnap = 2;
|
// ele->mTBSnap = 2;
|
||||||
ele->update();
|
// ele->update();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
geo.setTop(dstVer);
|
// geo.setTop(dstVer);
|
||||||
} else if(mFrmSec==Qt::TopLeftSection) {
|
// } else if(mFrmSec==Qt::TopLeftSection) {
|
||||||
dstHor = qMin(dstHor, geo.right() - m_handleLen);
|
// dstHor = qMin(dstHor, geo.right() - m_handleLen);
|
||||||
dstVer = qMin(dstVer, geo.bottom() - m_handleLen);
|
// dstVer = qMin(dstVer, geo.bottom() - m_handleLen);
|
||||||
if(dstHor < 0) dstHor = 0;
|
// if(dstHor < 0) dstHor = 0;
|
||||||
if(dstVer < 0) dstVer = 0;
|
// if(dstVer < 0) dstVer = 0;
|
||||||
geo.setLeft(dstHor);
|
// geo.setLeft(dstHor);
|
||||||
geo.setTop(dstVer);
|
// geo.setTop(dstVer);
|
||||||
} else if(mFrmSec==Qt::TopRightSection) {
|
// } else if(mFrmSec==Qt::TopRightSection) {
|
||||||
dstHor = qMax(dstHor, geo.x() + m_handleLen);
|
// dstHor = qMax(dstHor, geo.x() + m_handleLen);
|
||||||
dstVer = qMin(dstVer, geo.bottom() - m_handleLen);
|
// dstVer = qMin(dstVer, geo.bottom() - m_handleLen);
|
||||||
if(dstHor > expertWin->screenWidth) dstHor = expertWin->screenWidth;
|
// if(dstHor > expertWin->screenWidth) dstHor = expertWin->screenWidth;
|
||||||
if(dstVer < 0) dstVer = 0;
|
// if(dstVer < 0) dstVer = 0;
|
||||||
geo.setRight(dstHor);
|
// geo.setRight(dstHor);
|
||||||
geo.setTop(dstVer);
|
// geo.setTop(dstVer);
|
||||||
} else if(mFrmSec==Qt::BottomLeftSection) {
|
// } else if(mFrmSec==Qt::BottomLeftSection) {
|
||||||
dstHor = qMin(dstHor, geo.right() - m_handleLen);
|
// dstHor = qMin(dstHor, geo.right() - m_handleLen);
|
||||||
dstVer = qMax(dstVer, geo.y() + m_handleLen);
|
// dstVer = qMax(dstVer, geo.y() + m_handleLen);
|
||||||
if(dstHor < 0) dstHor = 0;
|
// if(dstHor < 0) dstHor = 0;
|
||||||
if(dstVer > expertWin->screenHeight) dstVer = expertWin->screenHeight;
|
// if(dstVer > expertWin->screenHeight) dstVer = expertWin->screenHeight;
|
||||||
geo.setLeft(dstHor);
|
// geo.setLeft(dstHor);
|
||||||
geo.setBottom(dstVer);
|
// geo.setBottom(dstVer);
|
||||||
}
|
// }
|
||||||
setGeometry(geo);
|
// setGeometry(geo);
|
||||||
mX = qRound(geo.x() / expertWin->rate);
|
// mX = qRound(geo.x() / expertWin->rate);
|
||||||
mY = qRound(geo.y() / expertWin->rate);
|
// mY = qRound(geo.y() / expertWin->rate);
|
||||||
mW = qRound(geo.width() / expertWin->rate);
|
// mW = qRound(geo.width() / expertWin->rate);
|
||||||
mH = qRound(geo.height() / expertWin->rate);
|
// mH = qRound(geo.height() / expertWin->rate);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
void ModuleUnit::leaveEvent(QEvent *) {
|
void ModuleUnit::leaveEvent(QEvent *) {
|
||||||
setFrmSecIfNeed(Qt::NoSection, Qt::ArrowCursor);
|
setFrmSecIfNeed(Qt::NoSection, Qt::ArrowCursor);
|
||||||
|
|
|
@ -6,13 +6,13 @@
|
||||||
#include <QPen>
|
#include <QPen>
|
||||||
|
|
||||||
#define m_handleLen 10
|
#define m_handleLen 10
|
||||||
class ExpertWin;
|
class ExpertBoxLayoutWin;
|
||||||
class ModuleUnit : public QWidget {
|
class ModuleUnit : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ModuleUnit(ExpertWin *, const QString &name, int x, int y, int w, int h, QWidget *parent = nullptr);
|
explicit ModuleUnit(ExpertBoxLayoutWin *, const QString &name, int x, int y, int w, int h, QWidget *parent = nullptr);
|
||||||
|
|
||||||
ExpertWin *expertWin{0};
|
ExpertBoxLayoutWin *expertWin{0};
|
||||||
QString name;
|
QString name;
|
||||||
int mX, mY, mW, mH;
|
int mX, mY, mW, mH;
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -14,15 +14,22 @@ void PcapReThread::run() {
|
||||||
int res;
|
int res;
|
||||||
while((res = pcap_next_ex(pcap, &header, &data)) >= 0) {
|
while((res = pcap_next_ex(pcap, &header, &data)) >= 0) {
|
||||||
if(status==2) return;
|
if(status==2) return;
|
||||||
if(status==1 || res == 0) continue; //超时
|
if(resps.isEmpty()) continue;
|
||||||
if(data[0]!=0x55 || data[1]!=0x55 ) continue;
|
|
||||||
int id = data[2]<<8 | data[3];
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mtx);
|
std::lock_guard<std::mutex> lock(mtx);
|
||||||
for(int i=0; i<resps.size(); i++) if(resps[i].id==id) {
|
if(status==0 && res && data[0]==0x55 && data[1]==0x55) {
|
||||||
|
int id = data[2]<<8 | data[3];
|
||||||
|
for(int i=0; i<resps.size(); i++) if(resps[i].id==id) {
|
||||||
|
auto resp = resps.takeAt(i);
|
||||||
|
emit onMsg(resp, QByteArray((char*)data, header->caplen));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
auto now = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
|
||||||
|
for(int i=0; i<resps.size(); i++) if(resps[i].timeout <= now && resps[i].timeout > 0) {
|
||||||
auto resp = resps.takeAt(i);
|
auto resp = resps.takeAt(i);
|
||||||
emit onMsg(resp, QByteArray((char*)(data+4), header->caplen-4));
|
resp.timeout = -5;
|
||||||
break;
|
emit onMsg(resp, QByteArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,13 @@
|
||||||
#include "pcap.h"
|
#include "pcap.h"
|
||||||
|
|
||||||
struct Resp {
|
struct Resp {
|
||||||
|
Resp() {}
|
||||||
|
Resp(int id, qint64 timeout, const std::function<void(const QByteArray)> &callback) : id(id), timeout(timeout), callback(callback) {
|
||||||
|
auto now = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
|
||||||
|
if(this->timeout > 0) this->timeout += now;
|
||||||
|
}
|
||||||
int id;
|
int id;
|
||||||
|
qint64 timeout;
|
||||||
std::function<void(const QByteArray)> callback;
|
std::function<void(const QByteArray)> callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "globalfunc.h"
|
|
||||||
|
|
||||||
PcapWin *PcapWin::newIns(QByteArray &name, QWidget *parent) {
|
PcapWin *PcapWin::newIns(QByteArray &name, QWidget *parent) {
|
||||||
if(name.isEmpty()) return 0;
|
if(name.isEmpty()) return 0;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "videowin.h"
|
#include "videowin.h"
|
||||||
#include "gqt.h"
|
#include "gutil/qgui.h"
|
||||||
#include "crc.h"
|
#include "crc.h"
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user