|
@ -20,11 +20,13 @@ QString parseReplyJson(QNetworkReply *reply, QJsonDocument *outJson) {
|
||||||
auto error = reply->error();
|
auto error = reply->error();
|
||||||
if(error != QNetworkReply::NoError) {
|
if(error != QNetworkReply::NoError) {
|
||||||
auto errStr = reply->errorString();
|
auto errStr = reply->errorString();
|
||||||
|
if(error!=QNetworkReply::InternalServerError || ! errStr.endsWith("replied: Unknown")) {
|
||||||
if(error==QNetworkReply::OperationCanceledError) {
|
if(error==QNetworkReply::OperationCanceledError) {
|
||||||
error = QNetworkReply::TimeoutError;
|
error = QNetworkReply::TimeoutError;
|
||||||
errStr = QCoreApplication::translate("Def","Connection Timeout");
|
errStr = QCoreApplication::translate("Def","Connection Timeout");
|
||||||
}
|
}
|
||||||
return QString::number(error)+" "+QMetaEnum::fromType<QNetworkReply::NetworkError>().valueToKey(error)+" "+errStr+"\n"+reply->readAll();
|
return QString(QMetaEnum::fromType<QNetworkReply::NetworkError>().valueToKey(error))+" ("+QString::number(error)+")\n"+errStr+"\n"+reply->readAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
auto status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
auto status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
if(status != 200) return QString::number(status)+" "+reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString()+"\n"+reply->readAll();
|
if(status != 200) return QString::number(status)+" "+reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString()+"\n"+reply->readAll();
|
||||||
|
@ -42,18 +44,20 @@ QString checkReplyForJson(QNetworkReply *reply, QJsonDocument *doc) {
|
||||||
auto data = reply->readAll();
|
auto data = reply->readAll();
|
||||||
if(error != QNetworkReply::NoError) {
|
if(error != QNetworkReply::NoError) {
|
||||||
auto errStr = reply->errorString();
|
auto errStr = reply->errorString();
|
||||||
|
if(error!=QNetworkReply::InternalServerError || ! errStr.endsWith("replied: Unknown")) {
|
||||||
if(error==QNetworkReply::OperationCanceledError) {
|
if(error==QNetworkReply::OperationCanceledError) {
|
||||||
error = QNetworkReply::TimeoutError;
|
error = QNetworkReply::TimeoutError;
|
||||||
errStr = QCoreApplication::translate("Def","Connection Timeout");
|
errStr = QCoreApplication::translate("Def","Connection Timeout");
|
||||||
}
|
}
|
||||||
return QString::number(error)+" - "+QMetaEnum::fromType<QNetworkReply::NetworkError>().valueToKey(error)+": "+errStr+"\n"+data;
|
return QString(QMetaEnum::fromType<QNetworkReply::NetworkError>().valueToKey(error))+" ("+QString::number(error)+")\n"+errStr+"\n"+data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
auto status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
auto status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
if(status != 200) return QString::number(status)+" "+reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString()+"\n"+data;
|
if(status != 200) return QString::number(status)+" - "+reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString()+"\n"+data;
|
||||||
QJsonParseError jsonErr;
|
QJsonParseError jsonErr;
|
||||||
QJsonDocument json = QJsonDocument::fromJson(data, &jsonErr);
|
QJsonDocument json = QJsonDocument::fromJson(data, &jsonErr);
|
||||||
if(jsonErr.error != QJsonParseError::NoError) return "JsonError "+jsonErr.errorString()+"\n"+data;
|
if(jsonErr.error != QJsonParseError::NoError) return "JsonError "+jsonErr.errorString()+"\n"+data;
|
||||||
if(! json["success"].toBool()) return QCoreApplication::translate("Def","Fail");
|
if(! json["success"].toBool()) return QCoreApplication::translate("Def","Fail")+"\n"+data;
|
||||||
if(doc) doc->swap(json);
|
if(doc) doc->swap(json);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
15
LedOK/gqt.h
|
@ -90,6 +90,21 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class VBox : public QBoxLayout {
|
||||||
|
public:
|
||||||
|
inline VBox(QWidget *parent=nullptr) : QBoxLayout(TopToBottom, parent) {}
|
||||||
|
inline VBox(QBoxLayout *parent) : QBoxLayout(TopToBottom) {
|
||||||
|
parent->addLayout(this);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
class HBox : public QBoxLayout {
|
||||||
|
public:
|
||||||
|
inline HBox(QWidget *parent=nullptr) : QBoxLayout(LeftToRight, parent) {}
|
||||||
|
inline HBox(QBoxLayout *parent) : QBoxLayout(LeftToRight) {
|
||||||
|
parent->addLayout(this);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
template <typename Func>
|
template <typename Func>
|
||||||
inline QThread *ThreadStart(Func &&f) {
|
inline QThread *ThreadStart(Func &&f) {
|
||||||
QThread* thread = QThread::create(f);
|
QThread* thread = QThread::create(f);
|
||||||
|
|
|
@ -507,37 +507,83 @@ CtrlAdvancedPanel::CtrlAdvancedPanel(QWidget *parent,QList<LedCard *> *list) : Q
|
||||||
btnBindTaxiIc = new QPushButton;
|
btnBindTaxiIc = new QPushButton;
|
||||||
btnBindTaxiIc->setProperty("ssType", "progManageTool");
|
btnBindTaxiIc->setProperty("ssType", "progManageTool");
|
||||||
connect(btnBindTaxiIc, &QPushButton::clicked, this, [this] {
|
connect(btnBindTaxiIc, &QPushButton::clicked, this, [this] {
|
||||||
if(m_pLedlist==nullptr) return;
|
if(gSelCards->isEmpty()) {
|
||||||
CHECK_CARD_SELECTED
|
QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController"));
|
||||||
m_strStartUrl = "http://"+m_pLedCard->m_strCardIp+":3000";
|
return;
|
||||||
|
}
|
||||||
QString icFile = QFileDialog::getOpenFileName(this, "open file dialog", "", tr("indentity voucher (*.ic)"));
|
QString icFile = QFileDialog::getOpenFileName(this, "open file dialog", "", tr("indentity voucher (*.ic)"));
|
||||||
if(icFile.isEmpty()) return;
|
if(icFile.isEmpty()) return;
|
||||||
QFile file(icFile);
|
QFile file(icFile);
|
||||||
file.open(QIODevice::ReadOnly);
|
if(! file.open(QIODevice::ReadOnly)) {
|
||||||
QJsonDocument icJson = QJsonDocument::fromJson(file.readAll());
|
QMessageBox::information(gMainWin, tr("Tip"), tr("Open file Failed"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto data = file.readAll();
|
||||||
file.close();
|
file.close();
|
||||||
|
QJsonParseError jsonErr;
|
||||||
|
QJsonDocument icJson = QJsonDocument::fromJson(data, &jsonErr);
|
||||||
|
if(jsonErr.error != QJsonParseError::NoError) {
|
||||||
|
QMessageBox::information(gMainWin, tr("Tip"), "JsonError "+jsonErr.errorString()+"\n"+data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QJsonObject jsonCommand;
|
||||||
|
jsonCommand.insert("action", "BindAccount");
|
||||||
|
jsonCommand.insert("accountIdToken", icJson["account_id_token"]);
|
||||||
|
jsonCommand.insert("server", icJson["taxiServerURL"]);
|
||||||
|
jsonCommand.insert("tlsServer", icJson["taxiServerTLSURL"]);
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
json.insert("action", "InvokeTaxiAppFunction");
|
json.insert("action", "InvokeTaxiAppFunction");
|
||||||
|
json.insert("jsonCommand", jsonCommand);
|
||||||
QJsonObject subJson;
|
if(gSelCards->count() == 1) {
|
||||||
subJson.insert("action", "BindAccount");
|
auto waitingDlg = new WaitingDlg(this, tr("InvokeTaxiAppFunction"));
|
||||||
subJson.insert("accountIdToken", icJson["account_id_token"].toString());
|
waitingDlg->show();
|
||||||
subJson.insert("server", icJson["taxiServerURL"].toString());
|
auto reply = Tools::netManager().post(reqForJson("http://"+gSelCards->at(0)->m_strCardIp+":3000"), QJsonDocument{json}.toJson(QJsonDocument::Compact));
|
||||||
subJson.insert("tlsServer", icJson["taxiServerTLSURL"].toString());
|
connect(reply, &QNetworkReply::finished, this, [reply, waitingDlg] {
|
||||||
json.insert("jsonCommand", subJson);
|
QString err = parseReplyJson(reply);
|
||||||
if(m_pLedlist->count()==1) {
|
if(! err.isEmpty()) {
|
||||||
if(m_pLedCard!=nullptr) {
|
waitingDlg->close();
|
||||||
HttpPostByTypeJsonObject(pHpptClient,m_strStartUrl,json);
|
QMessageBox::critical(gMainWin, tr("Error"), err);
|
||||||
if(m_PostingDlg==nullptr) {
|
return;
|
||||||
m_PostingDlg = new LoEmptyDialog(this);
|
}
|
||||||
connect(m_PostingDlg,SIGNAL(sigClose()),this,SLOT(DeletePostingDlg()));
|
auto data = reply->readAll();
|
||||||
connect(m_pGetAskTimer,SIGNAL(timeout()),m_PostingDlg,SLOT(TimerOutUnlock()));
|
QJsonParseError jsonErr;
|
||||||
m_PostingDlg->lock(tr("InvokeTaxiAppFunction"),tr("Success"),tr("failed"));
|
QJsonDocument json = QJsonDocument::fromJson(data, &jsonErr);
|
||||||
m_pGetAskTimer->start(5000);
|
if(jsonErr.error != QJsonParseError::NoError) {
|
||||||
m_PostingDlg->exec();
|
waitingDlg->close();
|
||||||
|
QMessageBox::critical(gMainWin, tr("Error"), "JsonError "+jsonErr.errorString()+"\n"+data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(json["result"].toString() != "true") {
|
||||||
|
waitingDlg->close();
|
||||||
|
QMessageBox::critical(gMainWin, tr("Error"), data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
waitingDlg->success();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
foreach(auto card, *gSelCards) {
|
||||||
|
auto reply = Tools::netManager().post(reqForJson("http://"+card->m_strCardIp+":3000"), QJsonDocument{json}.toJson(QJsonDocument::Compact));
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [reply, card] {
|
||||||
|
QString err = parseReplyJson(reply);
|
||||||
|
if(! err.isEmpty()) {
|
||||||
|
gFdResInfo->append(card->m_strCardId+" "+tr("InvokeTaxiAppFunction")+" "+tr("Error")+" "+err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto data = reply->readAll();
|
||||||
|
QJsonParseError jsonErr;
|
||||||
|
QJsonDocument json = QJsonDocument::fromJson(data, &jsonErr);
|
||||||
|
if(jsonErr.error != QJsonParseError::NoError) {
|
||||||
|
gFdResInfo->append(card->m_strCardId+" "+tr("InvokeTaxiAppFunction")+" "+tr("Error")+" JsonError "+jsonErr.errorString()+"\n"+data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(json["result"].toString() != "true") {
|
||||||
|
gFdResInfo->append(card->m_strCardId+" "+tr("InvokeTaxiAppFunction")+" "+tr("Error")+" "+data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
gFdResInfo->append(card->m_strCardId+" "+tr("InvokeTaxiAppFunction")+" "+QCoreApplication::translate("Def","Success"));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else emit sigSend(json,tr("InvokeTaxiAppFunction"));
|
|
||||||
});
|
});
|
||||||
hBox->addWidget(btnBindTaxiIc);
|
hBox->addWidget(btnBindTaxiIc);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
|
@ -1,57 +1,119 @@
|
||||||
#include "expertscreenconnwin.h"
|
#include "expertscreenconnwin.h"
|
||||||
#include <QBoxLayout>
|
#include "gqt.h"
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QButtonGroup>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QTableWidget>
|
||||||
|
#include <QHeaderView>
|
||||||
|
|
||||||
|
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 vBox = new QVBoxLayout(this);
|
auto vv = new QVBoxLayout(this);
|
||||||
vBox->setContentsMargins(4, 4, 4, 4);
|
vv->setContentsMargins(4, 4, 4, 4);
|
||||||
|
|
||||||
auto hh = new QHBoxLayout;
|
auto hh = new QHBoxLayout;
|
||||||
vBox->addLayout(hh);
|
vv->addLayout(hh);
|
||||||
|
|
||||||
auto vvv = new QVBoxLayout;
|
auto leftWgt = new QWidget;
|
||||||
hh->addLayout(vvv);
|
auto poli = leftWgt->sizePolicy();
|
||||||
|
poli.setHorizontalPolicy(QSizePolicy::Maximum);
|
||||||
|
leftWgt->setSizePolicy(poli);
|
||||||
|
hh->addWidget(leftWgt);
|
||||||
|
|
||||||
auto gBox = new QGroupBox("接收卡设置");
|
auto vvv = new QVBoxLayout(leftWgt);
|
||||||
|
vvv->setContentsMargins(0,0,0,0);
|
||||||
|
|
||||||
|
auto gBox = new QGroupBox("起始位置");
|
||||||
vvv->addWidget(gBox);
|
vvv->addWidget(gBox);
|
||||||
|
|
||||||
|
auto fdX = new QSpinBox;
|
||||||
|
auto fdY = new QSpinBox;
|
||||||
|
{
|
||||||
auto hhh = new QHBoxLayout(gBox);
|
auto hhh = new QHBoxLayout(gBox);
|
||||||
|
|
||||||
auto lb = new QLabel("卡宽度: ");
|
auto lb = new QLabel("X坐标: ");
|
||||||
hhh->addWidget(lb);
|
hhh->addWidget(lb);
|
||||||
|
|
||||||
auto fdReCardWidth = new QSpinBox;
|
fdX->setRange(0, 99999);
|
||||||
fdReCardWidth->setRange(0, 9999);
|
fdX->setValue(0);
|
||||||
fdReCardWidth->setValue(128);
|
hhh->addWidget(fdX);
|
||||||
hhh->addWidget(fdReCardWidth);
|
|
||||||
|
lb = new QLabel("Y坐标: ");
|
||||||
|
hhh->addWidget(lb);
|
||||||
|
|
||||||
|
fdY->setRange(0, 99999);
|
||||||
|
fdY->setValue(0);
|
||||||
|
hhh->addWidget(fdY);
|
||||||
|
}
|
||||||
|
|
||||||
|
gBox = new QGroupBox("接收卡设置");
|
||||||
|
vvv->addWidget(gBox);
|
||||||
|
|
||||||
|
auto fdCardColNum = new QSpinBox;
|
||||||
|
auto fdCardRowNum = new QSpinBox;
|
||||||
|
auto fdCardWidth = new QSpinBox;
|
||||||
|
auto fdCardHeight = new QSpinBox;
|
||||||
|
{
|
||||||
|
auto vBox = new QVBoxLayout(gBox);
|
||||||
|
auto hhh = new QHBoxLayout;
|
||||||
|
vBox->addLayout(hhh);
|
||||||
|
|
||||||
|
auto lb = new QLabel("卡列数: ");
|
||||||
|
hhh->addWidget(lb);
|
||||||
|
|
||||||
|
fdCardColNum->setRange(0, 9999);
|
||||||
|
fdCardColNum->setValue(2);
|
||||||
|
// connect(fdCardColNum, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
|
||||||
|
// table->setColumnCount(value);
|
||||||
|
// });
|
||||||
|
hhh->addWidget(fdCardColNum);
|
||||||
|
|
||||||
|
lb = new QLabel("卡行数: ");
|
||||||
|
hhh->addWidget(lb);
|
||||||
|
|
||||||
|
fdCardRowNum->setRange(0, 9999);
|
||||||
|
fdCardRowNum->setValue(2);
|
||||||
|
|
||||||
|
hhh->addWidget(fdCardRowNum);
|
||||||
|
|
||||||
|
vBox->addLayout(hhh = new QHBoxLayout);
|
||||||
|
|
||||||
|
lb = new QLabel("卡宽度: ");
|
||||||
|
hhh->addWidget(lb);
|
||||||
|
|
||||||
|
fdCardWidth->setRange(0, 9999);
|
||||||
|
fdCardWidth->setValue(128);
|
||||||
|
hhh->addWidget(fdCardWidth);
|
||||||
|
|
||||||
lb = new QLabel("卡高度: ");
|
lb = new QLabel("卡高度: ");
|
||||||
hhh->addWidget(lb);
|
hhh->addWidget(lb);
|
||||||
|
|
||||||
auto fdReCardHeight = new QSpinBox;
|
fdCardHeight->setRange(0, 9999);
|
||||||
fdReCardHeight->setRange(0, 9999);
|
fdCardHeight->setValue(128);
|
||||||
fdReCardHeight->setValue(64);
|
hhh->addWidget(fdCardHeight);
|
||||||
hhh->addWidget(fdReCardHeight);
|
}
|
||||||
|
|
||||||
gBox = new QGroupBox("网口选择");
|
gBox = new QGroupBox("网口选择");
|
||||||
vvv->addWidget(gBox);
|
vvv->addWidget(gBox);
|
||||||
hhh = new QHBoxLayout(gBox);
|
auto hhh = new QHBoxLayout(gBox);
|
||||||
|
|
||||||
auto bnNet1 = new QPushButton("1");
|
|
||||||
hhh->addWidget(bnNet1);
|
|
||||||
|
|
||||||
auto bnNet2 = new QPushButton("2");
|
|
||||||
hhh->addWidget(bnNet2);
|
|
||||||
|
|
||||||
auto bnNet3 = new QPushButton("3");
|
|
||||||
hhh->addWidget(bnNet3);
|
|
||||||
|
|
||||||
auto bnNet4 = new QPushButton("4");
|
|
||||||
hhh->addWidget(bnNet4);
|
|
||||||
|
|
||||||
|
auto pal = palette();
|
||||||
|
auto fdNet = new QButtonGroup(gBox);
|
||||||
|
for(int i=0; i<netss.size(); i++) {
|
||||||
|
auto bn = new QPushButton(QString::number(i+1));
|
||||||
|
bn->setCheckable(true);
|
||||||
|
if(i==0) bn->setChecked(true);
|
||||||
|
bn->setMinimumHeight(30);
|
||||||
|
pal.setColor(QPalette::ButtonText, cardColors[i%(sizeof(cardColors)/sizeof(cardColors[0]))]);
|
||||||
|
bn->setPalette(pal);
|
||||||
|
hhh->addWidget(bn);
|
||||||
|
fdNet->addButton(bn, i);
|
||||||
|
}
|
||||||
|
|
||||||
gBox = new QGroupBox("快速串线:");
|
gBox = new QGroupBox("快速串线:");
|
||||||
gBox->setStyleSheet("QToolButton {border: none; }");
|
gBox->setStyleSheet("QToolButton {border: none; }");
|
||||||
|
@ -104,16 +166,76 @@ ExpertScreenConnWin::ExpertScreenConnWin(QWidget *parent) : QWidget{parent} {
|
||||||
bnConn8->setIcon(QIcon(":/imgs/conn8.png"));
|
bnConn8->setIcon(QIcon(":/imgs/conn8.png"));
|
||||||
hhh->addWidget(bnConn8);
|
hhh->addWidget(bnConn8);
|
||||||
}
|
}
|
||||||
vvv->addStretch();
|
|
||||||
|
|
||||||
vvv = new QVBoxLayout;
|
vvv->addLayout(hhh = new QHBoxLayout);
|
||||||
hh->addLayout(vvv);
|
|
||||||
|
|
||||||
hhh = new QHBoxLayout;
|
auto bnRefresh = new QPushButton("重新开始");
|
||||||
vvv->addLayout(hhh);
|
connect(bnRefresh, &QPushButton::clicked, this, [this] {
|
||||||
|
table->clearContents();
|
||||||
auto bnRefresh = new QToolButton;
|
for(int i=0; i<netss.size(); i++) if(! netss[i].isEmpty()) netss[i].clear();
|
||||||
|
});
|
||||||
hhh->addWidget(bnRefresh);
|
hhh->addWidget(bnRefresh);
|
||||||
|
|
||||||
|
auto bnBack = new QPushButton("后退");
|
||||||
|
connect(bnBack, &QPushButton::clicked, this, [this, fdNet] {
|
||||||
|
auto netIdx = fdNet->checkedId();
|
||||||
|
if(netss[netIdx].isEmpty()) return;
|
||||||
|
auto sels = table->selectedItems();
|
||||||
|
if(! sels.isEmpty()) sels[0]->setSelected(false);
|
||||||
|
auto point = netss[netIdx].takeLast();
|
||||||
|
table->setItem(point.y(), point.x(), 0);
|
||||||
|
table->update();
|
||||||
|
});
|
||||||
|
hhh->addWidget(bnBack);
|
||||||
|
|
||||||
hhh->addStretch();
|
hhh->addStretch();
|
||||||
|
|
||||||
|
vvv->addStretch();
|
||||||
|
|
||||||
|
table = new CardTable(fdCardRowNum->value(), fdCardColNum->value());
|
||||||
|
table->win = this;
|
||||||
|
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||||
|
table->horizontalHeader()->setDefaultAlignment(Qt::AlignCenter);
|
||||||
|
table->horizontalHeader()->setDefaultSectionSize(90);
|
||||||
|
table->verticalHeader()->setDefaultAlignment(Qt::AlignCenter);
|
||||||
|
table->verticalHeader()->setDefaultSectionSize(90);
|
||||||
|
table->verticalHeader()->setMinimumWidth(30);
|
||||||
|
table->setSelectionMode(QTableWidget::SingleSelection);
|
||||||
|
connect(table, &QTableWidget::currentCellChanged, this, [this, fdNet, fdCardWidth, fdCardHeight](int row, int column) {
|
||||||
|
auto item = table->item(row, column);
|
||||||
|
if(item) {
|
||||||
|
auto netIdx = item->data(Qt::UserRole).toInt();
|
||||||
|
table->setStyleSheet("QTableView{selection-color:"+cardColors[netIdx % (sizeof(cardColors)/sizeof(cardColors[0]))].name()+";}");
|
||||||
|
//fdNet->button(netIdx)->setChecked(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto netIdx = fdNet->checkedId();
|
||||||
|
netss[netIdx].append(QPoint(column, row));
|
||||||
|
item = new QTableWidgetItem("网口: "+QString::number(netIdx+1)+"\n接收卡: "+QString::number(netss[netIdx].size())+"\n宽度: "+QString::number(fdCardWidth->value())+"\n高度: "+QString::number(fdCardHeight->value()));
|
||||||
|
auto color = cardColors[netIdx % (sizeof(cardColors)/sizeof(cardColors[0]))];
|
||||||
|
item->setForeground(color);
|
||||||
|
table->setStyleSheet("QTableView{selection-color:"+color.name()+";}");
|
||||||
|
item->setData(Qt::UserRole, netIdx);
|
||||||
|
table->setItem(row, column, item);
|
||||||
|
table->update();
|
||||||
|
});
|
||||||
|
connect(fdCardColNum, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, table, &QTableWidget::setColumnCount);
|
||||||
|
connect(fdCardRowNum, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, table, &QTableWidget::setRowCount);
|
||||||
|
hh->addWidget(table);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CardTable::paintEvent(QPaintEvent *event) {
|
||||||
|
QTableWidget::paintEvent(event);
|
||||||
|
QPainter painter(viewport());
|
||||||
|
for(int i=0; i<win->netss.size(); i++) {
|
||||||
|
auto size = win->netss[i].size();
|
||||||
|
if(size < 2) continue;
|
||||||
|
painter.setPen(QPen(cardColors[i % (sizeof(cardColors)/sizeof(cardColors[0]))], 2));
|
||||||
|
int off = 45 + (i+1)/2 * (i%2 ? -4 : 4);
|
||||||
|
for(int j=1; j<size; j++) {
|
||||||
|
auto point1 = win->netss[i][j-1];
|
||||||
|
auto point2 = win->netss[i][j];
|
||||||
|
painter.drawLine(point1.x()*90+off, point1.y()*90+off, point2.x()*90+off, point2.y()*90+off);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,24 @@
|
||||||
#ifndef EXPERTSCREENCONNWIN_H
|
#ifndef EXPERTSCREENCONNWIN_H
|
||||||
#define EXPERTSCREENCONNWIN_H
|
#define EXPERTSCREENCONNWIN_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QTableWidget>
|
||||||
|
|
||||||
|
class CardTable;
|
||||||
class ExpertScreenConnWin : public QWidget {
|
class ExpertScreenConnWin : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ExpertScreenConnWin(QWidget *parent = nullptr);
|
explicit ExpertScreenConnWin(QWidget *parent = nullptr);
|
||||||
|
CardTable *table;
|
||||||
|
QList<QList<QPoint>> netss{QList<QPoint>{}, QList<QPoint>{}, QList<QPoint>{}, QList<QPoint>{}};
|
||||||
|
};
|
||||||
|
|
||||||
signals:
|
class CardTable : public QTableWidget {
|
||||||
|
public:
|
||||||
|
explicit CardTable(QWidget *parent = nullptr) : QTableWidget{parent} {}
|
||||||
|
CardTable(int rows, int columns, QWidget *parent = nullptr) : QTableWidget{rows, columns, parent} {}
|
||||||
|
ExpertScreenConnWin *win;
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *event);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EXPERTSCREENCONNWIN_H
|
#endif // EXPERTSCREENCONNWIN_H
|
||||||
|
|
|
@ -315,10 +315,7 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(QWidget *parent) : BaseWin{parent
|
||||||
auto bnReset = new QPushButton("重新走点");
|
auto bnReset = new QPushButton("重新走点");
|
||||||
bnReset->setMinimumSize(90, 30);
|
bnReset->setMinimumSize(90, 30);
|
||||||
connect(bnReset, &QPushButton::clicked, this, [this] {
|
connect(bnReset, &QPushButton::clicked, this, [this] {
|
||||||
table->setColumnCount(0);
|
table->clearContents();
|
||||||
table->setRowCount(0);
|
|
||||||
table->setColumnCount(moduleWidth);
|
|
||||||
table->setRowCount(moduleHeight);
|
|
||||||
curPoint = 0;
|
curPoint = 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "expertwin.h"
|
#include "expertwin.h"
|
||||||
|
#include "gqt.h"
|
||||||
#include "table.h"
|
#include "table.h"
|
||||||
#include "screenunit.h"
|
#include "screenunit.h"
|
||||||
#include "expertsmartpointsetwin.h"
|
#include "expertsmartpointsetwin.h"
|
||||||
|
@ -86,14 +87,14 @@ QTabBar::tab:selected {margin-top: 0; border-bottom: none; color: #acf; backgrou
|
||||||
vLeft->addWidget(table);
|
vLeft->addWidget(table);
|
||||||
table->setRowCount(4);
|
table->setRowCount(4);
|
||||||
|
|
||||||
auto canvas = new Canvas;
|
auto canvas = new ResizeEmitedWgt;
|
||||||
auto screen = new QWidget(canvas);
|
auto screen = new QWidget(canvas);
|
||||||
screen->setGeometry(0, 0, screenWidth, screenHeight);
|
screen->setGeometry(0, 0, screenWidth, screenHeight);
|
||||||
screen->setAutoFillBackground(true);
|
screen->setAutoFillBackground(true);
|
||||||
auto pal = palette();
|
auto pal = palette();
|
||||||
pal.setColor(QPalette::Window, QColor(0, 0, 0));
|
pal.setColor(QPalette::Window, QColor(0, 0, 0));
|
||||||
screen->setPalette(pal);
|
screen->setPalette(pal);
|
||||||
connect(canvas, &Canvas::resized, this, [this, canvas, screen] {
|
connect(canvas, &ResizeEmitedWgt::resized, this, [this, canvas, screen] {
|
||||||
rate = qMin(canvas->width()/(double)screenWidth, canvas->height()/(double)screenHeight);
|
rate = qMin(canvas->width()/(double)screenWidth, canvas->height()/(double)screenHeight);
|
||||||
if(rate==0) return;
|
if(rate==0) return;
|
||||||
screen->resize(qRound(screenWidth*rate), qRound(screenHeight*rate));
|
screen->resize(qRound(screenWidth*rate), qRound(screenHeight*rate));
|
||||||
|
|
|
@ -10,20 +10,6 @@ public:
|
||||||
|
|
||||||
int screenWidth{1280}, screenHeight{720};
|
int screenWidth{1280}, screenHeight{720};
|
||||||
double rate{1};
|
double rate{1};
|
||||||
signals:
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Canvas : public QWidget {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit Canvas(QWidget *parent = nullptr) : QWidget{parent} {}
|
|
||||||
protected:
|
|
||||||
void resizeEvent(QResizeEvent *) override {
|
|
||||||
emit resized();
|
|
||||||
};
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void resized();
|
|
||||||
};
|
|
||||||
#endif // EXPERTWIN_H
|
#endif // EXPERTWIN_H
|
||||||
|
|
|
@ -1,4 +1 @@
|
||||||
#include "gqt.h"
|
#include "gqt.h"
|
||||||
|
|
||||||
Label::Label(QWidget *parent, Qt::WindowFlags f) : QLabel(parent, f), Wgt(this){}
|
|
||||||
Label::Label(const QString &text, QWidget *parent, Qt::WindowFlags f) : QLabel(text, parent, f), Wgt(this){}
|
|
||||||
|
|
137
ledset/gqt.h
|
@ -1,33 +1,132 @@
|
||||||
#ifndef GLABEL_H
|
#ifndef GQT_H
|
||||||
#define GLABEL_H
|
#define GQT_H
|
||||||
#include <QVBoxLayout>
|
#include <QLayout>
|
||||||
#include <QLabel>
|
#include <QThread>
|
||||||
|
#include <QComboBox>
|
||||||
|
|
||||||
|
inline long long steady_milli() {
|
||||||
|
return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
|
||||||
|
}
|
||||||
|
inline long long system_milli() {
|
||||||
|
return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
|
||||||
|
}
|
||||||
|
inline long long steady_micro() {
|
||||||
|
return std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
|
||||||
|
}
|
||||||
|
inline long long system_micro() {
|
||||||
|
return std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
|
||||||
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
class Wgt{
|
class Wrp {
|
||||||
public:
|
public:
|
||||||
T *wgt;
|
T *obj;
|
||||||
Wgt(T *wgt = nullptr){
|
Wrp(T *obj = nullptr){
|
||||||
this->wgt = wgt;
|
this->obj = obj;
|
||||||
};
|
};
|
||||||
inline Wgt* margin(int a){
|
inline Wrp& operator()(T *obj){
|
||||||
wgt->setMargin(a);
|
this->obj = obj;
|
||||||
return this;
|
return *this;
|
||||||
|
}
|
||||||
|
inline Wrp& operator()(T *obj, QLayout *layout){
|
||||||
|
this->obj = obj;
|
||||||
|
layout->addWidget(obj);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
inline Wrp& addTo(QLayout *layout){
|
||||||
|
layout->addWidget(obj);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
inline Wrp& margin(int a){
|
||||||
|
obj->setMargin(a);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
inline Wrp& font(const QFont &font){
|
||||||
|
obj->setFont(font);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
inline Wrp& font(int size){
|
||||||
|
QFont font = obj->font();
|
||||||
|
font.setPointSize(size);
|
||||||
|
obj->setFont(font);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Wrp& width(int w){
|
||||||
|
obj->setFixedWidth(w);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
inline Wrp& height(int h){
|
||||||
|
obj->setFixedHeight(h);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
inline Wrp& padding(int wAdd, int hAdd, int minW = 32, int minH = 16){
|
||||||
|
wAdd+=8;
|
||||||
|
hAdd+=8;
|
||||||
|
QSize size = obj->fontMetrics().size(Qt::TextShowMnemonic, obj->text());
|
||||||
|
int &rwidth = size.rwidth();
|
||||||
|
rwidth += wAdd;
|
||||||
|
if(rwidth < minW) rwidth = minW;
|
||||||
|
int &rheight = size.rheight();
|
||||||
|
rheight += hAdd;
|
||||||
|
if(rheight < minH) rheight = minH;
|
||||||
|
obj->setFixedSize(size);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Wrp& alignC(){
|
||||||
|
obj->setAlignment(Qt::AlignCenter);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
inline Wrp& alignR(){
|
||||||
|
obj->setAlignment(Qt::AlignRight);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Wrp& connStart(){
|
||||||
|
QObject::connect(obj, &QThread::finished, obj, &QThread::deleteLater);
|
||||||
|
obj->start();
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class VBox : public QVBoxLayout{
|
class VBox : public QBoxLayout {
|
||||||
public:
|
public:
|
||||||
inline VBox(QWidget *parent=nullptr) : QVBoxLayout(parent){}
|
inline VBox(QWidget *parent=nullptr) : QBoxLayout(TopToBottom, parent) {}
|
||||||
inline VBox(QBoxLayout *boxLayout){
|
inline VBox(QBoxLayout *parent) : QBoxLayout(TopToBottom) {
|
||||||
boxLayout->addLayout(this);
|
parent->addLayout(this);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
class HBox : public QBoxLayout {
|
||||||
|
public:
|
||||||
|
inline HBox(QWidget *parent=nullptr) : QBoxLayout(LeftToRight, parent) {}
|
||||||
|
inline HBox(QBoxLayout *parent) : QBoxLayout(LeftToRight) {
|
||||||
|
parent->addLayout(this);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
class Label : public QLabel, public Wgt<Label>{
|
class ResizeEmitedWgt : public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit Label(QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags());
|
explicit ResizeEmitedWgt(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()) : QWidget{parent, f} {}
|
||||||
explicit Label(const QString &text, QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags());
|
protected:
|
||||||
|
void resizeEvent(QResizeEvent *) override {emit resized();}
|
||||||
|
signals:
|
||||||
|
void resized();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GLABEL_H
|
template <typename Func>
|
||||||
|
inline QThread *ThreadStart(Func &&f) {
|
||||||
|
QThread* thread = QThread::create(f);
|
||||||
|
QObject::connect(thread, &QThread::finished, thread, &QThread::deleteLater);
|
||||||
|
thread->start();
|
||||||
|
return thread;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void select(QComboBox *combo, const QVariant &data) {
|
||||||
|
int idx = combo->findData(data);
|
||||||
|
if(idx!=-1) combo->setCurrentIndex(idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 972 B |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 983 B |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 940 B |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 942 B |
|
@ -69,6 +69,7 @@ QLineEdit, QComboBox, QSpinBox {border-radius: 2px; padding: 2px; background: #2
|
||||||
QPushButton{border-radius: 4px; padding: 2px 6px; background: #222;}
|
QPushButton{border-radius: 4px; padding: 2px 6px; background: #222;}
|
||||||
QPushButton:hover {background: #444;}
|
QPushButton:hover {background: #444;}
|
||||||
QPushButton:pressed {background: #666;}
|
QPushButton:pressed {background: #666;}
|
||||||
|
QPushButton:checked {background: #026; border-color: #06f;}
|
||||||
|
|
||||||
QPushButton[ss="min"]{border-radius: 4px; padding: 0; width: 30px; height: 25px; background: #07c;}
|
QPushButton[ss="min"]{border-radius: 4px; padding: 0; width: 30px; height: 25px; background: #07c;}
|
||||||
QPushButton[ss="close"]{border-radius: 4px; padding: 0; width: 30px; height: 25px; background: #e22;}
|
QPushButton[ss="close"]{border-radius: 4px; padding: 0; width: 30px; height: 25px; background: #e22;}
|
||||||
|
@ -78,7 +79,7 @@ QRadioButton::indicator:checked {border-image: url(:/imgs/radio-check.png);}
|
||||||
|
|
||||||
QAbstractScrollArea QScrollBar {background: #555;}
|
QAbstractScrollArea QScrollBar {background: #555;}
|
||||||
|
|
||||||
QTableView {gridline-color:#888;}
|
QTableView {gridline-color:#888; selection-background-color: #226; selection-color: #fff;}
|
||||||
QHeaderView::section, QTableCornerButton:section {background: #555;}
|
QHeaderView::section, QTableCornerButton:section {background: #555;}
|
||||||
|
|
||||||
QSlider::horizontal {height: 16px;}
|
QSlider::horizontal {height: 16px;}
|
||||||
|
|
|
@ -4,16 +4,15 @@
|
||||||
#include "brightwin.h"
|
#include "brightwin.h"
|
||||||
#include "pcapwin.h"
|
#include "pcapwin.h"
|
||||||
#include "gqt.h"
|
#include "gqt.h"
|
||||||
#include <QVBoxLayout>
|
#include <QLabel>
|
||||||
#include <QHBoxLayout>
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPainterPath>
|
#include <QPainterPath>
|
||||||
#include <QDebug>
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
class ImgBtn : public QToolButton {
|
class ImgBtn : public QToolButton {
|
||||||
public:
|
public:
|
||||||
ImgBtn(QIcon icon) {
|
ImgBtn(QIcon icon) {
|
||||||
|
|