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 += console
DEFINES += leyide
# You can also make your code fail to compile if you use deprecated APIs.
# 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.
@ -108,6 +108,7 @@ SOURCES += \
base/lodateselector.cpp \
base/loqtitlebar.cpp \
base/loqtreewidget.cpp \
device/progressesdlg.cpp \
gutil/qcore.cpp \
gutil/qwaitingdlg.cpp \
basedlg.cpp \
@ -176,6 +177,7 @@ HEADERS += \
base/lodateselector.h \
base/loqtitlebar.h \
base/loqtreewidget.h \
device/progressesdlg.h \
gutil/qcore.h \
gutil/qwaitingdlg.h \
basedlg.h \

View File

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

View File

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

View File

@ -47,10 +47,11 @@ private:
QPushButton *btnLanSet, *btnLanGet;
QLabel *label_5;
QLabel *lbWifiName;
QComboBox *fdWifiName;
QRadioButton *fdIs2_4G;
QLabel *lbWifiPassword;
QRadioButton *fdIsWifi, *fdIsHotspot;
QComboBox *fdWifiName;
QLineEdit *fdWifiPassword;
QPushButton *btnScan;
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));\
});
class LocalObj : public QObject {
public :
int cnt = 1;
void reset() {
cnt = 0;
}
};
#endif // GLOBALDEFINE_H

View File

@ -390,7 +390,15 @@ public:
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 {
Q_OBJECT
public:

View File

@ -138,7 +138,15 @@ PlayWin::PlayWin(int x, int y, int width, int height, QString dir, const JValue
src.view = video;
} else if(src.type=="WebURL") {
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->setFocusPolicy(Qt::NoFocus);
src.view = web;
}
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();
mProgTree->clear();
QStringList progNames = QDir(mProgsDir).entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
for(auto &pro_name : progNames) addProFile(mProgsDir + "/" + pro_name + "/pro.json");
addProFiles();
});
bnExport = new QPushButton(tr("Export"));
@ -260,13 +259,8 @@ ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
}
}
}
//查找根路径下的项目文件夹查找文件夹下的节目pro.json信息包括节目名称大小像素备注等信息
if(! mProgsDir.isEmpty()) {
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");
}
if(! mProgsDir.isEmpty()) addProFiles();
QSettings settings;
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);
@ -294,18 +288,21 @@ void ProgPanel::transUi() {
btnPlay->setText(tr("Play")+"/"+tr("Stop"));
}
void ProgPanel::addProFile(const QString &file) {
void ProgPanel::addProFiles() {
auto progNames = QDir(mProgsDir).entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
for(auto &progName : progNames) {
auto file = mProgsDir + "/" + progName + "/pro.json";
QFile qFile(file);
if(! qFile.exists()) return;
if(! qFile.open(QIODevice::ReadOnly)) return;
if(! qFile.exists()) continue;
if(! qFile.open(QIODevice::ReadOnly)) continue;
auto data = qFile.readAll();
qFile.close();
QString error;
auto json = JFrom(data, &error);
if(! error.isEmpty()) return;
if(! error.isEmpty()) continue;
auto item = new ProgItem(mProgTree);
item->mProgsDir = mProgsDir;
item->mName = json["name"].toString();
item->mName = progName;
item->mWidth = json["resolution"]["w"].toInt();
item->mHeight = json["resolution"]["h"].toInt();
item->mRemark = json["remarks"].toString();
@ -322,6 +319,7 @@ void ProgPanel::addProFile(const QString &file) {
item->setText("lasttime", QFileInfo(file).lastModified().toString("yyyy-MM-dd hh:mm:ss"));
item->init();
}
}
void ProgPanel::onEditClicked(bool){
int cnt = mProgTree->topLevelItemCount();

View File

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

View File

@ -1,9 +1,8 @@
#include "eweb.h"
#include "gutil/qgui.h"
#include <QSpinBox>
#include <QBoxLayout>
#include <QLineEdit>
#include <QPainter>
#include <QLabel>
EWeb::EWeb(EBase *multiWin) : EBase(multiWin) {
mType = EBase::Web;
@ -12,6 +11,9 @@ EWeb::EWeb(const JObj &json, EBase *multiWin) : EBase(multiWin) {
mType = EBase::Web;
setBaseAttr(json);
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) {
@ -28,41 +30,83 @@ void EWeb::paint(QPainter *painter, const QStyleOptionGraphicsItem *a, QWidget *
}
QWidget* EWeb::attrWgt() {
auto wgtAttr = new QWidget();
auto vBox = new QVBoxLayout(wgtAttr);
auto wgtAttr = new QWidget;
auto vBox = new VBox(wgtAttr);
vBox->setContentsMargins(6, 0, 6, 0);
if(mMultiWin!=nullptr) vBox->setSpacing(3);
if(mMultiWin) vBox->setSpacing(3);
addBaseAttrWgt(vBox);
auto hBox = new QHBoxLayout;
hBox->addWidget(new QLabel(tr("Basic Properties")));
auto hBox = new HBox(vBox);
hBox->addLabel(tr("Basic Properties"));
auto line = new QFrame();
auto line = new QFrame;
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
hBox->addWidget(line, 1);
vBox->addLayout(hBox);
hBox = new QHBoxLayout;
hBox = new HBox(vBox);
hBox->addSpacing(6);
hBox->addWidget(new QLabel("URL: "));
hBox->addLabel("URL:");
auto url_fd = new QLineEdit(url);
hBox->addWidget(url_fd);
connect(url_fd, &QLineEdit::textChanged, this, [this](const QString &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();
return wgtAttr;
}
JObj EWeb::attrJson() const {
JObj oRoot;
addBaseAttr(oRoot);
oRoot["elementType"] = "Web";
oRoot["url"] = url;
return oRoot;
JObj obj;
addBaseAttr(obj);
obj["elementType"] = "Web";
obj["url"] = url;
obj["zoom"] = zoom;
obj["offX"] = _x;
obj["offY"] = _y;
return obj;
}

View File

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

View File

@ -506,6 +506,9 @@ JObj GenTmpThread::convertWeb(const JValue &res) {
dst["_type"] = "WebURL";
dst["name"] = "WebURL";
dst["url"] = res["url"];
dst["zoom"] = res["zoom"];
dst["offX"] = res["offX"];
dst["offY"] = res["offY"];
return dst;
}
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