From 8a1cee9e8286b31ceaa2a992b89d44bf40c2da3d Mon Sep 17 00:00:00 2001 From: Gangphon Date: Wed, 7 Jun 2023 19:11:03 +0800 Subject: [PATCH] =?UTF-8?q?ledset=20=E8=B5=B0=E7=82=B9=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ledset/expertsmartpointsetwin.cpp | 382 +++++++++++++++--------------- ledset/expertsmartpointsetwin.h | 3 + ledset/globalfunc.cpp | 11 + ledset/globalfunc.h | 2 +- ledset/gutil/qgui.h | 19 +- ledset/ledset.pro | 2 + ledset/main.cpp | 9 +- ledset/mainwin.cpp | 9 +- ledset/waitingdlg.cpp | 21 +- ledset/waitingdlg.h | 1 + 10 files changed, 256 insertions(+), 203 deletions(-) diff --git a/ledset/expertsmartpointsetwin.cpp b/ledset/expertsmartpointsetwin.cpp index 598ec61..7c41db6 100644 --- a/ledset/expertsmartpointsetwin.cpp +++ b/ledset/expertsmartpointsetwin.cpp @@ -77,6 +77,7 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e vBox->addLayout(addBtns(new QHBoxLayout())); auto stack = new QStackedLayout(vBox); + auto vv = new VBox(stack); vv->setContentsMargins(50, 50, 6, 6); @@ -451,185 +452,143 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e vv->addStretch(); - { - auto vBox = new VBox(stack); - vBox->setContentsMargins(50, 50, 6, 6); - auto lb = new QLabel(tr("扫描行数")); - gFont(lb, 16); - lb->setPalette(bkBlue); - vBox->addWidget(lb); - vBox->addSpacing(50); + vv = new VBox(stack); + vv->setContentsMargins(50, 50, 6, 6); - auto hBox = new QHBoxLayout; - vBox->addLayout(hBox); - hBox->addStretch(); + lb = new QLabel(tr("扫描行数")); + gFont(lb, 16); + lb->setPalette(bkBlue); + vv->addWidget(lb); + vv->addSpacing(50); - auto vvv = new QVBoxLayout; - hBox->addLayout(vvv); + auto hBox = new HBox(vv); + hBox->addStretch(); - lb = new QLabel(tr("根据亮线的行/列数确定扫描行/列数: ")); - vvv->addWidget(lb); - vvv->addSpacing(30); + auto vvv = new VBox(hBox); - auto hhhh = new QHBoxLayout; - hhhh->addStretch(); - auto fdRow = new QRadioButton(tr("行")); - hhhh->addWidget(fdRow); - hhhh->addStretch(); - auto fdCol = new QRadioButton(tr("列")); - hhhh->addWidget(fdCol); - hhhh->addStretch(); - vvv->addLayout(hhhh); - vvv->addSpacing(20); + lb = new QLabel(tr("根据亮线的行/列数确定扫描行/列数: ")); + vvv->addWidget(lb); + vvv->addSpacing(30); - hhhh = new QHBoxLayout; - hhhh->addStretch(); + hhhh = new HBox(vvv); + hhhh->addStretch(); - lb = new QLabel(tr("亮线的行/列数: ")); - hhhh->addWidget(lb); + fdRow = new QRadioButton(tr("行")); + fdRow->setChecked(true); + hhhh->addWidget(fdRow); + hhhh->addStretch(); - auto fdNum = new QSpinBox; - fdNum->setRange(0, 9999); - fdNum->setValue(1); - hhhh->addWidget(fdNum); + fdCol = new QRadioButton(tr("列")); + hhhh->addWidget(fdCol); + hhhh->addStretch(); - hhhh->addStretch(); - vvv->addLayout(hhhh); + auto grp = new QButtonGroup; + grp->addButton(fdRow, 0); + grp->addButton(fdCol, 1); - vvv->addStretch(); + vvv->addSpacing(20); - hBox->addStretch(); + hhhh = new HBox(vvv); + hhhh->addStretch(); - vvv = new QVBoxLayout; - hBox->addLayout(vvv); + lb = new QLabel(tr("亮线的行/列数: ")); + hhhh->addWidget(lb); - lb = new QLabel(tr("芯片245版本: ")); - vvv->addWidget(lb); - vvv->addSpacing(30); + auto fdNum = new QSpinBox; + fdNum->setRange(0, 9999); + fdNum->setValue(1); + hhhh->addWidget(fdNum); - 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); + hhhh->addStretch(); - vvv->addStretch(); - hBox->addStretch(); + vvv->addStretch(); + + hBox->addStretch(); + + vvv = new VBox(hBox); + + lb = new QLabel(tr("芯片245版本: ")); + vvv->addWidget(lb); + vvv->addSpacing(30); + + hhhh = new HBox(vvv); + hhhh->addStretch(); + + auto fdA = new QRadioButton("A"); + hhhh->addWidget(fdA); + hhhh->addStretch(); + + auto fdD = new QRadioButton("D"); + hhhh->addWidget(fdD); + hhhh->addStretch(); + + vvv->addStretch(); + hBox->addStretch(); + + + vv = new VBox(stack); + vv->setContentsMargins(50, 50, 6, 6); + + lb = new QLabel(tr("数据线颜色")); + gFont(lb, 16); + lb->setPalette(bkBlue); + vv->addWidget(lb); + vv->addSpacing(50); + + lb = new QLabel(tr("依次点击以下状态, 根据模组颜色选择对应颜色")); + vv->addWidget(lb, 0, Qt::AlignCenter); + vv->addSpacing(30); + + grid = new Grid(vv); + grid->setVerticalSpacing(20); + grid->setColumnStretch(0, 1); + grid->setColumnStretch(2, 1); + grid->setColumnStretch(7, 1); + + auto fdStas = new QButtonGroup(grid); + auto fdRs = new QButtonGroup(grid); + auto fdGs = new QButtonGroup(grid); + auto fdBs = new QButtonGroup(grid); + auto fdNos = new QButtonGroup(grid); + for(int rr = 0; rr < 3; ++rr) { + fdStas->addButton(new QRadioButton(tr("状态")+QString::number(rr+1)), rr); + fdRs->addButton(new QRadioButton(tr("红")), rr); + fdGs->addButton(new QRadioButton(tr("绿")), rr); + fdBs->addButton(new QRadioButton(tr("蓝")), rr); + fdNos->addButton(new QRadioButton(tr("黑")), rr); + grid->addWidget(fdStas->button(rr), rr, 1); + grid->addWidget(fdRs->button(rr), rr, 3); + grid->addWidget(fdGs->button(rr), rr, 4); + grid->addWidget(fdBs->button(rr), rr, 5); + grid->addWidget(fdNos->button(rr), rr, 6); } - { - auto vBox = new VBox(stack); - vBox->setContentsMargins(50, 50, 6, 6); + fdStas->button(0)->setChecked(true); + fdRs->button(0)->setChecked(true); + fdGs->button(1)->setChecked(true); + fdBs->button(2)->setChecked(true); - auto lb = new QLabel(tr("数据线颜色")); - gFont(lb, 16); - lb->setPalette(bkBlue); - vBox->addWidget(lb); - vBox->addSpacing(50); + connect(fdStas, &QButtonGroup::idClicked, this, [this] (int id) { + auto msg = QByteArray::fromHex("5555 01AD 000A FFFFFFFF 0000ABCD B1000011 0000 D10CD484 AD000011 0004 01200000 0BF4F928"); + msg[msg.size()-5] = id; + auto check = (quint32_be*)(msg.data()+msg.size()-4); + *check = crc32_calc((byte*)msg.data()+headMap.body, msg.size()-4-headMap.body); + qDebug()<<"check"<addWidget(lb, 0, Qt::AlignCenter); - vBox->addSpacing(30); + auto waitingDlg = new WaitingDlg(this, tr("Setting")+" ..."); + auto res = sendMsg(msg, 0x1EA, 10000, [=](int code, const QByteArray data) { + if(code==5) { + waitingDlg->close(); + QMessageBox::critical(this, "Error", tr("请求超时")); + return; + } + waitingDlg->close(); + qDebug()<<"resp back. RGB status:"<addStretch(); - auto fdSta1 = new QRadioButton(tr("状态1")); - fdSta1->setChecked(true); - hhhh->addWidget(fdSta1); - hhhh->addStretch(); - - auto fdR1 = new QRadioButton(tr("红")); - fdR1->setChecked(true); - hhhh->addWidget(fdR1); - hhhh->addSpacing(20); - - auto fdG1 = new QRadioButton(tr("绿")); - hhhh->addWidget(fdG1); - hhhh->addSpacing(20); - - auto fdB1 = new QRadioButton(tr("蓝")); - hhhh->addWidget(fdB1); - hhhh->addSpacing(20); - - auto fdNo1 = new QRadioButton(tr("黑")); - hhhh->addWidget(fdNo1); - hhhh->addStretch(); - - vBox->addLayout(hhhh); - vBox->addSpacing(20); - - hhhh = new QHBoxLayout; - hhhh->addStretch(); - auto fdSta2 = new QRadioButton(tr("状态2")); - hhhh->addWidget(fdSta2); - hhhh->addStretch(); - - auto fdR2 = new QRadioButton(tr("红")); - hhhh->addWidget(fdR2); - hhhh->addSpacing(20); - - auto fdG2 = new QRadioButton(tr("绿")); - fdG2->setChecked(true); - hhhh->addWidget(fdG2); - hhhh->addSpacing(20); - - auto fdB2 = new QRadioButton(tr("蓝")); - hhhh->addWidget(fdB2); - hhhh->addSpacing(20); - - auto fdNo2 = new QRadioButton(tr("黑")); - hhhh->addWidget(fdNo2); - hhhh->addStretch(); - - vBox->addLayout(hhhh); - vBox->addSpacing(20); - - hhhh = new QHBoxLayout; - hhhh->addStretch(); - auto fdSta3 = new QRadioButton(tr("状态3")); - hhhh->addWidget(fdSta3); - hhhh->addStretch(); - - auto fdR3 = new QRadioButton(tr("红")); - hhhh->addWidget(fdR3); - hhhh->addSpacing(20); - - auto fdG3 = new QRadioButton(tr("绿")); - hhhh->addWidget(fdG3); - hhhh->addSpacing(20); - - auto fdB3 = new QRadioButton(tr("蓝")); - fdB3->setChecked(true); - hhhh->addWidget(fdB3); - hhhh->addSpacing(20); - - auto fdNo3 = new QRadioButton(tr("黑")); - hhhh->addWidget(fdNo3); - hhhh->addStretch(); - - vBox->addLayout(hhhh); - vBox->addStretch(); - - auto btnGrp = new QButtonGroup(fdNo1); - btnGrp->addButton(fdR1); - btnGrp->addButton(fdG1); - btnGrp->addButton(fdB1); - btnGrp->addButton(fdNo1); - btnGrp = new QButtonGroup(fdNo2); - btnGrp->addButton(fdR2); - btnGrp->addButton(fdG2); - btnGrp->addButton(fdB2); - btnGrp->addButton(fdNo2); - btnGrp = new QButtonGroup(fdNo3); - btnGrp->addButton(fdR3); - btnGrp->addButton(fdG3); - btnGrp->addButton(fdB3); - btnGrp->addButton(fdNo3); - } + vv->addStretch(); { auto vBox = new VBox(stack); vBox->setContentsMargins(0,0,0,0); @@ -677,6 +636,7 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e table->clearContents(); tableRow->setColumnCount(0); virtualCnt = 0; + scans.clear(); }); hhh->addWidget(btnReset); @@ -689,11 +649,10 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e vBox->addLayout(hhh); table = new Table; - table->setNoEdit(); - table->setSelectionMode(QTableWidget::SingleSelection); - table->setColWidth(40); + table->setNoEdit()->setSelectionMode(QTableWidget::SingleSelection); + table->setColWidth(35)->setRowHeight(24, QHeaderView::Fixed); table->horizontalHeader()->setDefaultAlignment(Qt::AlignCenter); - table->verticalHeader()->setMinimumWidth(40); + table->verticalHeader()->setMinimumWidth(35); table->verticalHeader()->setDefaultAlignment(Qt::AlignCenter); connect(table, &QTableWidget::currentCellChanged, this, [=](int row, int col) { if(row < 0) return; @@ -707,42 +666,49 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e tableRow->setData(1, cnt-1, QPoint{col, row}); auto realCnt = cnt - virtualCnt; table->setText(row, col, QString::number(realCnt))->setTextAlignment(Qt::AlignCenter); - if(realCnt==ModuleWidth) { + if(realCnt!=ModuleWidth) { + sendPoint(cnt); + } else { scans.append({col, row}); QMessageBox::information(this, tr("提示"), tr("列走完")); + sendPoint(1<<10); } } else if(scans.size() < ScanNum) { scans.append({col, row}); auto size = scans.size(); table->setText(row, col, "S"+QString::number(size))->setTextAlignment(Qt::AlignCenter); - if(size==ScanNum) { + if(size!=ScanNum) sendPoint(size<<10); + else { QMessageBox::information(this, tr("提示"), tr("行走完")); + auto msg = QByteArray::fromHex("5555 01AD 000A FFFFFFFF 0000ABCD B1000011 0000 D10CD484 AD000011 0004 00000000 8b05d8ad"); + auto waitingDlg = new WaitingDlg(this, tr("Setting")+" ..."); + auto res = sendMsgSync(msg, 0x1EA, 10000, waitingDlg); + if(res==5) QMessageBox::critical(this, "Error", tr("请求超时")); + else if(res) QMessageBox::critical(this, "Error", QString(tr("发送失败: "))+QString::fromLocal8Bit(pcap_geterr(pcapSend))); + else waitingDlg->close(); + qDebug()<<"resp back. point end."; save(); } } }); - vBox->addWidget(table); tableRow = new Table(2, 0); tableRow->setNoEdit(); tableRow->setSelectionMode(QTableWidget::NoSelection); - tableRow->horizontalHeader()->setDefaultSectionSize(40); + tableRow->setColWidth(35); + tableRow->setRowHeight(24); 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()); - item->setText(tr("第一扫灯数:")); - item = tableRow->verticalHeaderItem(1); - if(item==0) tableRow->setVerticalHeaderItem(1, item = new QTableWidgetItem()); - item->setText(tr("实: 虚:")); + tableRow->setMaximumHeight(50); + tableRow->setVHeaderText(0, tr("第一扫灯数:")); + tableRow->setVHeaderText(1, tr("实: 虚:")); vBox->addWidget(tableRow); } - auto hBox = new HBox(vBox); + hBox = new HBox(vBox); hBox->addStretch(); auto btnPrev = new QPushButton(tr("上一步")); @@ -770,34 +736,60 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e DecodeMode = fdDecodeMode->text(); 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 01 00 00 001000 01 " + auto msg = QByteArray::fromHex("5555 01AD 0062 FFFFFFFF 0000ABCD B1000000 0000 415F94A7 AD000000 005C AA55AA55 0000 0036 1770 0000 0280 0000 32 10 00 00 0A 01 00 00 001000 01 " "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB 00000000 00000008 00400020 00001400 FF00FF00 3C000000 00000000 1B022020 00000040 55AA55AA 00000000 39F424F6 351B0E53"); // UUID type len w h ex1 chip/decode ex3 smartset smartset2 走点len endFlag auto unitptr = msg.data()+headMap.end+modMap.Unit; auto w = (quint16_be*)(unitptr+modUnitMap.w); - qDebug()<<"w"<close(); + QMessageBox::critical(this, "Error", tr("请求超时")); + return; + } + auto msg = QByteArray::fromHex(QByteArray("5555 01AD 000A FFFFFFFF 0000ABCD B1000011 0000 D10CD484 AD000011 0004 01300000 17D25A58")); + auto res = sendMsg(msg, 0x1EA, 10000, [=](int code, const QByteArray data) { + if(code==5) { + waitingDlg->close(); + QMessageBox::critical(this, "Error", tr("请求超时")); + return; + } + waitingDlg->close(); + auto iii = idx+1; + stack->setCurrentIndex(iii); + btnPrev->setEnabled(iii > 0); + btnNext->setEnabled(iii < stack->count()-1); + }, waitingDlg); + if(res) QMessageBox::critical(this, "Error", QString(tr("发送失败: "))+QString::fromLocal8Bit(pcap_geterr(pcapSend))); + }, waitingDlg); + if(res) QMessageBox::critical(this, "Error", QString(tr("发送失败: "))+QString::fromLocal8Bit(pcap_geterr(pcapSend))); + } else if(idx==1) { + //GroupMode = fdNum->value(); + auto msg = QByteArray::fromHex("5555 01AD 000A FFFFFFFF 0000ABCD B1000011 0000 D10CD484 AD000011 0004 01200000 0BF4F928"); + auto id = fdStas->checkedId(); + if(id) { + msg[msg.size()-5] = id; + auto check = (quint32_be*)(msg.data()+msg.size()-4); + *check = crc32_calc((byte*)msg.data()+headMap.body, msg.size()-4-headMap.body); + } auto waitingDlg = new WaitingDlg(this, tr("Setting")+" ..."); auto res = sendMsg(msg, 0x1EA, 10000, [=](int code, const QByteArray data) { if(code==5) { @@ -813,6 +805,7 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e }, waitingDlg); if(res) QMessageBox::critical(this, "Error", QString(tr("发送失败: "))+QString::fromLocal8Bit(pcap_geterr(pcapSend))); } else if(idx==2) { + if(sendPoint(0)) return; table->setColumnCount(ModuleWidth); table->setRowCount(ModuleHeight); QColor altColor(0x445566); @@ -820,9 +813,10 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e if((r&7)!=7) for(int c=7; citemValid(r, c)->setBackground(altColor); else for(int c=0; citemValid(r, c)->setBackground(altColor); } - stack->setCurrentIndex(++idx); - btnPrev->setEnabled(idx > 0); - btnNext->setEnabled(idx < stack->count()-1); + auto iii = idx+1; + stack->setCurrentIndex(iii); + btnPrev->setEnabled(iii > 0); + btnNext->setEnabled(iii < stack->count()-1); } }); @@ -832,6 +826,22 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e hBox->addSpacing(30); } +int ExpertSmartPointSetWin::sendPoint(uint cnt) { + auto msg = QByteArray::fromHex("5555 01AD 000A FFFFFFFF 0000ABCD B1000011 0000 D10CD484 AD000011 0004 01400000 43233208"); + if(cnt) { + auto idx = (quint32_be*)(msg.data()+msg.size()-8); + *idx |= cnt; + auto check = (quint32_be*)(msg.data()+msg.size()-4); + *check = crc32_calc((byte*)msg.data()+headMap.body, msg.size()-4-headMap.body); + } + auto waitingDlg = new WaitingDlg(this, tr("Setting")+" ..."); + auto res = sendMsgSync(msg, 0x1EA, 10000, waitingDlg); + if(res==5) QMessageBox::critical(this, "Error", tr("请求超时")); + else if(res) QMessageBox::critical(this, "Error", QString(tr("发送失败: "))+QString::fromLocal8Bit(pcap_geterr(pcapSend))); + else waitingDlg->close(); + qDebug()<<"resp back. point:"< #include +#include class ExpertSmartPointSetWin : public BaseWin { Q_OBJECT public: explicit ExpertSmartPointSetWin(ExpertWin *parent = nullptr); + int sendPoint(uint); void save(); ExpertWin *expertWin; @@ -19,6 +21,7 @@ public: int virtualCnt = 0; QList scans; + QRadioButton *fdRow, *fdCol; QSpinBox *fdModuleWidth, *fdModuleHeight, *fdGroupNum; QLineEdit *fdChipType, *fdDecodeMode; Table *tableChipType, *tableDecodeMode; diff --git a/ledset/globalfunc.cpp b/ledset/globalfunc.cpp index 71fcb92..0eeb10b 100644 --- a/ledset/globalfunc.cpp +++ b/ledset/globalfunc.cpp @@ -4,11 +4,22 @@ #include #include #include +#include HeadMap headMap; pcap_t *pcapSend{0}; PcapReThread *reThd{0}; +int sendMsgSync(QByteArray &msg, int id, qint64 timeout, WaitingDlg *waitingDlg) { + QEventLoop loop; + auto res = sendMsg(msg, id, timeout, [=, &loop](int code, const QByteArray data) { + loop.exit(code); + }, waitingDlg); + if(res==0) res = loop.exec(QEventLoop::ExcludeUserInputEvents); + if(res && waitingDlg) waitingDlg->close(); + return res; +} + QByteArray getNetDev(QWidget *parent, QByteArray def, bool justReturnIfHave) { char errbuf[PCAP_ERRBUF_SIZE]; pcap_if_t *devs; diff --git a/ledset/globalfunc.h b/ledset/globalfunc.h index bf65825..ba7d541 100644 --- a/ledset/globalfunc.h +++ b/ledset/globalfunc.h @@ -58,5 +58,5 @@ inline int sendMsg(const byte *msg, int size, int id, qint64 timeout, std::funct inline int sendMsg(QByteArray &msg, int id, qint64 timeout, std::function callback, WaitingDlg *waitingDlg = 0) { return sendMsg((byte*)msg.data(), msg.size(), id, timeout, callback, waitingDlg); } - +int sendMsgSync(QByteArray &msg, int id, qint64 timeout, WaitingDlg *waitingDlg = 0); #endif // GLOBALFUNC_H diff --git a/ledset/gutil/qgui.h b/ledset/gutil/qgui.h index 43bf780..818a268 100644 --- a/ledset/gutil/qgui.h +++ b/ledset/gutil/qgui.h @@ -158,12 +158,16 @@ public: verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); return this; } - inline auto setColWidth(int value) { - horizontalHeader()->setDefaultSectionSize(value); + inline auto setColWidth(int value, QHeaderView::ResizeMode mode = QHeaderView::Interactive) { + auto header = horizontalHeader(); + header->setDefaultSectionSize(value); + if(mode!=QHeaderView::Interactive) header->setSectionResizeMode(mode); return this; } - inline auto setRowHeight(int value) { - verticalHeader()->setDefaultSectionSize(value); + inline auto setRowHeight(int value, QHeaderView::ResizeMode mode = QHeaderView::Interactive) { + auto header = verticalHeader(); + header->setDefaultSectionSize(value); + if(mode!=QHeaderView::Interactive) header->setSectionResizeMode(mode); return this; } @@ -178,6 +182,13 @@ public: return setHeaderText(col, text); } + inline auto setVHeaderText(int row, QString text) { + auto item = verticalHeaderItem(row); + if(item==0) setVerticalHeaderItem(row, item = new QTableWidgetItem()); + item->setText(text); + return item; + } + inline auto appendRow() { auto value = rowCount(); setRowCount(value + 1); diff --git a/ledset/ledset.pro b/ledset/ledset.pro index fad005b..a8af2e5 100644 --- a/ledset/ledset.pro +++ b/ledset/ledset.pro @@ -9,6 +9,8 @@ CONFIG += embed_translations # In order to do so, uncomment the following line. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 +TARGET = $$quote(LedSet Express) + msvc { contains(QT_ARCH, i386) { QMAKE_LFLAGS += /LARGEADDRESSAWARE diff --git a/ledset/main.cpp b/ledset/main.cpp index 73a8dba..8a2cdee 100644 --- a/ledset/main.cpp +++ b/ledset/main.cpp @@ -32,7 +32,7 @@ int main(int argc, char *argv[]) { QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); QApplication::setOrganizationName("Shanghai Xixun Electronic Technology"); - QApplication::setOrganizationDomain("www.ledok.cn"); + QApplication::setOrganizationDomain("ledok.cn"); QApplication::setApplicationName("LedSet Express"); QApplication a(argc, argv); a.setStyle(QStyleFactory::create("Fusion")); @@ -49,19 +49,20 @@ 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:checked {border-image: url(:/imgs/checkbox-check.png);} +QPushButton:disabled {color: #777;} + QPushButton[ss="min"]{padding: 0; width: 30px; height: 25px; } QPushButton[ss="close"]{padding: 0; width: 30px; height: 25px; } 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;} +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"); /* */ QFont font; font.setFamilies(QStringList{"Arial","Microsoft YaHei UI"}); - //font.setPixelSize(14); a.setFont(font); QPalette plt = a.palette(); plt.setBrush(QPalette::Window, QColor(0x333333)); diff --git a/ledset/mainwin.cpp b/ledset/mainwin.cpp index 6624487..237fe34 100644 --- a/ledset/mainwin.cpp +++ b/ledset/mainwin.cpp @@ -157,10 +157,7 @@ MainWin::MainWin() { pcapSend = pcapS; reThd = new PcapReThread(pcapR); reThd->start(); - QSettings config(QApplication::applicationDirPath()+"/ledset.config", QSettings::IniFormat);//QDir::currentPath()为exe位置 - config.beginGroup("GLOBAL"); - config.setValue("net_name", net_name = name); - config.endGroup(); + QSettings().setValue("net_name", net_name = name); }); hstatus->addWidget(btnNetSelect); @@ -172,8 +169,7 @@ MainWin::MainWin() { show(); - QSettings config(QApplication::applicationDirPath()+"/ledset.config", QSettings::IniFormat); - config.beginGroup("GLOBAL");//保存数据 + QSettings config; auto name = config.value("net_name").toByteArray(); name = getNetDev(this, name, true); if(! name.isEmpty()) { @@ -190,7 +186,6 @@ MainWin::MainWin() { } } } - config.endGroup(); getCard(); } diff --git a/ledset/waitingdlg.cpp b/ledset/waitingdlg.cpp index b636bdf..d3a1155 100644 --- a/ledset/waitingdlg.cpp +++ b/ledset/waitingdlg.cpp @@ -22,11 +22,24 @@ WaitingDlg::WaitingDlg(QWidget *parent, QString text, QString sucText) : QDialog vBox->addWidget(fdText); } +void WaitingDlg::closeEvent(QCloseEvent *event) { + if(showTimerId) { + killTimer(showTimerId); + showTimerId = 0; + } + if(closeTimerId) { + killTimer(closeTimerId); + closeTimerId = 0; + } + QDialog::closeEvent(event); +} void WaitingDlg::timerEvent(QTimerEvent *event) { if(showTimerId==event->timerId()) { killTimer(showTimerId); showTimerId = 0; show(); + raise(); + activateWindow(); } else if(closeTimerId==event->timerId()) { killTimer(closeTimerId); closeTimerId = 0; @@ -34,12 +47,18 @@ void WaitingDlg::timerEvent(QTimerEvent *event) { } else QDialog::timerEvent(event); } void WaitingDlg::showLater() { + if(isVisible()) return; if(showTimerId) killTimer(showTimerId); - showTimerId = startTimer(250); + showTimerId = startTimer(200); } void WaitingDlg::success() { fdText->setText(sucText.isEmpty() ? tr("Success") : sucText); mIndicator->success(); + if(showTimerId) { + killTimer(showTimerId); + showTimerId = 0; + } + if(! isVisible()) show(); if(closeTimerId) killTimer(closeTimerId); closeTimerId = startTimer(1000); } diff --git a/ledset/waitingdlg.h b/ledset/waitingdlg.h index 74915f8..4f162af 100644 --- a/ledset/waitingdlg.h +++ b/ledset/waitingdlg.h @@ -42,6 +42,7 @@ public slots: void success(); protected: void timerEvent(QTimerEvent *) override; + void closeEvent(QCloseEvent *) override; private: int closeTimerId{0}, showTimerId{0}; };