This commit is contained in:
Gangphon 2023-10-23 15:08:45 +08:00
parent 3a7eaae7a8
commit 8bf38c468d
15 changed files with 202 additions and 120 deletions

View File

@ -1,6 +1,6 @@
#include "ctrladvancedpanel.h" #include "ctrladvancedpanel.h"
#include "globaldefine.h" #include "globaldefine.h"
#include "base/waitingdlg.h" #include "gutil/qwaitingdlg.h"
#include "base/changepasswordform.h" #include "base/changepasswordform.h"
#include "tools.h" #include "tools.h"
#include "gutil/qgui.h" #include "gutil/qgui.h"
@ -30,9 +30,14 @@
CtrlAdvancedPanel::CtrlAdvancedPanel() { CtrlAdvancedPanel::CtrlAdvancedPanel() {
setFocusPolicy(Qt::StrongFocus); setFocusPolicy(Qt::StrongFocus);
auto vBox = new QVBoxLayout(this); auto vBox = new VBox(this);
vBox->setContentsMargins(6,6,6,0);
lbTitle = new QLabel; lbTitle = new QLabel;
auto ft = lbTitle->font();
ft.setPixelSize(16);
ft.setBold(true);
lbTitle->setFont(ft);
lbTitle->setAlignment(Qt::AlignCenter); lbTitle->setAlignment(Qt::AlignCenter);
vBox->addWidget(lbTitle); vBox->addWidget(lbTitle);
@ -119,7 +124,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
auto item = findItem(card.id); auto item = findItem(card.id);
if(item) { if(item) {
item->mCard.alias = alias; item->mCard.alias = alias;
item->setText(DeviceTable_Remark, alias); item->setText("alias", alias);
} }
}); });
} else { } else {
@ -132,7 +137,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
auto item = findItem(card.id); auto item = findItem(card.id);
if(item) { if(item) {
item->mCard.alias = alias; item->mCard.alias = alias;
item->setText(DeviceTable_Remark, alias); item->setText("alias", alias);
} }
}); });
} }
@ -185,7 +190,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
fdCompanyId->setFocus(); fdCompanyId->setFocus();
return; return;
} }
auto res = QMessageBox::question(this, tr("Tip Info"), tr("Do you want to modify webserveraddress and companyId?")); auto res = QMessageBox::question(this, tr("Tip Info"), tr("This operation will clear current program.")+"\n"+tr("Do you want to continue?"));
if(res != QMessageBox::Yes) return; if(res != QMessageBox::Yes) return;
QJsonObject json; QJsonObject json;
json.insert("_id", "SetOnlineAddr"); json.insert("_id", "SetOnlineAddr");
@ -279,8 +284,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
btnWareUpdate->setMinimumSize(100, 30); btnWareUpdate->setMinimumSize(100, 30);
btnWareUpdate->setProperty("ssType", "progManageTool"); btnWareUpdate->setProperty("ssType", "progManageTool");
connect(btnWareUpdate, &QPushButton::clicked, this, [=] { connect(btnWareUpdate, &QPushButton::clicked, this, [=] {
UpgradeApkDialog dlg(this); new UpgradeApkDialog(this);
dlg.exec();
}); });
hBox->addWidget(btnWareUpdate); hBox->addWidget(btnWareUpdate);
@ -317,7 +321,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
infoDlg->setWindowTitle(tr("Software Version Info")); infoDlg->setWindowTitle(tr("Software Version Info"));
auto vBox = new QVBoxLayout(infoDlg); auto vBox = new QVBoxLayout(infoDlg);
vBox->setContentsMargins(0, 0, 0, 0); vBox->setContentsMargins(0, 0, 0, 0);
auto table = new Table{ auto table = new TableWidget{
{"apk", "Apk"}, {"apk", "Apk"},
{"ver", tr("Version")}, {"ver", tr("Version")},
{"pkg", tr("Package")} {"pkg", tr("Package")}
@ -487,7 +491,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
tcp->connectToHost(card.ip, 3333); tcp->connectToHost(card.ip, 3333);
tcp->startTimer(10000); tcp->startTimer(10000);
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
auto tcp = new TcpSocket; auto tcp = new TcpSocket;
auto cardId = card.id; auto cardId = card.id;
connect(tcp, &QTcpSocket::connected, tcp, [=] { connect(tcp, &QTcpSocket::connected, tcp, [=] {
@ -608,23 +612,24 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
waitingDlg->show(); waitingDlg->show();
auto card = gSelCards[0]; auto card = gSelCards[0];
auto reply = NetReq("http://"+card.ip+":2016/download?file=logs").timeout(120000).get(); auto reply = NetReq("http://"+card.ip+":2016/download?file=logs").timeout(120000).get();
waitingDlg->connAbort(reply); ConnReply(reply, waitingDlg) [=] {
connect(reply, &QNetworkReply::finished, this, [=] {
waitingDlg->close(); waitingDlg->close();
QString err = checkReply(reply); QString err = checkReply(reply);
if(! err.isEmpty()) { if(! err.isEmpty()) {
QMessageBox::critical(this, tr("Error"), err); QMessageBox::critical(this, tr("Error"), err);
return; return;
} }
QString logFile = QApplication::applicationDirPath()+"/card-log.txt"; auto wgt = new QWidget(this, Qt::Window);
QFile file(logFile); wgt->setAttribute(Qt::WA_DeleteOnClose);
if(! file.open(QIODevice::WriteOnly)) { wgt->resize(800, 800);
QMessageBox::critical(this, tr("Error"), "Open for Write Fail"); auto vv = new VBox(wgt);
return; vv->setContentsMargins(0,0,0,0);
} auto fdLog = new QTextEdit;
file.write(reply->readAll()); fdLog->setPlainText(reply->readAll());
file.close(); vv->addWidget(fdLog);
QProcess::execute("notepad", {logFile}); wgt->show();
wgt->raise();
wgt->activateWindow();
}); });
} }
}); });
@ -738,8 +743,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
waitingDlg->show(); waitingDlg->show();
NetReq req("http://"+gSelCards[0].ip+":2016/upload?type=update_display"); NetReq req("http://"+gSelCards[0].ip+":2016/upload?type=update_display");
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);
waitingDlg->connAbort(reply); ConnReply(reply, waitingDlg) [=] {
connect(reply, &QNetworkReply::finished, this, [=] {
QString err = checkReply(reply); QString err = checkReply(reply);
if(! err.isEmpty()) { if(! err.isEmpty()) {
waitingDlg->close(); waitingDlg->close();
@ -817,7 +821,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
connect(reply, &QNetworkReply::finished, this, [=] { connect(reply, &QNetworkReply::finished, this, [=] {
Def_CtrlSingleGetReply Def_CtrlSingleGetReply
waitingDlg->success(); waitingDlg->success();
setCurrentData(fdDisMode, json["result"].toInt()); SetCurData(fdDisMode, json["result"].toInt());
}); });
} else { } else {
foreach(auto card, gSelCards) { foreach(auto card, gSelCards) {
@ -973,8 +977,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
auto waitingDlg = new WaitingDlg(this, tr("InvokeTaxiAppFunction")); auto waitingDlg = new WaitingDlg(this, tr("InvokeTaxiAppFunction"));
waitingDlg->show(); waitingDlg->show();
auto reply = NetReq("http://"+gSelCards[0].ip+":3000").timeout(120000).post(json); auto reply = NetReq("http://"+gSelCards[0].ip+":3000").timeout(120000).post(json);
waitingDlg->connAbort(reply); ConnReply(reply, waitingDlg) [=] {
connect(reply, &QNetworkReply::finished, this, [=] {
QString err = checkReply(reply); QString err = checkReply(reply);
if(! err.isEmpty()) { if(! err.isEmpty()) {
waitingDlg->close(); waitingDlg->close();
@ -1358,8 +1361,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
waitingDlg->show(); waitingDlg->show();
NetReq req("http://"+gSelCards[0].ip+":2016/upload?type=mcu_update"); NetReq req("http://"+gSelCards[0].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);
waitingDlg->connAbort(reply); ConnReply(reply, waitingDlg) [=] {
connect(reply, &QNetworkReply::finished, this, [=] {
QString err = checkReply(reply); QString err = checkReply(reply);
if(! err.isEmpty()) { if(! err.isEmpty()) {
waitingDlg->close(); waitingDlg->close();
@ -1423,7 +1425,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController")); QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
return; return;
} }
QString file = QFileDialog::getOpenFileName(this, tr("Select File"), gFileHome, EPhoto::filters()); auto file = QFileDialog::getOpenFileName(this, tr("Select File"), gFileHome, EPhoto::filters());
if(file.isEmpty()) return; if(file.isEmpty()) return;
QFileInfo info(file); QFileInfo info(file);
if(! info.isFile()) return; if(! info.isFile()) return;
@ -1653,7 +1655,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
lbRotate = new QLabel; lbRotate = new QLabel;
hBox->addWidget(lbRotate); hBox->addWidget(lbRotate);
hBox->addSpacing(20); hBox->addSpacing(12);
auto fdDeg0 = new QRadioButton(""); auto fdDeg0 = new QRadioButton("");
hBox->addWidget(fdDeg0); hBox->addWidget(fdDeg0);
@ -1735,6 +1737,42 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
hBox->addStretch(); hBox->addStretch();
hBox = new HBox(vBox);
lbChargingStation = new QLabel(tr("Charging Station")+" ID:");
hBox->addWidget(lbChargingStation);
auto fdChargingStation = new QLineEdit;
fdChargingStation->setMaximumWidth(120);
hBox->addWidget(fdChargingStation);
btnChargingStationSet = new QPushButton;
btnChargingStationSet->setProperty("ssType", "progManageTool");
connect(btnChargingStationSet, &QPushButton::clicked, this, [=] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
return;
}
QJsonObject json;
json.insert("_id", "SetChargingStationID");
json.insert("_type", "SetChargingStationID");
json.insert("number", fdChargingStation->text());
if(gSelCards.count() == 1) {
auto waitingDlg = new WaitingDlg(this, tr("Setting ")+tr("Charging Station")+" ID ...");
Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, this, [=] {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
Def_CtrlSetMulti(tr("Set")+" "+tr("Charging Station")+" ID")
}
}
});
hBox->addWidget(btnChargingStationSet);
hBox->addStretch();
hBox = new HBox(vBox); hBox = new HBox(vBox);
lbBaudCfg = new QLabel; lbBaudCfg = new QLabel;
@ -1932,10 +1970,54 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
}); });
hBox->addWidget(btnSendCustomJson); hBox->addWidget(btnSendCustomJson);
btnCustomJsonGet = new QPushButton;
btnCustomJsonGet->setProperty("ssType", "progManageTool");
connect(btnCustomJsonGet, &QPushButton::clicked, this, [=] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
return;
}
auto text = fdCustomJson->toPlainText().toUtf8();
if(text.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("Text is empty"));
return;
}
QString jsonErr;
auto json = JFrom(text, &jsonErr);
if(! jsonErr.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("Json Parse Error")+" "+jsonErr);
return;
}
if(! json.isObj()) {
QMessageBox::information(this, tr("Tip"), tr("Json isn't an Object"));
return;
}
if(gSelCards.count() == 1) {
auto waitingDlg = new WaitingDlg(this, "Custom Json Getting ...");
Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, this, [=] {
waitingDlg->close();
auto err = errStrWithData(reply);
if(! err.isEmpty()) QMessageBox::critical(this, tr("Error"), err);
else QMessageBox::information(this, tr("Info"), reply->readAll());
});
} else {
foreach(auto card, gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
connect(reply, &QNetworkReply::finished, gFdResInfo, [=] {
auto err = errStrWithData(reply);
gFdResInfo->append(card.id+" Custom Json Get "+(err.isEmpty()?reply->readAll():err));
});
}
}
});
hBox->addWidget(btnCustomJsonGet);
hBox->addStretch(); hBox->addStretch();
fdCustomJson = new QTextEdit; fdCustomJson = new QTextEdit;
fdCustomJson->setMinimumHeight(120); fdCustomJson->setMinimumHeight(120);
fdCustomJson->setPlainText("{\"_id\":\"0\",\"_type\":\"\"}");
vBox->addWidget(fdCustomJson); vBox->addWidget(fdCustomJson);
@ -1992,7 +2074,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
connect(reply, &QNetworkReply::finished, this, [=] { connect(reply, &QNetworkReply::finished, this, [=] {
Def_CtrlSingleGetReply Def_CtrlSingleGetReply
waitingDlg->success(); waitingDlg->success();
setCurrentData(fdTraficProtocol, json["protocolType"].toInt()); SetCurData(fdTraficProtocol, json["protocolType"].toInt());
}); });
} else { } else {
foreach(auto card, gSelCards) { foreach(auto card, gSelCards) {
@ -2079,7 +2161,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
connect(reply, &QNetworkReply::finished, this, [=] { connect(reply, &QNetworkReply::finished, this, [=] {
Def_CtrlSingleGetReply Def_CtrlSingleGetReply
waitingDlg->success(); waitingDlg->success();
setCurrentData(fdServerType, json["serverType"].toInt()); SetCurData(fdServerType, json["serverType"].toInt());
fdPort->setValue(json["port"].toInt()); fdPort->setValue(json["port"].toInt());
}); });
} else { } else {
@ -2108,6 +2190,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
vBox->addWidget(grpBoxHiddenSettings); vBox->addWidget(grpBoxHiddenSettings);
vBox->addStretch(); vBox->addStretch();
if(QSettings().value("advUiPs", "888").toString().isEmpty()) isPassed = true;
connect(gDevicePanel, &DevicePanel::sigSelectedDeviceList, this, [this] { connect(gDevicePanel, &DevicePanel::sigSelectedDeviceList, this, [this] {
if(isVisible()) init(); if(isVisible()) init();
}); });
@ -2150,8 +2233,8 @@ void CtrlAdvancedPanel::init() {
vBox->addWidget(btnBox); vBox->addWidget(btnBox);
connect(btnBox, &QDialogButtonBox::accepted, &dlg, [=, &dlg] { connect(btnBox, &QDialogButtonBox::accepted, &dlg, [=, &dlg] {
QString pwdRaw = QSettings().value("advUiPs").toString(); auto pwdVar = QSettings().value("advUiPs");
QString password = pwdRaw.isEmpty() ? "888" : QString::fromUtf8(QByteArray::fromBase64(pwdRaw.toLatin1())); auto password = pwdVar.isNull() ? "888" : QString::fromUtf8(QByteArray::fromBase64(pwdVar.toString().toLatin1()));
if(fdPassword->text() == password) dlg.accept(); if(fdPassword->text() == password) dlg.accept();
else QMessageBox::critical(&dlg, tr("Tip"),tr("Password is error")); else QMessageBox::critical(&dlg, tr("Tip"),tr("Password is error"));
}); });
@ -2163,7 +2246,6 @@ void CtrlAdvancedPanel::init() {
bool isSingle = gSelCards.count()==1; bool isSingle = gSelCards.count()==1;
btnApkCheck->setEnabled(isSingle); btnApkCheck->setEnabled(isSingle);
btnRestart->setEnabled(isSingle);
btnGetLog->setEnabled(isSingle); btnGetLog->setEnabled(isSingle);
if(! isSingle) { if(! isSingle) {
@ -2195,10 +2277,13 @@ void CtrlAdvancedPanel::init() {
} }
auto isY50 = card.id.startsWith("st5", Qt::CaseInsensitive) auto isY50 = card.id.startsWith("st5", Qt::CaseInsensitive)
|| card.id.startsWith("m5s", Qt::CaseInsensitive) || card.id.startsWith("m5h", Qt::CaseInsensitive)
|| card.id.startsWith("m6s", Qt::CaseInsensitive) || card.id.startsWith("m5s", Qt::CaseInsensitive)
|| card.id.startsWith("m7s", Qt::CaseInsensitive) || card.id.startsWith("m6s", Qt::CaseInsensitive)
|| card.id.startsWith("y5", Qt::CaseInsensitive); || card.id.startsWith("m7s", Qt::CaseInsensitive)
|| card.id.startsWith("y1", Qt::CaseInsensitive)
|| card.id.startsWith("y4", Qt::CaseInsensitive)
|| card.id.startsWith("y5", Qt::CaseInsensitive);
grpY50->setVisible(isY50); grpY50->setVisible(isY50);
QJsonObject json; QJsonObject json;
@ -2262,6 +2347,7 @@ void CtrlAdvancedPanel::transUi() {
lbRotate->setText(tr("Rotate")); lbRotate->setText(tr("Rotate"));
btnRotateSet->setText(tr("Set")); btnRotateSet->setText(tr("Set"));
btnRotateGet->setText(tr("Get")); btnRotateGet->setText(tr("Get"));
btnChargingStationSet->setText(tr("Set"));
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"));
@ -2276,6 +2362,7 @@ void CtrlAdvancedPanel::transUi() {
fdIsOpenADB->setText(tr("Open ADB")); fdIsOpenADB->setText(tr("Open ADB"));
lbCustomJson->setText(tr("Post Custom JSON")); lbCustomJson->setText(tr("Post Custom JSON"));
btnSendCustomJson->setText(tr("Send")); btnSendCustomJson->setText(tr("Send"));
btnCustomJsonGet->setText(tr("Get"));
grpHighForBusy->setTitle(tr("Taxi top screen configuration")); grpHighForBusy->setTitle(tr("Taxi top screen configuration"));
label->setText(tr("Realtimer Server Address:")); label->setText(tr("Realtimer Server Address:"));
@ -2368,22 +2455,11 @@ void PlayerBackSendThread::run() {
auto remain = info.size(); auto remain = info.size();
auto req = QJsonObject(); auto req = QJsonObject();
req.insert("_type", "proStart");
req.insert("proName", "program");
req.insert("proSize", remain);
req.insert("zVer","xixun1");
auto resNum = tcp.write(QJsonDocument(req).toJson(QJsonDocument::Compact));
if(resNum == -1 || ! tcp.waitForBytesWritten()) {
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when write 'proStart'");
tcp.close();
return;
}
req = QJsonObject();
req.insert("_type", "imgFileStart"); req.insert("_type", "imgFileStart");
req.insert("id", baseName); req.insert("id", baseName);
req.insert("size", remain); req.insert("size", remain);
req.insert("zVer","xixun1"); req.insert("zVer","xixun1");
resNum = tcp.write(QJsonDocument(req).toJson(QJsonDocument::Compact)); auto resNum = tcp.write(QJsonDocument(req).toJson(QJsonDocument::Compact));
if(resNum == -1 || ! tcp.waitForBytesWritten()) { if(resNum == -1 || ! tcp.waitForBytesWritten()) {
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when write 'imgFileStart'"); emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when write 'imgFileStart'");
tcp.close(); tcp.close();
@ -2425,28 +2501,18 @@ void PlayerBackSendThread::run() {
req.insert("zVer","xixun1"); req.insert("zVer","xixun1");
resNum = tcp.write(QJsonDocument(req).toJson(QJsonDocument::Compact)); resNum = tcp.write(QJsonDocument(req).toJson(QJsonDocument::Compact));
if(resNum == -1 || ! tcp.waitForBytesWritten()) { if(resNum == -1 || ! tcp.waitForBytesWritten()) {
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when write 'fileEnd'"); emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when write 'imgFileEnd'");
tcp.close(); tcp.close();
return; return;
} }
req = QJsonObject();
req.insert("_type", "proEnd");
req.insert("proName", "program");
req.insert("zVer","xixun1");
resNum = tcp.write(QJsonDocument(req).toJson(QJsonDocument::Compact));
if(resNum == -1 || ! tcp.waitForBytesWritten()) {
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when write 'proEnd'");
tcp.close();
return;
};
if(! tcp.waitForReadyRead()) { if(! tcp.waitForReadyRead()) {
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when waitForRead 'proEnd'"); emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when waitForRead 'imgFileEnd'");
tcp.close(); tcp.close();
return; return;
} }
auto resp = tcp.readAll(); auto resp = tcp.readAll();
if(resp.isEmpty()) { if(resp.isEmpty()) {
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when read 'proEnd'"); emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when read 'imgFileEnd'");
tcp.close(); tcp.close();
return; return;
} }

View File

@ -92,13 +92,13 @@ private:
QGroupBox *grpBoxHiddenSettings; QGroupBox *grpBoxHiddenSettings;
QPushButton *btnSysUpd, *btnMcuUpd, *btnMcuGet; QPushButton *btnSysUpd, *btnMcuUpd, *btnMcuGet;
QPushButton *btnRotateSet, *btnRotateGet; QPushButton *btnRotateSet, *btnRotateGet, *btnChargingStationSet;
QLabel *lbRotate, *lbBaudCfg, *lbBaudModel, *lbUart, *lbBaud; QLabel *lbRotate, *lbChargingStation, *lbBaudCfg, *lbBaudModel, *lbUart, *lbBaud;
QPushButton *btnBaudSet, *btnBaudGet; QPushButton *btnBaudSet, *btnBaudGet;
QCheckBox *fdIsOpenADB; QCheckBox *fdIsOpenADB;
QLabel *lbCustomJson; QLabel *lbCustomJson;
QTextEdit *fdCustomJson; QTextEdit *fdCustomJson;
QPushButton *btnSendCustomJson; QPushButton *btnSendCustomJson, *btnCustomJsonGet;
QLabel *lbTraficProtocol, *lbCardMode, *lbTraficPort; QLabel *lbTraficProtocol, *lbCardMode, *lbTraficPort;
QComboBox *fdServerType; QComboBox *fdServerType;

View File

@ -1,5 +1,5 @@
#include "ctrlbrightpanel.h" #include "ctrlbrightpanel.h"
#include "base/waitingdlg.h" #include "gutil/qwaitingdlg.h"
#include "gutil/qnetwork.h" #include "gutil/qnetwork.h"
#include "globaldefine.h" #include "globaldefine.h"
#include "tools.h" #include "tools.h"
@ -17,16 +17,15 @@
CtrlBrightPanel::CtrlBrightPanel() { CtrlBrightPanel::CtrlBrightPanel() {
auto vBox = new VBox(this); auto vBox = new VBox(this);
vBox->setContentsMargins(0,0,0,0); vBox->setContentsMargins(6,6,6,0);
vBox->addSpacing(8);
lbBrightCfg = new QLabel; lbTitle = new QLabel;
auto font = lbBrightCfg->font(); auto ft = lbTitle->font();
font.setPixelSize(font.pixelSize()+2); ft.setPixelSize(16);
font.setBold(true); ft.setBold(true);
lbBrightCfg->setFont(font); lbTitle->setFont(ft);
lbBrightCfg->setAlignment(Qt::AlignCenter); lbTitle->setAlignment(Qt::AlignCenter);
vBox->addWidget(lbBrightCfg); vBox->addWidget(lbTitle);
vBox->addSpacing(9); vBox->addSpacing(9);
auto hBox = new HBox(vBox); auto hBox = new HBox(vBox);
@ -528,7 +527,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
auto item = findItem(card.id); auto item = findItem(card.id);
if(item) { if(item) {
item->mCard.bright = bright; item->mCard.bright = bright;
item->setData(DeviceTable_Brightness, 0, QString::number(bright)+"%"); item->setText("brightness", QString::number(bright)+"%");
} }
}); });
} else { } else {
@ -544,7 +543,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
auto item = findItem(card.id); auto item = findItem(card.id);
if(item) { if(item) {
item->mCard.bright = bright; item->mCard.bright = bright;
item->setData(DeviceTable_Brightness, 0, err); item->setText("brightness", err);
} }
} }
gFdResInfo->append(card.id+" "+tr("Brightness")+" "+err); gFdResInfo->append(card.id+" "+tr("Brightness")+" "+err);
@ -618,7 +617,6 @@ CtrlBrightPanel::CtrlBrightPanel() {
btnScheClear = new QPushButton; btnScheClear = new QPushButton;
btnScheClear->setMinimumSize(60, 30); btnScheClear->setMinimumSize(60, 30);
btnScheClear->setProperty("ssType", "progManageTool"); btnScheClear->setProperty("ssType", "progManageTool");
connect(btnScheClear, &QPushButton::clicked, this, [this] {tableSche->setRowCount(0);});
hBox->addWidget(btnScheClear); hBox->addWidget(btnScheClear);
hBox->addStretch(); hBox->addStretch();
@ -719,15 +717,17 @@ CtrlBrightPanel::CtrlBrightPanel() {
hBox->addWidget(btnScheExport); hBox->addWidget(btnScheExport);
tableSche = new Table({ tableSche = new TableWidget{
{"bright", "", 300}, {"bright", "", 300},
{"start", "", 100}, {"start", "", 100},
{"end", "", 100} {"end", "", 100}
}); };
tableSche->setDefs(); tableSche->setDefs();
tableSche->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); tableSche->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
vBox->addWidget(tableSche); vBox->addWidget(tableSche);
connect(btnScheClear, &QPushButton::clicked, tableSche, &TableWidget::clearRows);
hBox = new HBox(vBox); hBox = new HBox(vBox);
hBox->addStretch(); hBox->addStretch();
@ -866,7 +866,7 @@ void CtrlBrightPanel::changeEvent(QEvent *event) {
if(event->type() == QEvent::LanguageChange) transUi(); if(event->type() == QEvent::LanguageChange) transUi();
} }
void CtrlBrightPanel::transUi() { void CtrlBrightPanel::transUi() {
lbBrightCfg->setText(tr("Brightness Configuration")); lbTitle->setText(tr("Brightness Config"));
radioAuto->setText(tr("Auto")); radioAuto->setText(tr("Auto"));
radioManual->setText(tr("Manual")); radioManual->setText(tr("Manual"));
radioSchedule->setText(tr("Schedule")); radioSchedule->setText(tr("Schedule"));

View File

@ -20,7 +20,7 @@ protected:
private: private:
bool restoreScheduleJson(QJsonDocument &, int); bool restoreScheduleJson(QJsonDocument &, int);
void getScheduleJson(QJsonObject &, int); void getScheduleJson(QJsonObject &, int);
QLabel *lbBrightCfg; QLabel *lbTitle;
QRadioButton *radioAuto; QRadioButton *radioAuto;
QRadioButton *radioManual; QRadioButton *radioManual;
QRadioButton *radioSchedule; QRadioButton *radioSchedule;
@ -59,7 +59,7 @@ private:
QSlider *fdDefBright; QSlider *fdDefBright;
QPushButton *btnScheImport; QPushButton *btnScheImport;
QPushButton *btnScheExport; QPushButton *btnScheExport;
Table *tableSche; TableWidget *tableSche;
QPushButton *btnScheSet; QPushButton *btnScheSet;
QPushButton *btnScheGet; QPushButton *btnScheGet;
}; };

View File

@ -3,7 +3,7 @@
#include "gutil/qnetwork.h" #include "gutil/qnetwork.h"
#include "tools.h" #include "tools.h"
#include "globaldefine.h" #include "globaldefine.h"
#include "base/waitingdlg.h" #include "gutil/qwaitingdlg.h"
#include <QMessageBox> #include <QMessageBox>
#include <QButtonGroup> #include <QButtonGroup>
#include <QTimeEdit> #include <QTimeEdit>
@ -13,16 +13,18 @@
CtrlHdmiPanel::CtrlHdmiPanel() { CtrlHdmiPanel::CtrlHdmiPanel() {
auto vBox = new QVBoxLayout(this); auto vBox = new QVBoxLayout(this);
vBox->setContentsMargins(6,6,6,0);
lbHdmiCfg = new QLabel; lbHdmiCfg = new QLabel;
auto ft = lbHdmiCfg->font();
ft.setPixelSize(16);
ft.setBold(true);
lbHdmiCfg->setFont(ft);
lbHdmiCfg->setAlignment(Qt::AlignCenter); lbHdmiCfg->setAlignment(Qt::AlignCenter);
vBox->addWidget(lbHdmiCfg); vBox->addWidget(lbHdmiCfg);
vBox->addSpacing(9);
auto line = new QFrame; auto hBox = new HBox(vBox);
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
vBox->addWidget(line);
auto hBox = new QHBoxLayout();
hBox->addStretch(); hBox->addStretch();
fdManual = new QRadioButton; fdManual = new QRadioButton;
@ -33,8 +35,6 @@ CtrlHdmiPanel::CtrlHdmiPanel() {
hBox->addWidget(fdSchedule); hBox->addWidget(fdSchedule);
hBox->addStretch(); hBox->addStretch();
vBox->addLayout(hBox);
auto stacked = new QStackedLayout(vBox); auto stacked = new QStackedLayout(vBox);
{ {
auto vBox = new VBox(stacked); auto vBox = new VBox(stacked);
@ -150,7 +150,7 @@ CtrlHdmiPanel::CtrlHdmiPanel() {
auto hBox = new HBox(vBox); auto hBox = new HBox(vBox);
hBox->setSpacing(10); hBox->setSpacing(10);
tableSche = new Table({ tableSche = new TableWidget{
{"start", "", 100}, {"start", "", 100},
{"end", "", 100}, {"end", "", 100},
{"0", "", 60}, {"0", "", 60},
@ -160,9 +160,8 @@ CtrlHdmiPanel::CtrlHdmiPanel() {
{"4", "", 60}, {"4", "", 60},
{"5", "", 60}, {"5", "", 60},
{"6", "", 60} {"6", "", 60}
}); };
tableSche->setDefs(); tableSche->setDefs();
tableSche->setStyleSheet("Table {selection-background-color: #8ce;}");
btnScheAdd = new QPushButton; btnScheAdd = new QPushButton;
btnScheAdd->setMinimumSize(QSize(60, 30)); btnScheAdd->setMinimumSize(QSize(60, 30));
@ -199,7 +198,7 @@ CtrlHdmiPanel::CtrlHdmiPanel() {
btnScheClear = new QPushButton; btnScheClear = new QPushButton;
btnScheClear->setMinimumSize(QSize(60, 30)); btnScheClear->setMinimumSize(QSize(60, 30));
btnScheClear->setProperty("ssType", "progManageTool"); btnScheClear->setProperty("ssType", "progManageTool");
connect(btnScheClear, &QPushButton::clicked, tableSche, &Table::clearRows); connect(btnScheClear, &QPushButton::clicked, tableSche, &TableWidget::clearRows);
hBox->addWidget(btnScheClear); hBox->addWidget(btnScheClear);
hBox->addStretch(); hBox->addStretch();

View File

@ -23,7 +23,7 @@ private:
QRadioButton *fdManual, *fdSchedule, *fdAsync, *fdHdmi, *fdHdmi2; QRadioButton *fdManual, *fdSchedule, *fdAsync, *fdHdmi, *fdHdmi2;
QPushButton *btnSyncSet, *btnSyncGet; QPushButton *btnSyncSet, *btnSyncGet;
Table *tableSche; TableWidget *tableSche;
QPushButton *btnScheAdd; QPushButton *btnScheAdd;
QPushButton *btnScheDel; QPushButton *btnScheDel;
QPushButton *btnScheClear; QPushButton *btnScheClear;

View File

@ -1,5 +1,5 @@
#include "ctrlnetworkpanel.h" #include "ctrlnetworkpanel.h"
#include "base/waitingdlg.h" #include "gutil/qwaitingdlg.h"
#include "globaldefine.h" #include "globaldefine.h"
#include "tools.h" #include "tools.h"
#include "devicepanel.h" #include "devicepanel.h"
@ -346,7 +346,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
if(gSelCards.count() == 1) { if(gSelCards.count() == 1) {
auto waitingDlg = new WaitingDlg(this, tr("ConfigurationWiFi")+" ..."); auto waitingDlg = new WaitingDlg(this, tr("ConfigurationWiFi")+" ...");
Def_CtrlReqPre Def_CtrlReqPre
connect(reply, &QNetworkReply::finished, this, [=] { connect(reply, &QNetworkReply::finished, waitingDlg, [=] {
QString err = checkReplyForJson(reply); QString err = checkReplyForJson(reply);
if(! err.isEmpty()) { if(! err.isEmpty()) {
waitingDlg->close(); waitingDlg->close();
@ -354,8 +354,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
return; return;
} }
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json2); auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json2);
waitingDlg->connAbort(reply); ConnReply(reply, waitingDlg) [=] {
connect(reply, &QNetworkReply::finished, this, [=] {
Def_CtrlSetReqAfter Def_CtrlSetReqAfter
}); });
}); });

View File

@ -2,7 +2,7 @@
#include "globaldefine.h" #include "globaldefine.h"
#include "deviceitem.h" #include "deviceitem.h"
#include "devicepanel.h" #include "devicepanel.h"
#include "base/waitingdlg.h" #include "gutil/qwaitingdlg.h"
#include "gutil/qnetwork.h" #include "gutil/qnetwork.h"
#include "tools.h" #include "tools.h"
#include <QMessageBox> #include <QMessageBox>
@ -12,10 +12,16 @@
CtrlPowerPanel::CtrlPowerPanel() { CtrlPowerPanel::CtrlPowerPanel() {
auto vBox = new VBox(this); auto vBox = new VBox(this);
vBox->setContentsMargins(6,6,6,0);
lbScreenCfg = new QLabel; lbScreenCfg = new QLabel;
auto ft = lbScreenCfg->font();
ft.setPixelSize(16);
ft.setBold(true);
lbScreenCfg->setFont(ft);
lbScreenCfg->setAlignment(Qt::AlignCenter); lbScreenCfg->setAlignment(Qt::AlignCenter);
vBox->addWidget(lbScreenCfg); vBox->addWidget(lbScreenCfg);
vBox->addSpacing(9);
auto hBox = new HBox(vBox); auto hBox = new HBox(vBox);
hBox->addStretch(); hBox->addStretch();
@ -92,8 +98,8 @@ CtrlPowerPanel::CtrlPowerPanel() {
auto item = findItem(card.id); auto item = findItem(card.id);
if(item) { if(item) {
item->mCard.isScreenOn = json["on"].toBool(); item->mCard.isScreenOn = json["on"].toBool();
item->setForeground(DeviceTable_Power, item->mCard.isScreenOn ? Qt::green : Qt::red); item->setForeground("power", item->mCard.isScreenOn ? Qt::green : Qt::red);
item->setData(DeviceTable_Power, 0, item->mCard.isScreenOn ? tr("On") : tr("Off")); item->setText("power", item->mCard.isScreenOn ? tr("On") : tr("Off"));
} }
}); });
} else { } else {
@ -107,8 +113,8 @@ CtrlPowerPanel::CtrlPowerPanel() {
auto item = findItem(card.id); auto item = findItem(card.id);
if(item) { if(item) {
item->mCard.isScreenOn = json["on"].toBool(); item->mCard.isScreenOn = json["on"].toBool();
item->setForeground(DeviceTable_Power, item->mCard.isScreenOn ? Qt::green : Qt::red); item->setForeground("power", item->mCard.isScreenOn ? Qt::green : Qt::red);
item->setData(DeviceTable_Power, 0, err); item->setText("power", err);
} }
} }
gFdResInfo->append(card.id+" "+tr("IsScreenOn")+" "+err); gFdResInfo->append(card.id+" "+tr("IsScreenOn")+" "+err);
@ -124,7 +130,7 @@ CtrlPowerPanel::CtrlPowerPanel() {
auto hBox = new HBox(vBox); auto hBox = new HBox(vBox);
hBox->setSpacing(10); hBox->setSpacing(10);
tableSche = new Table({ tableSche = new TableWidget{
{"start", "", 100}, {"start", "", 100},
{"end", "", 100}, {"end", "", 100},
{"0", "", 60}, {"0", "", 60},
@ -134,7 +140,7 @@ CtrlPowerPanel::CtrlPowerPanel() {
{"4", "", 60}, {"4", "", 60},
{"5", "", 60}, {"5", "", 60},
{"6", "", 60} {"6", "", 60}
}); };
tableSche->setDefs(); tableSche->setDefs();
pushButtonAdd = new QPushButton; pushButtonAdd = new QPushButton;
@ -172,7 +178,7 @@ CtrlPowerPanel::CtrlPowerPanel() {
pushButtonClear = new QPushButton; pushButtonClear = new QPushButton;
pushButtonClear->setMinimumSize(QSize(60, 30)); pushButtonClear->setMinimumSize(QSize(60, 30));
pushButtonClear->setProperty("ssType", "progManageTool"); pushButtonClear->setProperty("ssType", "progManageTool");
connect(pushButtonClear, &QPushButton::clicked, tableSche, &Table::clearRows); connect(pushButtonClear, &QPushButton::clicked, tableSche, &TableWidget::clearRows);
hBox->addWidget(pushButtonClear); hBox->addWidget(pushButtonClear);
hBox->addStretch(); hBox->addStretch();

View File

@ -34,7 +34,7 @@ private:
QPushButton *pushButtonImport; QPushButton *pushButtonImport;
QPushButton *pushButtonExport; QPushButton *pushButtonExport;
QLabel *labelPowerScheduleTip; QLabel *labelPowerScheduleTip;
Table *tableSche; TableWidget *tableSche;
QPushButton *pushButtonApply; QPushButton *pushButtonApply;
QPushButton *pushButtonClearSchedule; QPushButton *pushButtonClearSchedule;
QPushButton *pushButtonReadback; QPushButton *pushButtonReadback;

View File

@ -1,7 +1,7 @@
#include "ctrlpwdpanel.h" #include "ctrlpwdpanel.h"
#include "gutil/qgui.h" #include "gutil/qgui.h"
#include "gutil/qnetwork.h" #include "gutil/qnetwork.h"
#include "base/waitingdlg.h" #include "gutil/qwaitingdlg.h"
#include "QFileDialog" #include "QFileDialog"
#include <QMessageBox> #include <QMessageBox>
#include <QJsonObject> #include <QJsonObject>
@ -12,7 +12,13 @@
CtrlPwdPanel::CtrlPwdPanel() { CtrlPwdPanel::CtrlPwdPanel() {
auto vBox = new VBox(this); auto vBox = new VBox(this);
vBox->setContentsMargins(6,6,6,0);
lbPwdConfig = new QLabel; lbPwdConfig = new QLabel;
auto font = lbPwdConfig->font();
font.setPixelSize(16);
font.setBold(true);
lbPwdConfig->setFont(font);
lbPwdConfig->setAlignment(Qt::AlignCenter); lbPwdConfig->setAlignment(Qt::AlignCenter);
vBox->addWidget(lbPwdConfig); vBox->addWidget(lbPwdConfig);
vBox->addSpacing(20); vBox->addSpacing(20);

View File

@ -2,7 +2,7 @@
#include "tools.h" #include "tools.h"
#include "gutil/qgui.h" #include "gutil/qgui.h"
#include "gutil/qnetwork.h" #include "gutil/qnetwork.h"
#include "base/waitingdlg.h" #include "gutil/qwaitingdlg.h"
#include <QFileDialog> #include <QFileDialog>
#include <QLineEdit> #include <QLineEdit>
#include <QJsonObject> #include <QJsonObject>

View File

@ -1,5 +1,5 @@
#include "ctrlverifyclockpanel.h" #include "ctrlverifyclockpanel.h"
#include "base/waitingdlg.h" #include "gutil/qwaitingdlg.h"
#include "gutil/qnetwork.h" #include "gutil/qnetwork.h"
#include "globaldefine.h" #include "globaldefine.h"
#include "gutil/qgui.h" #include "gutil/qgui.h"

View File

@ -1,6 +1,6 @@
#include "ctrlvolumepanel.h" #include "ctrlvolumepanel.h"
#include "globaldefine.h" #include "globaldefine.h"
#include "base/waitingdlg.h" #include "gutil/qwaitingdlg.h"
#include "gutil/qnetwork.h" #include "gutil/qnetwork.h"
#include "tools.h" #include "tools.h"
#include <QMessageBox> #include <QMessageBox>
@ -11,10 +11,16 @@
CtrlVolumePanel::CtrlVolumePanel() { CtrlVolumePanel::CtrlVolumePanel() {
auto vBox = new VBox(this); auto vBox = new VBox(this);
vBox->setContentsMargins(6,6,6,0);
lbVolumeControl = new QLabel; lbVolumeControl = new QLabel;
auto ft = lbVolumeControl->font();
ft.setPixelSize(16);
ft.setBold(true);
lbVolumeControl->setFont(ft);
lbVolumeControl->setAlignment(Qt::AlignCenter); lbVolumeControl->setAlignment(Qt::AlignCenter);
vBox->addWidget(lbVolumeControl); vBox->addWidget(lbVolumeControl);
vBox->addSpacing(9);
auto hBox = new HBox(vBox); auto hBox = new HBox(vBox);
hBox->addStretch(); hBox->addStretch();
@ -180,7 +186,6 @@ CtrlVolumePanel::CtrlVolumePanel() {
btnScheClear = new QPushButton; btnScheClear = new QPushButton;
btnScheClear->setMinimumSize(60, 30); btnScheClear->setMinimumSize(60, 30);
btnScheClear->setProperty("ssType", "progManageTool"); btnScheClear->setProperty("ssType", "progManageTool");
connect(btnScheClear, &QPushButton::clicked, this, [this] {tableSche->setRowCount(0);});
hBox->addWidget(btnScheClear); hBox->addWidget(btnScheClear);
lbDefBright = new QLabel; lbDefBright = new QLabel;
@ -234,7 +239,7 @@ CtrlVolumePanel::CtrlVolumePanel() {
}); });
hBox->addWidget(btnScheExport); hBox->addWidget(btnScheExport);
tableSche = new Table({ tableSche = new TableWidget{
{"vol", "", 300}, {"vol", "", 300},
{"start", "", 100}, {"start", "", 100},
{"end", "", 100}, {"end", "", 100},
@ -245,9 +250,10 @@ CtrlVolumePanel::CtrlVolumePanel() {
{"4", "", 60}, {"4", "", 60},
{"5", "", 60}, {"5", "", 60},
{"6", "", 60} {"6", "", 60}
}); };
tableSche->setDefs(); tableSche->setDefs();
vBox->addWidget(tableSche); vBox->addWidget(tableSche);
connect(btnScheClear, &QPushButton::clicked, tableSche, &TableWidget::clearRows);
hBox = new HBox(vBox); hBox = new HBox(vBox);
hBox->addStretch(); hBox->addStretch();

View File

@ -36,7 +36,7 @@ private:
QSlider *fdDefBright; QSlider *fdDefBright;
QPushButton *btnScheImport; QPushButton *btnScheImport;
QPushButton *btnScheExport; QPushButton *btnScheExport;
Table *tableSche; TableWidget *tableSche;
QPushButton *btnScheSet; QPushButton *btnScheSet;
QPushButton *btnScheGet; QPushButton *btnScheGet;
}; };

View File

@ -199,7 +199,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
item->fdProgress->setValue(bytesSent*100/bytesTotal); item->fdProgress->setValue(bytesSent*100/bytesTotal);
}); });
ConnReply(reply, item->fdProgress) [=] { ConnReply(reply, item->fdProgress) [=] {
QString err = errStrWithData(reply); auto err = errStrWithData(reply);
if(! err.isEmpty()) { if(! err.isEmpty()) {
item->setResult(tr("Upload error")+": "+err, Qt::red); item->setResult(tr("Upload error")+": "+err, Qt::red);
item->isUpdating = false; item->isUpdating = false;