This commit is contained in:
Gangphon 2024-05-23 17:13:51 +08:00
parent 332897f9cf
commit 2e0aefd05a
19 changed files with 3443 additions and 2969 deletions

View File

@ -19,7 +19,7 @@ CONFIG += lrelease
CONFIG += embed_translations CONFIG += embed_translations
# CONFIG += console # CONFIG += console
DEFINES += leyide
# You can also make your code fail to compile if you use deprecated APIs. # You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line. # In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt. # You can also select to disable deprecated APIs only up to a certain version of Qt.
@ -108,6 +108,7 @@ SOURCES += \
base/lodateselector.cpp \ base/lodateselector.cpp \
base/loqtitlebar.cpp \ base/loqtitlebar.cpp \
base/loqtreewidget.cpp \ base/loqtreewidget.cpp \
device/progressesdlg.cpp \
gutil/qcore.cpp \ gutil/qcore.cpp \
gutil/qwaitingdlg.cpp \ gutil/qwaitingdlg.cpp \
basedlg.cpp \ basedlg.cpp \
@ -176,6 +177,7 @@ HEADERS += \
base/lodateselector.h \ base/lodateselector.h \
base/loqtitlebar.h \ base/loqtitlebar.h \
base/loqtreewidget.h \ base/loqtreewidget.h \
device/progressesdlg.h \
gutil/qcore.h \ gutil/qcore.h \
gutil/qwaitingdlg.h \ gutil/qwaitingdlg.h \
basedlg.h \ basedlg.h \

View File

@ -1,4 +1,5 @@
#include "ctrladvancedpanel.h" #include "ctrladvancedpanel.h"
#include "device/progressesdlg.h"
#include "globaldefine.h" #include "globaldefine.h"
#include "gutil/qwaitingdlg.h" #include "gutil/qwaitingdlg.h"
#include "base/changepasswordform.h" #include "base/changepasswordform.h"
@ -634,6 +635,8 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
} }
JObj json{{"_type", "GetFile"}, {"name", "program"}}; JObj json{{"_type", "GetFile"}, {"name", "program"}};
auto fd = new QTextEdit; auto fd = new QTextEdit;
LocalObj lll;
connect(fd, &QTextEdit::destroyed, &lll, &LocalObj::reset);
fd->setAttribute(Qt::WA_DeleteOnClose); fd->setAttribute(Qt::WA_DeleteOnClose);
fd->setTabStopDistance(26); fd->setTabStopDistance(26);
auto ft = fd->font(); auto ft = fd->font();
@ -643,30 +646,38 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
fd->resize(600, 900); fd->resize(600, 900);
fd->show(); fd->show();
for(auto &card : gSelCards) { for(auto &card : gSelCards) {
auto tcp = new TcpSocket; fd->append(card.id+" Prog JSON");
auto cardId = card.id; TcpSocket tcp;
connect(fd, &QTextEdit::destroyed, tcp, &QTcpSocket::deleteLater); tcp.connectToHost(card.ip, 3333);
connect(tcp, &QTcpSocket::connected, tcp, [=] { if(! tcp.waitForConnected()) {
tcp->stopTimer(); if(lll.cnt==0) return;
tcp->write(JToBytes(json)); fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitConnected\n");
tcp->startTimer(10000); tcp.close();
}); continue;
connect(tcp, &QTcpSocket::readyRead, fd, [=] { }
tcp->stopTimer(); auto resNum = tcp.write(JToBytes(json));
auto resp = tcp->readAll(); tcp.flush();
tcp->close(); if(resNum == -1 || ! tcp.waitForBytesWritten()) {
tcp->deleteLater(); if(lll.cnt==0) return;
fd->append(cardId+" Prog JSON"); fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at write\n");
fd->append(resp); tcp.close();
fd->append(""); continue;
}); }
connect(tcp, &QTcpSocket::errorOccurred, fd, [=](QAbstractSocket::SocketError err) { if(! tcp.waitForReadyRead()) {
tcp->close(); if(lll.cnt==0) return;
tcp->deleteLater(); fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead\n");
fd->append(cardId+" View Prog JSON "+socketErrKey(err)+" ("+QString::number(err)+") "+tcp->errorString()); tcp.close();
}); continue;
tcp->connectToHost(card.ip, 3333); }
tcp->startTimer(10000); fd->append(tcp.readAll());
while(tcp.waitForReadyRead(1000)) {
if(lll.cnt==0) return;
fd->append(tcp.readAll());
}
if(lll.cnt==0) return;
if(tcp.error()!=QAbstractSocket::SocketTimeoutError) fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead2\n");
tcp.close();
fd->append("");
} }
}); });
hBox->addWidget(btnViewProg); hBox->addWidget(btnViewProg);
@ -680,6 +691,8 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
} }
JObj json{{"_type", "ListProgFiles"}}; JObj json{{"_type", "ListProgFiles"}};
auto fd = new QTextEdit; auto fd = new QTextEdit;
LocalObj lll;
connect(fd, &QTextEdit::destroyed, &lll, &LocalObj::reset);
fd->setAttribute(Qt::WA_DeleteOnClose); fd->setAttribute(Qt::WA_DeleteOnClose);
auto ft = fd->font(); auto ft = fd->font();
ft.setFamily("Consolas"); ft.setFamily("Consolas");
@ -688,30 +701,38 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
fd->resize(600, 900); fd->resize(600, 900);
fd->show(); fd->show();
for(auto &card : gSelCards) { for(auto &card : gSelCards) {
auto tcp = new TcpSocket; fd->append(card.id+" Prog Files");
auto cardId = card.id; TcpSocket tcp;
connect(fd, &QTextEdit::destroyed, tcp, &QTcpSocket::deleteLater); tcp.connectToHost(card.ip, 3333);
connect(tcp, &QTcpSocket::connected, tcp, [=] { if(! tcp.waitForConnected()) {
tcp->stopTimer(); if(lll.cnt==0) return;
tcp->write(JToBytes(json)); fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitConnected\n");
tcp->startTimer(10000); tcp.close();
}); continue;
connect(tcp, &QTcpSocket::readyRead, fd, [=] { }
tcp->stopTimer(); auto resNum = tcp.write(JToBytes(json));
auto resp = tcp->readAll(); tcp.flush();
tcp->close(); if(resNum == -1 || ! tcp.waitForBytesWritten()) {
tcp->deleteLater(); if(lll.cnt==0) return;
fd->append(cardId+" Prog Files"); fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at write\n");
fd->append(resp); tcp.close();
fd->append(""); continue;
}); }
connect(tcp, &QTcpSocket::errorOccurred, fd, [=](QAbstractSocket::SocketError err) { if(! tcp.waitForReadyRead()) {
tcp->close(); if(lll.cnt==0) return;
tcp->deleteLater(); fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead\n");
fd->append(cardId+" List Prog Files "+socketErrKey(err)+" ("+QString::number(err)+") "+tcp->errorString()); tcp.close();
}); continue;
tcp->connectToHost(card.ip, 3333); }
tcp->startTimer(10000); fd->append(tcp.readAll());
while(tcp.waitForReadyRead(1000)) {
if(lll.cnt==0) return;
fd->append(tcp.readAll());
}
if(lll.cnt==0) return;
if(tcp.error()!=QAbstractSocket::SocketTimeoutError) fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead2\n");
tcp.close();
fd->append("");
} }
}); });
hBox->addWidget(btnListFiles); hBox->addWidget(btnListFiles);
@ -725,6 +746,8 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
} }
JObj json{{"_type", "GetInfo"}}; JObj json{{"_type", "GetInfo"}};
auto fd = new QTextEdit; auto fd = new QTextEdit;
LocalObj lll;
connect(fd, &QTextEdit::destroyed, &lll, &LocalObj::reset);
fd->setAttribute(Qt::WA_DeleteOnClose); fd->setAttribute(Qt::WA_DeleteOnClose);
auto ft = fd->font(); auto ft = fd->font();
ft.setFamily("Consolas"); ft.setFamily("Consolas");
@ -733,31 +756,38 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
fd->resize(600, 900); fd->resize(600, 900);
fd->show(); fd->show();
for(auto &card : gSelCards) { for(auto &card : gSelCards) {
auto tcp = new TcpSocket; fd->append(card.id+" Player Info");
auto cardId = card.id; TcpSocket tcp;
connect(fd, &QTextEdit::destroyed, tcp, &QTcpSocket::deleteLater); tcp.connectToHost(card.ip, 3333);
connect(tcp, &QTcpSocket::connected, tcp, [=] { if(! tcp.waitForConnected()) {
tcp->stopTimer(); if(lll.cnt==0) return;
tcp->write(JToBytes(json)); fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitConnected\n");
tcp->startTimer(10000); tcp.close();
}); continue;
connect(tcp, &QTcpSocket::readyRead, fd, [=] { }
tcp->stopTimer(); auto resNum = tcp.write(JToBytes(json));
auto resp = tcp->readAll(); tcp.flush();
tcp->close(); if(resNum == -1 || ! tcp.waitForBytesWritten()) {
tcp->deleteLater(); if(lll.cnt==0) return;
fd->append(cardId+" Player Info"); fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at write\n");
fd->append(resp); tcp.close();
fd->append(""); continue;
}
}); if(! tcp.waitForReadyRead()) {
connect(tcp, &QTcpSocket::errorOccurred, fd, [=](QAbstractSocket::SocketError err) { if(lll.cnt==0) return;
tcp->close(); fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead\n");
tcp->deleteLater(); tcp.close();
fd->append(cardId+" Get Player Info "+socketErrKey(err)+" ("+QString::number(err)+") "+tcp->errorString()); continue;
}); }
tcp->connectToHost(card.ip, 3333); fd->append(tcp.readAll());
tcp->startTimer(10000); while(tcp.waitForReadyRead(1000)) {
if(lll.cnt==0) return;
fd->append(tcp.readAll());
}
if(lll.cnt==0) return;
if(tcp.error()!=QAbstractSocket::SocketTimeoutError) fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead2\n");
tcp.close();
fd->append("");
} }
}); });
hBox->addWidget(btnGetPlayerInfo); hBox->addWidget(btnGetPlayerInfo);
@ -771,6 +801,8 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
} }
JObj json{{"_type", "GetLog"}}; JObj json{{"_type", "GetLog"}};
auto fd = new QTextEdit; auto fd = new QTextEdit;
LocalObj lll;
connect(fd, &QTextEdit::destroyed, &lll, &LocalObj::reset);
fd->setAttribute(Qt::WA_DeleteOnClose); fd->setAttribute(Qt::WA_DeleteOnClose);
auto ft = fd->font(); auto ft = fd->font();
ft.setFamily("Consolas"); ft.setFamily("Consolas");
@ -779,27 +811,38 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
fd->resize(600, 900); fd->resize(600, 900);
fd->show(); fd->show();
for(auto &card : gSelCards) { for(auto &card : gSelCards) {
auto tcp = new TcpSocket; fd->append(card.id+" Player Log");
auto cardId = card.id; TcpSocket tcp;
connect(fd, &QTextEdit::destroyed, tcp, &QTcpSocket::deleteLater); tcp.connectToHost(card.ip, 3333);
connect(tcp, &QTcpSocket::connected, tcp, [=] { if(! tcp.waitForConnected()) {
tcp->stopTimer(); if(lll.cnt==0) return;
tcp->write(JToBytes(json)); fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitConnected\n");
tcp->startTimer(5000); tcp.close();
}); continue;
connect(tcp, &QTcpSocket::readyRead, fd, [=] { }
tcp->stopTimer(); auto resNum = tcp.write(JToBytes(json));
auto resp = tcp->readAll(); tcp.flush();
if(fd->document()->isEmpty()) fd->append(cardId+" Player Log"); if(resNum == -1 || ! tcp.waitForBytesWritten()) {
fd->append(resp); if(lll.cnt==0) return;
}); fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at write\n");
connect(tcp, &QTcpSocket::errorOccurred, fd, [=](QAbstractSocket::SocketError err) { tcp.close();
tcp->close(); continue;
tcp->deleteLater(); }
if(fd->document()->isEmpty() || err!=QAbstractSocket::SocketTimeoutError) fd->append(cardId+" Get Player Log "+socketErrKey(err)+" ("+QString::number(err)+") "+tcp->errorString()); if(! tcp.waitForReadyRead()) {
}); if(lll.cnt==0) return;
tcp->connectToHost(card.ip, 3333); fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead\n");
tcp->startTimer(8000); tcp.close();
continue;
}
fd->append(tcp.readAll());
while(tcp.waitForReadyRead(1000)) {
if(lll.cnt==0) return;
fd->append(tcp.readAll());
}
if(lll.cnt==0) return;
if(tcp.error()!=QAbstractSocket::SocketTimeoutError) fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead2\n");
tcp.close();
fd->append("");
} }
}); });
hBox->addWidget(GetBuf); hBox->addWidget(GetBuf);
@ -1136,27 +1179,29 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
} }
}); });
hBox->addWidget(btnReceCardsGet); hBox->addWidget(btnReceCardsGet);
// auto btnTool = new QPushButton("本地监控");
// btnTool->setMinimumHeight(30);
// btnTool->setProperty("ssType", "progManageTool");
// connect(btnTool, &QPushButton::clicked, btnTool, [] {
// QFileInfo file("EasyTool/EasyTool.exe");
// if(file.exists()) QProcess::startDetached(file.absoluteFilePath(), QStringList(), file.absolutePath());
// });
// hBox->addWidget(btnTool);
// auto btnVMS = new QPushButton("平台监控");
// btnVMS->setMinimumHeight(30);
// btnVMS->setProperty("ssType", "progManageTool");
// connect(btnVMS, &QPushButton::clicked, btnVMS, [] {
// QFileInfo file("EasyVMS/EasyVMS.exe");
// if(file.exists()) QProcess::startDetached(file.absoluteFilePath(), QStringList(), file.absolutePath());
// });
// hBox->addWidget(btnVMS);
hBox->addStretch(); hBox->addStretch();
// hBox = new HBox(vBox);
// auto btnTool = new QPushButton("EasyTool");
// btnTool->setMinimumHeight(30);
// btnTool->setProperty("ssType", "progManageTool");
// connect(btnTool, &QPushButton::clicked, btnTool, [] {
// QFileInfo file("EasyTool/EasyTool.exe");
// if(file.exists()) QProcess::startDetached(file.absoluteFilePath(), QStringList(), file.absolutePath());
// });
// hBox->addWidget(btnTool);
// auto btnVMS = new QPushButton("EasyVMS");
// btnVMS->setMinimumHeight(30);
// btnVMS->setProperty("ssType", "progManageTool");
// connect(btnVMS, &QPushButton::clicked, btnVMS, [] {
// QFileInfo file("EasyVMS/EasyVMS.exe");
// if(file.exists()) QProcess::startDetached(file.absoluteFilePath(), QStringList(), file.absolutePath());
// });
// hBox->addWidget(btnVMS);
// hBox->addStretch();
#ifndef Q_OS_WIN #ifndef Q_OS_WIN
btnLedSet->setVisible(false); btnLedSet->setVisible(false);
#endif #endif
@ -1553,7 +1598,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
hBox->addSpacing(20); hBox->addSpacing(20);
btnMcuUpd = new QPushButton; btnMcuUpd = new QPushButton("Update MCU");
btnMcuUpd->setProperty("ssType", "progManageTool"); btnMcuUpd->setProperty("ssType", "progManageTool");
connect(btnMcuUpd, &QPushButton::clicked, this, [this] { connect(btnMcuUpd, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) { if(gSelCards.isEmpty()) {
@ -1580,30 +1625,37 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
data.append("--").append(Boundary).append("\r\nContent-Disposition: form-data; name=\"").append(nameBytes).append("\"; filename=\"").append(nameBytes).append("\"\r\n\r\n").append(fileData).append("\r\n"); data.append("--").append(Boundary).append("\r\nContent-Disposition: form-data; name=\"").append(nameBytes).append("\"; filename=\"").append(nameBytes).append("\"\r\n\r\n").append(fileData).append("\r\n");
data.append("--").append(Boundary).append("--\r\n"); data.append("--").append(Boundary).append("--\r\n");
if(gSelCards.count() == 1) { ProgressesDlg dlg;
auto waitingDlg = new WaitingDlg(this, tr("MCU Uploading")+" ..."); dlg.resize(1024, 600);
waitingDlg->show(); for(auto &card : gSelCards) {
NetReq req("http://"+gSelCards[0].ip+":2016/upload?type=mcu_update"); ProgressesItem* item;
item = new ProgressesItem(dlg.table);
item->setText("id", card.id);
item->fdProgress = new QProgressBar;
item->fdProgress->setAlignment(Qt::AlignCenter);
item->fdProgress->setMaximumHeight(24);
item->setCellWidget("progress", WrapVCenter(item->fdProgress));
item->setText("ip", card.ip);
item->setText("alias", card.alias);
NetReq req("http://"+card.ip+":2016/upload?type=mcu_update");
auto reply = req.timeout(120000).type("multipart/form-data; boundary="+Boundary).post(data); auto reply = req.timeout(120000).type("multipart/form-data; boundary="+Boundary).post(data);
ConnReply(reply, waitingDlg) [=] { connect(reply, &QNetworkReply::uploadProgress, item, [=](qint64 bytesSent, qint64 bytesTotal) {
QString err = checkReply(reply); if(bytesTotal==0) return;
item->fdProgress->setValue(bytesSent*100/bytesTotal);
});
ConnReply(reply, item) [=] {
auto err = errStrWithData(reply);
if(! err.isEmpty()) { if(! err.isEmpty()) {
waitingDlg->close(); item->setRes(tr("Upload error")+": "+err, Qt::red);
QMessageBox::critical(this, tr("Error"), err);
return; return;
} }
waitingDlg->success(); auto info = tr("Upgrading")+" ...";
item->setRes(info);
item->sendProgress("GetMcuUpgradeProgress");
item->fdProgress->setValue(0);
}); });
} else {
foreach(auto card, gSelCards) {
NetReq req("http://"+card.ip+":2016/upload?type=mcu_update");
auto reply = req.timeout(120000).type("multipart/form-data; boundary="+Boundary).post(data);
connect(reply, &QNetworkReply::finished, this, [=] {
QString err = checkReply(reply);
gFdResInfo->append(card.id+" "+tr("Update MCU")+" "+(err.isEmpty()?tr("Success"):err));
});
}
} }
dlg.exec();
}); });
hBox->addWidget(btnMcuUpd); hBox->addWidget(btnMcuUpd);
@ -2539,7 +2591,7 @@ void CtrlAdvancedPanel::init() {
|| card.id.startsWith("m5h", Qt::CaseInsensitive) || card.id.startsWith("m5h", Qt::CaseInsensitive)
|| card.id.startsWith("m5s", Qt::CaseInsensitive) || card.id.startsWith("m5s", Qt::CaseInsensitive)
|| card.id.startsWith("m6s", Qt::CaseInsensitive) || card.id.startsWith("m6s", Qt::CaseInsensitive)
|| card.id.startsWith("m7s", Qt::CaseInsensitive) || card.id.startsWith("m7", Qt::CaseInsensitive)
|| card.id.startsWith("y1", Qt::CaseInsensitive) || card.id.startsWith("y1", Qt::CaseInsensitive)
|| card.id.startsWith("y4", Qt::CaseInsensitive) || card.id.startsWith("y4", Qt::CaseInsensitive)
|| card.id.startsWith("y5", Qt::CaseInsensitive); || card.id.startsWith("y5", Qt::CaseInsensitive);
@ -2583,7 +2635,7 @@ void CtrlAdvancedPanel::transUi() {
btnM80Restore->setText(tr("Restore to default")); btnM80Restore->setText(tr("Restore to default"));
btnM80Set->setText(tr("Set")); btnM80Set->setText(tr("Set"));
grpY50->setTitle("M50S / M60S / M70S / M5H / ST50 / Y1G / Y1C / Y4A / Y5A "+tr("Resolution Config")); grpY50->setTitle("M50S / M60S / M70S / M5H / M7L / ST50 / Y1G / Y1C / Y4A / Y5A "+tr("Resolution Config"));
fdDisMode->setItemText(0, tr("Full screen")); fdDisMode->setItemText(0, tr("Full screen"));
fdDisMode->setItemText(1, tr("Part")); fdDisMode->setItemText(1, tr("Part"));
btnY50Set->setText(tr("Set")); btnY50Set->setText(tr("Set"));
@ -2611,7 +2663,6 @@ void CtrlAdvancedPanel::transUi() {
grpBoxHiddenSettings->setTitle(tr("Hidden Settings")+" ("+tr("Click right button to hide")+")"); grpBoxHiddenSettings->setTitle(tr("Hidden Settings")+" ("+tr("Click right button to hide")+")");
btnSysUpd->setText(tr("System Update")); btnSysUpd->setText(tr("System Update"));
btnMcuUpd->setText(tr("Update MCU"));
btnMcuGet->setText(tr("Get MCU Version")); btnMcuGet->setText(tr("Get MCU Version"));
lbBaudCfg->setText(tr("Baud Config")); lbBaudCfg->setText(tr("Baud Config"));
lbBaudModel->setText(tr("Model")); lbBaudModel->setText(tr("Model"));

View File

@ -236,6 +236,10 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
hBox->addWidget(fdIsHotspot); hBox->addWidget(fdIsHotspot);
hBox->addStretch(); hBox->addStretch();
auto aaaQButtonGroup = new QButtonGroup(fdIsWifi);
aaaQButtonGroup->addButton(fdIsWifi);
aaaQButtonGroup->addButton(fdIsHotspot);
vBox->addLayout(stackedWifi); vBox->addLayout(stackedWifi);
{ {
auto vvv = new VBox(stackedWifi); auto vvv = new VBox(stackedWifi);
@ -243,6 +247,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
lbWifiName = new QLabel; lbWifiName = new QLabel;
lbWifiName->setMinimumWidth(80); lbWifiName->setMinimumWidth(80);
lbWifiName->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
hBox->addWidget(lbWifiName); hBox->addWidget(lbWifiName);
fdWifiName = new QComboBox; fdWifiName = new QComboBox;
@ -283,6 +288,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
lbWifiPassword = new QLabel; lbWifiPassword = new QLabel;
lbWifiPassword->setMinimumWidth(80); lbWifiPassword->setMinimumWidth(80);
lbWifiPassword->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
hBox->addWidget(lbWifiPassword); hBox->addWidget(lbWifiPassword);
fdWifiPassword = new QLineEdit; fdWifiPassword = new QLineEdit;
@ -298,6 +304,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
lbHotspotName = new QLabel; lbHotspotName = new QLabel;
lbHotspotName->setMinimumWidth(80); lbHotspotName->setMinimumWidth(80);
lbHotspotName->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
hBox->addWidget(lbHotspotName); hBox->addWidget(lbHotspotName);
fdHotspotName = new QLineEdit; fdHotspotName = new QLineEdit;
@ -309,6 +316,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
lbHotspotPassword = new QLabel; lbHotspotPassword = new QLabel;
lbHotspotPassword->setMinimumWidth(80); lbHotspotPassword->setMinimumWidth(80);
lbHotspotPassword->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
hBox->addWidget(lbHotspotPassword); hBox->addWidget(lbHotspotPassword);
fdHotspotPassword = new QLineEdit; fdHotspotPassword = new QLineEdit;
@ -317,6 +325,20 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
hBox->addWidget(fdHotspotPassword); hBox->addWidget(fdHotspotPassword);
hBox->addStretch(); hBox->addStretch();
hBox = new HBox(vvv);
auto lll = new QLabel;
lll->setMinimumWidth(80);
hBox->addWidget(lll);
fdIs2_4G = new QRadioButton("2.4G");
fdIs2_4G->setChecked(true);
hBox->addWidget(fdIs2_4G);
auto fdIs5G = new QRadioButton("5G");
hBox->addWidget(fdIs5G);
hBox->addStretch();
vvv->addStretch(); vvv->addStretch();
} }
fdIsWifi->setChecked(true); fdIsWifi->setChecked(true);
@ -380,6 +402,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
json.insert("_id", "ConfigurationHotSpot"); json.insert("_id", "ConfigurationHotSpot");
json.insert("_type", "ConfigurationHotSpot"); json.insert("_type", "ConfigurationHotSpot");
json.insert("apName", fdHotspotName->text()); json.insert("apName", fdHotspotName->text());
json.insert("apBand", fdIs2_4G->isChecked() ? 0 : 1);
json.insert("password", fdHotspotPassword->text()); json.insert("password", fdHotspotPassword->text());
if(gSelCards.count() == 1) { if(gSelCards.count() == 1) {
auto waitingDlg = new WaitingDlg(this, tr("ConfigurationHotSpot")+" ..."); auto waitingDlg = new WaitingDlg(this, tr("ConfigurationHotSpot")+" ...");

View File

@ -47,10 +47,11 @@ private:
QPushButton *btnLanSet, *btnLanGet; QPushButton *btnLanSet, *btnLanGet;
QLabel *label_5; QLabel *label_5;
QLabel *lbWifiName; QLabel *lbWifiName;
QComboBox *fdWifiName;
QRadioButton *fdIs2_4G;
QLabel *lbWifiPassword; QLabel *lbWifiPassword;
QRadioButton *fdIsWifi, *fdIsHotspot; QRadioButton *fdIsWifi, *fdIsHotspot;
QComboBox *fdWifiName;
QLineEdit *fdWifiPassword; QLineEdit *fdWifiPassword;
QPushButton *btnScan; QPushButton *btnScan;
QPushButton *btnWiFiSet; QPushButton *btnWiFiSet;

View File

@ -0,0 +1,65 @@
#include "progressesdlg.h"
#include "gutil/qcore.h"
#include "gutil/qgui.h"
#include "gutil/qnetwork.h"
#include "globaldefine.h"
#include <QAction>
#include <QFileDialog>
#include <QLineEdit>
#include <QMessageBox>
#include <QHeaderView>
#include <QKeyEvent>
#include <QJsonArray>
#include <QHttpMultiPart>
#include <QDialogButtonBox>
#include <QJsonObject>
#include <QInputDialog>
ProgressesDlg::ProgressesDlg(QWidget *parent) : QDialog(parent) {
resize(1280, 720);
setWindowFlag(Qt::WindowMaximizeButtonHint);
auto vBox = new VBox(this);
vBox->setContentsMargins(6, 0, 6, 0);
table = new TreeWidget;
table->addCol("#", "", 20);
table->addCol("id", "ID", 125);
table->addCol("ip", "IP", 95);
table->addCol("alias", tr("Alias"), 80);
table->addCol("progress", tr("Progress"), 100);
table->addCol("res", tr("State"), 200, QHeaderView::Stretch);
table->setDefs()->setHeaderAlignC();
table->setSelectionMode(QAbstractItemView::NoSelection);
vBox->addWidget(table);
}
void ProgressesItem::sendProgress(const QString &id) {
QJsonObject json;
json.insert("_id", id);
json.insert("_type", id);
auto reply = NetReq("http://"+text("ip")+":2016/settings").timeout(30000).post(json);
ConnReply(reply, this) [=] {
if(treeWidget()==0) return;
JValue json;
auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) {
setRes(id+" "+tr("Error")+": "+err, Qt::red);
return;
}
auto progre = json["progress"].toInt();
if(progre >= 100) {
fdProgress->setValue(100);
setRes("FPGA "+tr("Install Success"), Qt::darkGreen);
} else if(progre == -1) {
fdProgress->setValue(100);
setRes(tr("Same version, needn't update"), Qt::darkGreen);
} else if(progre == -2) {
setRes(tr("Install Failed")+" (-2)", Qt::red);
} else {
fdProgress->setValue(progre);
wait(250);
sendProgress(id);
}
});
}

View File

@ -0,0 +1,32 @@
#ifndef PROGRESSESDLG_H
#define PROGRESSESDLG_H
#include "gutil/qgui.h"
#include <QDialog>
#include <QProgressBar>
class ProgressesItem;
class ProgressesDlg : public QDialog {
Q_OBJECT
public:
explicit ProgressesDlg(QWidget *parent = nullptr);
QString filePath, fileId;
TreeWidget *table;
};
class ProgressesItem : public TreeWidgetItem, public QObject {
public:
using TreeWidgetItem::TreeWidgetItem;
void setRes(const QString &tip, QColor color = Qt::green) {
auto res = "res"**treeWidget();
setText(res, tip);
setToolTip(res, tip);
setForeground(res, color);
}
void sendProgress(const QString &id);
QProgressBar *fdProgress;
};
#endif // PROGRESSESDLG_H

View File

@ -124,4 +124,12 @@ QString checkReplyForJson(QNetworkReply *, QString errField);
gFdResInfo->append(card.id+" "+tip+" "+(err.isEmpty()?QCoreApplication::translate("Def","Success"):err));\ gFdResInfo->append(card.id+" "+tip+" "+(err.isEmpty()?QCoreApplication::translate("Def","Success"):err));\
}); });
class LocalObj : public QObject {
public :
int cnt = 1;
void reset() {
cnt = 0;
}
};
#endif // GLOBALDEFINE_H #endif // GLOBALDEFINE_H

View File

@ -390,7 +390,15 @@ public:
treeWidget()->setItemWidget(this, column**treeWidget(), widget); treeWidget()->setItemWidget(this, column**treeWidget(), widget);
} }
}; };
inline QWidget *WrapVCenter(QWidget *wgt) {
auto vvv = new VBox(new QWidget);
vvv->setContentsMargins(0,0,0,0);
vvv->setSpacing(0);
vvv->addStretch();
vvv->addWidget(wgt);
vvv->addStretch();
return vvv->parentWidget();
}
class TableWidget : public QTableWidget { class TableWidget : public QTableWidget {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -138,7 +138,15 @@ PlayWin::PlayWin(int x, int y, int width, int height, QString dir, const JValue
src.view = video; src.view = video;
} else if(src.type=="WebURL") { } else if(src.type=="WebURL") {
auto web = new QWebEngineView(box); auto web = new QWebEngineView(box);
auto offX = source["offX"].toInt();
auto offY = source["offY"].toInt();
if(offX || offY) connect(web, &QWebEngineView::loadFinished, this, [=] {
disconnect(web, &QWebEngineView::loadFinished, this, 0);
web->page()->runJavaScript("window.scrollTo("+QString::number(offX)+", "+QString::number(offY)+")");
});
web->setZoomFactor(source["zoom"].toInt(100)/100.0);
web->load(QUrl(source["url"].toString())); web->load(QUrl(source["url"].toString()));
web->setFocusPolicy(Qt::NoFocus);
src.view = web; src.view = web;
} }
else if(src.type=="Timer") src.view = new EleTimer(source, box); else if(src.type=="Timer") src.view = new EleTimer(source, box);

View File

@ -129,8 +129,7 @@ ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
dlg.exec(); dlg.exec();
mProgTree->clear(); mProgTree->clear();
QStringList progNames = QDir(mProgsDir).entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks); addProFiles();
for(auto &pro_name : progNames) addProFile(mProgsDir + "/" + pro_name + "/pro.json");
}); });
bnExport = new QPushButton(tr("Export")); bnExport = new QPushButton(tr("Export"));
@ -260,13 +259,8 @@ ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
} }
} }
} }
//查找根路径下的项目文件夹查找文件夹下的节目pro.json信息包括节目名称大小像素备注等信息 //查找根路径下的项目文件夹查找文件夹下的节目pro.json信息包括节目名称大小像素备注等信息
if(! mProgsDir.isEmpty()) { if(! mProgsDir.isEmpty()) addProFiles();
QDir root_dir(mProgsDir);
auto pro_list = root_dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
for(auto &pro_name : pro_list) addProFile(mProgsDir + "/" + pro_name + "/pro.json");
}
QSettings settings; QSettings settings;
if(settings.value("ProgramListSortOrder").toInt()==0) mProgTree->sortByColumn(settings.value("ProgramListSortColumn").toInt(),Qt::SortOrder::AscendingOrder); if(settings.value("ProgramListSortOrder").toInt()==0) mProgTree->sortByColumn(settings.value("ProgramListSortColumn").toInt(),Qt::SortOrder::AscendingOrder);
else mProgTree->sortByColumn(settings.value("ProgramListSortColumn").toInt(),Qt::SortOrder::DescendingOrder); else mProgTree->sortByColumn(settings.value("ProgramListSortColumn").toInt(),Qt::SortOrder::DescendingOrder);
@ -294,33 +288,37 @@ void ProgPanel::transUi() {
btnPlay->setText(tr("Play")+"/"+tr("Stop")); btnPlay->setText(tr("Play")+"/"+tr("Stop"));
} }
void ProgPanel::addProFile(const QString &file) { void ProgPanel::addProFiles() {
QFile qFile(file); auto progNames = QDir(mProgsDir).entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
if(! qFile.exists()) return; for(auto &progName : progNames) {
if(! qFile.open(QIODevice::ReadOnly)) return; auto file = mProgsDir + "/" + progName + "/pro.json";
auto data = qFile.readAll(); QFile qFile(file);
qFile.close(); if(! qFile.exists()) continue;
QString error; if(! qFile.open(QIODevice::ReadOnly)) continue;
auto json = JFrom(data, &error); auto data = qFile.readAll();
if(! error.isEmpty()) return; qFile.close();
auto item = new ProgItem(mProgTree); QString error;
item->mProgsDir = mProgsDir; auto json = JFrom(data, &error);
item->mName = json["name"].toString(); if(! error.isEmpty()) continue;
item->mWidth = json["resolution"]["w"].toInt(); auto item = new ProgItem(mProgTree);
item->mHeight = json["resolution"]["h"].toInt(); item->mProgsDir = mProgsDir;
item->mRemark = json["remarks"].toString(); item->mName = progName;
item->isVer = json["isVer"].toBool(); item->mWidth = json["resolution"]["w"].toInt();
auto partLengths = json["splitWidths"].toArray(); item->mHeight = json["resolution"]["h"].toInt();
for(auto &partLength : partLengths) { item->mRemark = json["remarks"].toString();
auto len = partLength.toInt(); item->isVer = json["isVer"].toBool();
if(item->maxLen < len) item->maxLen = len; auto partLengths = json["splitWidths"].toArray();
item->partLens.emplace_back(len); for(auto &partLength : partLengths) {
auto len = partLength.toInt();
if(item->maxLen < len) item->maxLen = len;
item->partLens.emplace_back(len);
}
item->m_fsize = json["file_size"].toDouble();
item->mProgDir = item->mProgsDir + "/" + item->mName;
item->m_orgName = item->mName;
item->setText("lasttime", QFileInfo(file).lastModified().toString("yyyy-MM-dd hh:mm:ss"));
item->init();
} }
item->m_fsize = json["file_size"].toDouble();
item->mProgDir = item->mProgsDir + "/" + item->mName;
item->m_orgName = item->mName;
item->setText("lasttime", QFileInfo(file).lastModified().toString("yyyy-MM-dd hh:mm:ss"));
item->init();
} }
void ProgPanel::onEditClicked(bool){ void ProgPanel::onEditClicked(bool){

View File

@ -17,7 +17,7 @@ protected:
void changeEvent(QEvent *) override; void changeEvent(QEvent *) override;
void transUi(); void transUi();
bool checkIfNameRepeated(const QString &name, QTreeWidgetItem *skip = nullptr); bool checkIfNameRepeated(const QString &name, QTreeWidgetItem *skip = nullptr);
void addProFile(const QString &); void addProFiles();
public slots: public slots:
void onEditClicked(bool f); void onEditClicked(bool f);

View File

@ -1,9 +1,8 @@
#include "eweb.h" #include "eweb.h"
#include "gutil/qgui.h"
#include <QSpinBox> #include <QSpinBox>
#include <QBoxLayout>
#include <QLineEdit> #include <QLineEdit>
#include <QPainter> #include <QPainter>
#include <QLabel>
EWeb::EWeb(EBase *multiWin) : EBase(multiWin) { EWeb::EWeb(EBase *multiWin) : EBase(multiWin) {
mType = EBase::Web; mType = EBase::Web;
@ -12,6 +11,9 @@ EWeb::EWeb(const JObj &json, EBase *multiWin) : EBase(multiWin) {
mType = EBase::Web; mType = EBase::Web;
setBaseAttr(json); setBaseAttr(json);
url = json["url"].toString(); url = json["url"].toString();
zoom = json["zoom"].toInt(100);
_x = json["offX"].toInt(0);
_y = json["offY"].toInt(0);
} }
void EWeb::paint(QPainter *painter, const QStyleOptionGraphicsItem *a, QWidget *b) { void EWeb::paint(QPainter *painter, const QStyleOptionGraphicsItem *a, QWidget *b) {
@ -28,41 +30,83 @@ void EWeb::paint(QPainter *painter, const QStyleOptionGraphicsItem *a, QWidget *
} }
QWidget* EWeb::attrWgt() { QWidget* EWeb::attrWgt() {
auto wgtAttr = new QWidget(); auto wgtAttr = new QWidget;
auto vBox = new QVBoxLayout(wgtAttr); auto vBox = new VBox(wgtAttr);
vBox->setContentsMargins(6, 0, 6, 0); vBox->setContentsMargins(6, 0, 6, 0);
if(mMultiWin!=nullptr) vBox->setSpacing(3); if(mMultiWin) vBox->setSpacing(3);
addBaseAttrWgt(vBox); addBaseAttrWgt(vBox);
auto hBox = new QHBoxLayout; auto hBox = new HBox(vBox);
hBox->addWidget(new QLabel(tr("Basic Properties"))); hBox->addLabel(tr("Basic Properties"));
auto line = new QFrame(); auto line = new QFrame;
line->setFrameShape(QFrame::HLine); line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken); line->setFrameShadow(QFrame::Sunken);
hBox->addWidget(line, 1); hBox->addWidget(line, 1);
vBox->addLayout(hBox); hBox = new HBox(vBox);
hBox = new QHBoxLayout;
hBox->addSpacing(6); hBox->addSpacing(6);
hBox->addWidget(new QLabel("URL: ")); hBox->addLabel("URL:");
auto url_fd = new QLineEdit(url); auto url_fd = new QLineEdit(url);
hBox->addWidget(url_fd); hBox->addWidget(url_fd);
connect(url_fd, &QLineEdit::textChanged, this, [this](const QString &text) { connect(url_fd, &QLineEdit::textChanged, this, [this](const QString &text) {
url = text; url = text;
}); });
vBox->addLayout(hBox);
hBox = new HBox(vBox);
auto lb = hBox->addLabel(tr("Zoom")+":");
lb->setMinimumWidth(70);
lb->setAlignment(Qt::AlignVCenter|Qt::AlignRight);
auto fdZoom = new QSpinBox;
fdZoom->setRange(1, 99999);
fdZoom->setValue(zoom);
connect(fdZoom, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [=](int value) {
zoom = value;
});
hBox->addWidget(fdZoom);
hBox->addSpacing(-3);
hBox->addLabel("%");
hBox->addStretch();
hBox = new HBox(vBox);
lb = hBox->addLabel(tr("Offset")+" X:");
lb->setMinimumWidth(70);
lb->setAlignment(Qt::AlignVCenter|Qt::AlignRight);
auto fdX = new QSpinBox;
fdX->setRange(0, 99999);
fdX->setValue(_x);
connect(fdX, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [=](int value) {
_x = value;
});
hBox->addWidget(fdX);
hBox->addSpacing(9);
hBox->addLabel("Y:");
auto fdY = new QSpinBox;
fdY->setRange(0, 99999);
fdY->setValue(_y);
connect(fdY, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [=](int value) {
_y = value;
});
hBox->addWidget(fdY);
hBox->addStretch();
vBox->addStretch(); vBox->addStretch();
return wgtAttr; return wgtAttr;
} }
JObj EWeb::attrJson() const { JObj EWeb::attrJson() const {
JObj oRoot; JObj obj;
addBaseAttr(oRoot); addBaseAttr(obj);
oRoot["elementType"] = "Web"; obj["elementType"] = "Web";
oRoot["url"] = url; obj["url"] = url;
return oRoot; obj["zoom"] = zoom;
obj["offX"] = _x;
obj["offY"] = _y;
return obj;
} }

View File

@ -21,6 +21,7 @@ public:
JObj attrJson() const override; JObj attrJson() const override;
QString url; QString url;
int zoom = 100, _x = 0, _y = 0;
}; };
#endif // EWEB_H #endif // EWEB_H

View File

@ -506,6 +506,9 @@ JObj GenTmpThread::convertWeb(const JValue &res) {
dst["_type"] = "WebURL"; dst["_type"] = "WebURL";
dst["name"] = "WebURL"; dst["name"] = "WebURL";
dst["url"] = res["url"]; dst["url"] = res["url"];
dst["zoom"] = res["zoom"];
dst["offX"] = res["offX"];
dst["offY"] = res["offY"];
return dst; return dst;
} }
JObj GenTmpThread::convertTimer(const JValue &json) { JObj GenTmpThread::convertTimer(const JValue &json) {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff