This commit is contained in:
Gangphon 2024-06-06 21:55:36 +08:00
parent 2e0aefd05a
commit f4cc005daa
14 changed files with 324 additions and 187 deletions

View File

@ -18,14 +18,16 @@ greaterThan(QT_MAJOR_VERSION, 5) {
CONFIG += lrelease CONFIG += lrelease
CONFIG += embed_translations CONFIG += embed_translations
#DEFINES += leyide
#DEFINES += citta
# 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.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
VERSION = 1.5.1 VERSION = 1.5.2
DEFINES += APP_VERSION=\\\"$$VERSION\\\" DEFINES += APP_VERSION=\\\"$$VERSION\\\"
msvc { msvc {
contains(QT_ARCH, i386) { contains(QT_ARCH, i386) {
@ -39,8 +41,18 @@ win32 {
LIBS += -lwinmm LIBS += -lwinmm
LIBS += -lDbghelp LIBS += -lDbghelp
contains(DEFINES, leyide) {
message(leyide)
RC_ICONS = res/Logo-leyide.ico
} else {
contains(DEFINES, citta) {
message(citta)
RC_ICONS = res/Logo-citta.ico
} else {
RC_ICONS = res/Logo.ico RC_ICONS = res/Logo.ico
} }
}
}
osx { osx {
QMAKE_MACOSX_DEPLOYMENT_TARGET = 11.0 QMAKE_MACOSX_DEPLOYMENT_TARGET = 11.0
-mmacosx-version-min=11.0 -mmacosx-version-min=11.0

View File

@ -27,6 +27,8 @@
#include <QButtonGroup> #include <QButtonGroup>
#include "devicepanel.h" #include "devicepanel.h"
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QInputDialog>
#include <QStandardPaths>
CtrlAdvancedPanel::CtrlAdvancedPanel() { CtrlAdvancedPanel::CtrlAdvancedPanel() {
setFocusPolicy(Qt::StrongFocus); setFocusPolicy(Qt::StrongFocus);
@ -89,8 +91,18 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter Def_CtrlSetReqAfter
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("SetScreenSize")) auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
connect(reply, &QNetworkReply::finished, gFdResInfo, [=] {
auto err = checkReplyForJson(reply);
gFdResInfo->append(card.id+" "+tr("SetScreenSize")+" "+(err.isEmpty() ? QCoreApplication::translate("Def","Success") : err));
// if(! err.isEmpty()) return;
// auto item = findItem(card.id);
// if(item) {
// item->mCard.ScreenResolution = aaa;
// item->setText("ScreenResolution", aaa);
// }
});
} }
} }
}); });
@ -129,10 +141,10 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
} }
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json); auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
connect(reply, &QNetworkReply::finished, gFdResInfo, [=] { connect(reply, &QNetworkReply::finished, gFdResInfo, [=] {
QString err = checkReplyForJson(reply); auto err = checkReplyForJson(reply);
gFdResInfo->append(card.id+" "+tr("SetCardAlias")+" "+(err.isEmpty() ? QCoreApplication::translate("Def","Success") : err)); gFdResInfo->append(card.id+" "+tr("SetCardAlias")+" "+(err.isEmpty() ? QCoreApplication::translate("Def","Success") : err));
if(! err.isEmpty()) return; if(! err.isEmpty()) return;
auto item = findItem(card.id); auto item = findItem(card.id);
@ -194,7 +206,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter Def_CtrlSetReqAfter
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card :gSelCards) {
Def_CtrlSetMulti(tr("SetOnlineAddr")) Def_CtrlSetMulti(tr("SetOnlineAddr"))
} }
} }
@ -230,7 +242,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter Def_CtrlSetReqAfter
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("SetRealtimeServer")) Def_CtrlSetMulti(tr("SetRealtimeServer"))
} }
} }
@ -256,7 +268,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter Def_CtrlSetReqAfter
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("ClearRealtimeServer")) Def_CtrlSetMulti(tr("ClearRealtimeServer"))
} }
} }
@ -361,7 +373,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter Def_CtrlSetReqAfter
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("UninstallSoftware")) Def_CtrlSetMulti(tr("UninstallSoftware"))
} }
} }
@ -393,7 +405,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
QMessageBox::information(this, tr("Tip"), json["running"].toBool() ? tr("running") : tr("no running")); QMessageBox::information(this, tr("Tip"), json["running"].toBool() ? tr("running") : tr("no running"));
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json); auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id; auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] { connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
@ -426,7 +438,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter Def_CtrlSetReqAfter
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("RestartAndroid")) Def_CtrlSetMulti(tr("RestartAndroid"))
} }
} }
@ -555,7 +567,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, [=] {
@ -669,10 +681,10 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
tcp.close(); tcp.close();
continue; continue;
} }
fd->append(tcp.readAll()); fd->insertPlainText(tcp.readAll());
while(tcp.waitForReadyRead(1000)) { while(tcp.waitForReadyRead(1000)) {
if(lll.cnt==0) return; if(lll.cnt==0) return;
fd->append(tcp.readAll()); fd->insertPlainText(tcp.readAll());
} }
if(lll.cnt==0) return; 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"); if(tcp.error()!=QAbstractSocket::SocketTimeoutError) fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead2\n");
@ -724,10 +736,10 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
tcp.close(); tcp.close();
continue; continue;
} }
fd->append(tcp.readAll()); fd->insertPlainText(tcp.readAll());
while(tcp.waitForReadyRead(1000)) { while(tcp.waitForReadyRead(1000)) {
if(lll.cnt==0) return; if(lll.cnt==0) return;
fd->append(tcp.readAll()); fd->insertPlainText(tcp.readAll());
} }
if(lll.cnt==0) return; 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"); if(tcp.error()!=QAbstractSocket::SocketTimeoutError) fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead2\n");
@ -779,10 +791,10 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
tcp.close(); tcp.close();
continue; continue;
} }
fd->append(tcp.readAll()); fd->insertPlainText(tcp.readAll());
while(tcp.waitForReadyRead(1000)) { while(tcp.waitForReadyRead(1000)) {
if(lll.cnt==0) return; if(lll.cnt==0) return;
fd->append(tcp.readAll()); fd->insertPlainText(tcp.readAll());
} }
if(lll.cnt==0) return; 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"); if(tcp.error()!=QAbstractSocket::SocketTimeoutError) fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead2\n");
@ -834,10 +846,10 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
tcp.close(); tcp.close();
continue; continue;
} }
fd->append(tcp.readAll()); fd->insertPlainText(tcp.readAll());
while(tcp.waitForReadyRead(1000)) { while(tcp.waitForReadyRead(1000)) {
if(lll.cnt==0) return; if(lll.cnt==0) return;
fd->append(tcp.readAll()); fd->insertPlainText(tcp.readAll());
} }
if(lll.cnt==0) return; 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"); if(tcp.error()!=QAbstractSocket::SocketTimeoutError) fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead2\n");
@ -847,6 +859,87 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
}); });
hBox->addWidget(GetBuf); hBox->addWidget(GetBuf);
auto btnDownFile = new QPushButton("Down File");
btnDownFile->setProperty("ssType", "progManageTool");
connect(btnDownFile, &QPushButton::clicked, this, [this] {
if(gSelCards.isEmpty()) {
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
return;
}
QInputDialog dlg(this);
dlg.setWindowTitle("Input File Name");
dlg.setLabelText("File Name");
if(dlg.exec() != QDialog::Accepted) return;
auto name = dlg.textValue();
if(name.isEmpty()) return;
auto tar = QFileDialog::getSaveFileName(this, "Save File", QStandardPaths::writableLocation(QStandardPaths::DownloadLocation)+"/"+name);
if(tar.isEmpty()) return;
JObj json{{"_type", "GetFile"}, {"name", name}};
QProgressBar fdProgress;
fdProgress.show();
for(auto &card : gSelCards) {
fdProgress.setWindowTitle("Progress "+card.id);
fdProgress.setValue(0);
TcpSocket tcp;
tcp.connectToHost(card.ip, 3333);
if(! tcp.waitForConnected()) {
if(! fdProgress.isVisible()) return;
QMessageBox::information(this, tr("Error"), QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitConnected");
tcp.close();
continue;
}
QFile file(tar+" "+card.id);
if(! file.open(QFile::WriteOnly)) continue;
auto resNum = tcp.write(JToBytes(json));
tcp.flush();
if(resNum == -1 || ! tcp.waitForBytesWritten()) {
if(! fdProgress.isVisible()) return;
QMessageBox::information(this, tr("Error"), QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at write");
tcp.close();
continue;
}
resNum = 0;
qint64 tarSize = 0;
while(tcp.waitForReadyRead(10000)) {
if(! fdProgress.isVisible()) return;
if(tarSize==0) {
QString err;
auto json = JFrom(&tcp, &err);
if(! err.isEmpty()) {
QMessageBox::information(this, tr("Error"), err);
goto end;
}
auto msg = json["msg"].toStr();
if(! msg.isEmpty()) {
QMessageBox::information(this, tr("Error"), msg);
goto end;
}
tarSize = json["len"].toLong();
if(tarSize==0) {
QMessageBox::information(this, tr("Error"), "tarSize==0");
goto end;
}
fdProgress.setMaximum(tarSize);
}
auto res = tcp.readAll();
if(res.size()==0) continue;
if(file.write(res) != res.size()) {
QMessageBox::information(this, tr("Error"), "write error");
goto end;
}
resNum += res.size();
fdProgress.setValue(resNum);
if(resNum>=tarSize) goto end;
}
QMessageBox::information(this, tr("Error"), QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead2\n");
end:
tcp.close();
}
fdProgress.close();
QMessageBox::information(this, tr("Error"), "OK");
});
hBox->addWidget(btnDownFile);
hBox->addStretch(); hBox->addStretch();
hBox = new HBox(vBox); hBox = new HBox(vBox);
hBox->addWidget(lbTimingReboot = new QLabel); hBox->addWidget(lbTimingReboot = new QLabel);
@ -873,7 +966,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter Def_CtrlSetReqAfter
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("Set Timing Reboot")) Def_CtrlSetMulti(tr("Set Timing Reboot"))
} }
} }
@ -899,7 +992,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
fdRebootTime->setText(json["time"].toString()); fdRebootTime->setText(json["time"].toString());
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json); auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id; auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] { connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
@ -965,7 +1058,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
waitingDlg->success(); waitingDlg->success();
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
NetReq req("http://"+card.ip+":2016/upload?type=update_display"); NetReq req("http://"+card.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);
connect(reply, &QNetworkReply::finished, this, [=] { connect(reply, &QNetworkReply::finished, this, [=] {
@ -1010,7 +1103,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter Def_CtrlSetReqAfter
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("Set Display Mode")) Def_CtrlSetMulti(tr("Set Display Mode"))
} }
} }
@ -1036,7 +1129,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
SetCurData(fdDisMode, json["result"].toInt()); SetCurData(fdDisMode, json["result"].toInt());
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json); auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id; auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [=] { connect(reply, &QNetworkReply::finished, this, [=] {
@ -1089,7 +1182,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter Def_CtrlSetReqAfter
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("Set Screen Offset")) Def_CtrlSetMulti(tr("Set Screen Offset"))
} }
} }
@ -1116,7 +1209,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
fdScreenOff->setValue(json["offsetValue"].toInt()); fdScreenOff->setValue(json["offsetValue"].toInt());
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json); auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id; auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [=] { connect(reply, &QNetworkReply::finished, this, [=] {
@ -1166,7 +1259,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
QMessageBox::information(this, btnReceCardsGet->text(), QString::number(json["receCardNum"].toInt())); QMessageBox::information(this, btnReceCardsGet->text(), QString::number(json["receCardNum"].toInt()));
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json); auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id; auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [=] { connect(reply, &QNetworkReply::finished, this, [=] {
@ -1269,7 +1362,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
waitingDlg->success(); waitingDlg->success();
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":3000").timeout(120000).post(json); auto reply = NetReq("http://"+card.ip+":3000").timeout(120000).post(json);
auto cardId = card.id; auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] { connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
@ -1327,7 +1420,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter Def_CtrlSetReqAfter
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("SetHighForBusy")) Def_CtrlSetMulti(tr("SetHighForBusy"))
} }
} }
@ -1354,7 +1447,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
else fdHighForBusy->setChecked(true); else fdHighForBusy->setChecked(true);
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json); auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id; auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] { connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
@ -1403,7 +1496,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter Def_CtrlSetReqAfter
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("SetMinBrightness")) Def_CtrlSetMulti(tr("SetMinBrightness"))
} }
} }
@ -1432,7 +1525,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
fdMinBright->setText(QString::number(value)); fdMinBright->setText(QString::number(value));
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json); auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id; auto cardId = card.id;
auto brightLevel = card.BrightnessLevel; auto brightLevel = card.BrightnessLevel;
@ -1480,7 +1573,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter Def_CtrlSetReqAfter
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("SetMaxBrightness")) Def_CtrlSetMulti(tr("SetMaxBrightness"))
} }
} }
@ -1509,7 +1602,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
fdMaxBright->setText(QString::number(value)); fdMaxBright->setText(QString::number(value));
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json); auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id; auto cardId = card.id;
auto brightLevel = card.BrightnessLevel; auto brightLevel = card.BrightnessLevel;
@ -1565,7 +1658,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter Def_CtrlSetReqAfter
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("Set Wallpaper")) Def_CtrlSetMulti(tr("Set Wallpaper"))
} }
} }
@ -1589,7 +1682,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter Def_CtrlSetReqAfter
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("System Update")) Def_CtrlSetMulti(tr("System Update"))
} }
} }
@ -1678,7 +1771,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
QMessageBox::information(this, tr("Tip"), tr("MCU Version")+": "+json["mcuVersion"].toString()); QMessageBox::information(this, tr("Tip"), tr("MCU Version")+": "+json["mcuVersion"].toString());
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json); auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id; auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] { connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
@ -1719,7 +1812,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
}); });
thread->start(); thread->start();
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
auto thread = new PlayerBackSendThread(file, card.ip); auto thread = new PlayerBackSendThread(file, card.ip);
auto cardId = card.id; auto cardId = card.id;
connect(thread, &PlayerBackSendThread::emErr, this, [cardId](QString err) { connect(thread, &PlayerBackSendThread::emErr, this, [cardId](QString err) {
@ -1786,7 +1879,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
tcp->connectToHost(card.ip, 3333); tcp->connectToHost(card.ip, 3333);
timer->start(10000); timer->start(10000);
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
auto tcp = new QTcpSocket(); auto tcp = new QTcpSocket();
auto timer = new QTimer(tcp); auto timer = new QTimer(tcp);
timer->setSingleShot(true); timer->setSingleShot(true);
@ -1872,7 +1965,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter Def_CtrlSetReqAfter
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("SetSpecialResolution")) Def_CtrlSetMulti(tr("SetSpecialResolution"))
} }
} }
@ -1898,7 +1991,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
fdM80Resolu->setCurrentText(json["displayResolution"].toString()); fdM80Resolu->setCurrentText(json["displayResolution"].toString());
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json); auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id; auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] { connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
@ -1929,7 +2022,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter Def_CtrlSetReqAfter
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("CleanDisplayScreenSize")) Def_CtrlSetMulti(tr("CleanDisplayScreenSize"))
} }
} }
@ -1979,7 +2072,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter Def_CtrlSetReqAfter
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("SetScreenRotation")) Def_CtrlSetMulti(tr("SetScreenRotation"))
} }
} }
@ -2006,7 +2099,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
if(btn) btn->setChecked(true); if(btn) btn->setChecked(true);
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json); auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
connect(reply, &QNetworkReply::finished, this, [=] { connect(reply, &QNetworkReply::finished, this, [=] {
QJsonDocument json; QJsonDocument json;
@ -2053,7 +2146,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter Def_CtrlSetReqAfter
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("Set")+" "+tr("Charging Station")+" ID") Def_CtrlSetMulti(tr("Set")+" "+tr("Charging Station")+" ID")
} }
} }
@ -2149,7 +2242,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter Def_CtrlSetReqAfter
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("Set Baud Rate")) Def_CtrlSetMulti(tr("Set Baud Rate"))
} }
} }
@ -2176,7 +2269,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
fdBaud->setText(QString::number(json["baud"].toInt())); fdBaud->setText(QString::number(json["baud"].toInt()));
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json); auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id; auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] { connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
@ -2209,7 +2302,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter Def_CtrlSetReqAfter
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("OpenAdb")) Def_CtrlSetMulti(tr("OpenAdb"))
} }
} }
@ -2252,7 +2345,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter Def_CtrlSetReqAfter
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("AliIotSetting")) Def_CtrlSetMulti(tr("AliIotSetting"))
} }
} }
@ -2291,7 +2384,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
else QMessageBox::information(this, tr("Info"), reply->readAll()); else QMessageBox::information(this, tr("Info"), reply->readAll());
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json); auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
connect(reply, &QNetworkReply::finished, gFdResInfo, [=] { connect(reply, &QNetworkReply::finished, gFdResInfo, [=] {
auto err = errStrWithData(reply); auto err = errStrWithData(reply);
@ -2340,7 +2433,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter Def_CtrlSetReqAfter
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("Set protocol")) Def_CtrlSetMulti(tr("Set protocol"))
} }
} }
@ -2366,7 +2459,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
SetCurData(fdTraficProtocol, json["protocolType"].toInt()); SetCurData(fdTraficProtocol, json["protocolType"].toInt());
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json); auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id; auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [reply, cardId, fdTraficProtocol] { connect(reply, &QNetworkReply::finished, this, [reply, cardId, fdTraficProtocol] {
@ -2427,7 +2520,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter Def_CtrlSetReqAfter
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("Set card work mode")) Def_CtrlSetMulti(tr("Set card work mode"))
} }
} }
@ -2454,7 +2547,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
fdPort->setValue(json["port"].toInt()); fdPort->setValue(json["port"].toInt());
}); });
} else { } else {
foreach(auto card, gSelCards) { for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json); auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id; auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [=] { connect(reply, &QNetworkReply::finished, this, [=] {

View File

@ -59,39 +59,7 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
setFont(ft); setFont(ft);
auto menuLang = new QMenu; auto menuLang = new QMenu;
auto actCN = new QAction("中文");
actCN->setCheckable(true);
actCN->setObjectName("zh_CN");
menuLang->addAction(actCN);
auto actTW = new QAction("中文繁体");
actTW->setCheckable(true);
actTW->setObjectName("zh_TW");
menuLang->addAction(actTW);
auto actEn = new QAction("English");
actEn->setCheckable(true);
actEn->setObjectName("en");
menuLang->addAction(actEn);
auto actJa = new QAction("日本語");
actJa->setCheckable(true);
actJa->setObjectName("ja");
menuLang->addAction(actJa);
auto actPt = new QAction("Português");
actPt->setCheckable(true);
actPt->setObjectName("pt");
menuLang->addAction(actPt);
langGrp = new QActionGroup(menuLang); langGrp = new QActionGroup(menuLang);
langGrp->addAction(actCN);
langGrp->addAction(actTW);
langGrp->addAction(actEn);
langGrp->addAction(actJa);
langGrp->addAction(actPt);
connect(menuLang, &QMenu::triggered, this, [this](QAction* action) { connect(menuLang, &QMenu::triggered, this, [this](QAction* action) {
auto lanName = action->objectName(); auto lanName = action->objectName();
qInfo() << "load translators" << lanName << translator.load("app_"+lanName, ":/i18n"); qInfo() << "load translators" << lanName << translator.load("app_"+lanName, ":/i18n");
@ -110,6 +78,85 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
} }
QString langName = settings.value("Language").toString(); QString langName = settings.value("Language").toString();
QAction *actLan = 0; QAction *actLan = 0;
#ifdef leyide
auto actTW = new QAction("中文繁体");
actTW->setCheckable(true);
actTW->setObjectName("zh_TW");
menuLang->addAction(actTW);
langGrp->addAction(actTW);
auto actEn = new QAction("English");
actEn->setCheckable(true);
actEn->setObjectName("en");
menuLang->addAction(actEn);
langGrp->addAction(actEn);
if(! langName.isEmpty()) {
if(langName.endsWith("TW")) actLan = actTW;
else if(langName.startsWith("en")) actLan = actEn;
}
if(actLan==0) {
langName = QLocale().name();
if(langName.startsWith("en")) actLan = actEn;
else actLan = actTW;
}
auto LogoPath = ":/res/Logo-leyide.png";
iconPos = QRectF(38, 20, 64, 64);
#elif defined(citta)
auto actPt = new QAction("Português");
actPt->setCheckable(true);
actPt->setObjectName("pt");
menuLang->addAction(actPt);
langGrp->addAction(actPt);
auto actEn = new QAction("English");
actEn->setCheckable(true);
actEn->setObjectName("en");
menuLang->addAction(actEn);
langGrp->addAction(actEn);
if(! langName.isEmpty()) {
if(langName.endsWith("pt")) actLan = actPt;
else if(langName.startsWith("en")) actLan = actEn;
}
if(actLan==0) {
langName = QLocale().name();
if(langName.startsWith("en")) actLan = actEn;
else actLan = actPt;
}
auto LogoPath = ":/res/Logo-citta.png";
iconPos = QRectF(14, 20, 132, 64);
#else
auto actCN = new QAction("中文");
actCN->setCheckable(true);
actCN->setObjectName("zh_CN");
menuLang->addAction(actCN);
langGrp->addAction(actCN);
auto actTW = new QAction("中文繁体");
actTW->setCheckable(true);
actTW->setObjectName("zh_TW");
menuLang->addAction(actTW);
langGrp->addAction(actTW);
auto actEn = new QAction("English");
actEn->setCheckable(true);
actEn->setObjectName("en");
menuLang->addAction(actEn);
langGrp->addAction(actEn);
auto actJa = new QAction("日本語");
actJa->setCheckable(true);
actJa->setObjectName("ja");
menuLang->addAction(actJa);
langGrp->addAction(actJa);
auto actPt = new QAction("Português");
actPt->setCheckable(true);
actPt->setObjectName("pt");
menuLang->addAction(actPt);
langGrp->addAction(actPt);
if(! langName.isEmpty()) { if(! langName.isEmpty()) {
if(langName.endsWith("CN")) actLan = actCN; if(langName.endsWith("CN")) actLan = actCN;
else if(langName.endsWith("TW")) actLan = actTW; else if(langName.endsWith("TW")) actLan = actTW;
@ -125,7 +172,10 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
else if(langName.startsWith("pt")) actLan = actPt; else if(langName.startsWith("pt")) actLan = actPt;
else actLan = actCN; else actLan = actCN;
} }
auto LogoPath = ":/res/Logo.png";
setWindowTitle("LedOK Express");
iconPos = QRectF(38, 20, 64, 64);
#endif
actLan->setChecked(true); actLan->setChecked(true);
emit menuLang->triggered(actLan); emit menuLang->triggered(actLan);
QCoreApplication::installTranslator(&translator); QCoreApplication::installTranslator(&translator);
@ -137,10 +187,8 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
gPlayPos = settings.value("PlayPos").toPoint(); gPlayPos = settings.value("PlayPos").toPoint();
setWindowTitle("LedOK Express"); icon.load(LogoPath);
icon.load(":/res/Logo.png");
titlePos = QPointF(26, 80); titlePos = QPointF(26, 80);
iconPos = QRectF(38, 20, 64, 64);
auto plt = palette(); auto plt = palette();
plt.setBrush(QPalette::Window, QColor(0xdddddd)); plt.setBrush(QPalette::Window, QColor(0xdddddd));
setPalette(plt); setPalette(plt);
@ -270,8 +318,9 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
}); });
menu_setting->addAction(actPreferences); menu_setting->addAction(actPreferences);
act_update = new QAction(tr("Check for updates")); #if !defined leyide && !defined citta
connect(act_update, &QAction::triggered, this, [this] { act_upd = new QAction(tr("Check for updates"));
connect(act_upd, &QAction::triggered, this, [this] {
{ {
QDialog dlg(this); QDialog dlg(this);
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
@ -355,7 +404,7 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
QCoreApplication::quit(); QCoreApplication::quit();
QDesktopServices::openUrl(QUrl::fromLocalFile(filePath)); QDesktopServices::openUrl(QUrl::fromLocalFile(filePath));
}); });
menu_setting->addAction(act_update); menu_setting->addAction(act_upd);
auto reply = NetReq(UpdVerUrl).timeout(60000).get(); auto reply = NetReq(UpdVerUrl).timeout(60000).get();
ConnReply(reply, this) [=] { ConnReply(reply, this) [=] {
@ -384,9 +433,10 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
if(verCompare(updates["ver"].toString(), APP_VERSION) > 0) { if(verCompare(updates["ver"].toString(), APP_VERSION) > 0) {
hasNewVer = true; hasNewVer = true;
bn_Setting->setIcon(QIcon(":/res/AppSettingTip.png")); bn_Setting->setIcon(QIcon(":/res/AppSettingTip.png"));
act_update->setIcon(QIcon(":/res/reddot.png")); act_upd->setIcon(QIcon(":/res/reddot.png"));
} }
}); });
#endif
act_help = new QAction(); act_help = new QAction();
connect(act_help, &QAction::triggered, this, [this] { connect(act_help, &QAction::triggered, this, [this] {
@ -405,8 +455,9 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
}); });
menu_setting->addAction(actInfo); menu_setting->addAction(actInfo);
#if !defined leyide && !defined citta
act_about = new QAction(tr("About")); act_about = new QAction(tr("About"));
connect(act_about, &QAction::triggered, this, [this] { connect(act_about, &QAction::triggered, this, [=] {
QDialog dlg(this); QDialog dlg(this);
dlg.setWindowFlag(Qt::WindowContextHelpButtonHint, false); dlg.setWindowFlag(Qt::WindowContextHelpButtonHint, false);
dlg.setWindowTitle(tr("About")); dlg.setWindowTitle(tr("About"));
@ -416,7 +467,7 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
hBox->setSpacing(24); hBox->setSpacing(24);
auto label = new QLabel; auto label = new QLabel;
label->setPixmap(QPixmap(":/res/Logo.png")); label->setPixmap(QPixmap(LogoPath));
hBox->addWidget(label); hBox->addWidget(label);
auto vBox = new VBox(hBox); auto vBox = new VBox(hBox);
@ -442,10 +493,10 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
label->setAlignment(Qt::AlignCenter); label->setAlignment(Qt::AlignCenter);
label->setOpenExternalLinks(true); label->setOpenExternalLinks(true);
vBox->addWidget(label); vBox->addWidget(label);
dlg.exec(); dlg.exec();
}); });
menu_setting->addAction(act_about); menu_setting->addAction(act_about);
#endif
bn_Setting->setMenu(menu_setting);//按钮上添加下拉菜单 bn_Setting->setMenu(menu_setting);//按钮上添加下拉菜单
vBox->addWidget(m_wTitle); vBox->addWidget(m_wTitle);
@ -455,7 +506,7 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
auto hBox = new HBox(vBox); auto hBox = new HBox(vBox);
hBox->setSpacing(2); hBox->setSpacing(2);
hBox->addSpacing(144); hBox->addSpacing(150);
mBtnGrp = new QButtonGroup(this); mBtnGrp = new QButtonGroup(this);
for(int i=0; i<MainPage_End; i++) { for(int i=0; i<MainPage_End; i++) {
@ -651,8 +702,8 @@ void MainWindow::transUi() {
act_lang->setText(tr("Language")); act_lang->setText(tr("Language"));
act_help->setText(tr("Help")); act_help->setText(tr("Help"));
actInfo->setText(tr("Info")); actInfo->setText(tr("Info"));
act_about->setText(tr("About")); if(act_about) act_about->setText(tr("About"));
act_update->setText(tr("Check for updates")); if(act_upd) act_upd->setText(tr("Check for updates"));
actFirmware->setText(tr("firmware manager")); actFirmware->setText(tr("firmware manager"));
actPreferences->setText(tr("Preferences")); actPreferences->setText(tr("Preferences"));
bn_Setting->setToolTip(tr("Setting")); bn_Setting->setToolTip(tr("Setting"));

View File

@ -26,10 +26,10 @@ private:
QActionGroup *langGrp; QActionGroup *langGrp;
QAction *act_lang; QAction *act_lang;
QAction *act_help, *actInfo; QAction *act_help, *actInfo;
QAction *act_update; QAction *act_upd = 0;
QAction *actFirmware; QAction *actFirmware;
QAction *actPreferences; QAction *actPreferences;
QAction *act_about; QAction *act_about = 0;
QPushButton *bn_Setting; QPushButton *bn_Setting;
QButtonGroup *mBtnGrp; QButtonGroup *mBtnGrp;

View File

@ -12,6 +12,7 @@
#include <QProgressBar> #include <QProgressBar>
#include <QFileDialog> #include <QFileDialog>
#include <QLineEdit> #include <QLineEdit>
#include <QProcess>
ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) { ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
@ -240,6 +241,17 @@ ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
bnExport->setEnabled(en); bnExport->setEnabled(en);
bnSend->setEnabled(en); bnSend->setEnabled(en);
}); });
connect(table, &LoQTreeWidget::itemPressed, this, [=](QTreeWidgetItem *item, int) {
if(((QApplication*)QApplication::instance())->mouseButtons()==Qt::RightButton) {
auto menu = new QMenu(table);
auto act = new QAction("Open folder");
menu->addAction(act);
connect(act, &QAction::triggered, this, [=] {
QProcess::execute("explorer", {((ProgItem*)item)->mProgDir.replace('/', '\\')});
});
menu->exec(QCursor::pos()+QPoint{2,2});
}
});
vBox->addWidget(mProgTree = table); vBox->addWidget(mProgTree = table);
auto dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); auto dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);

View File

@ -143,8 +143,6 @@ QWidget* EVideo::attrWgt() {
fdDuration->setValue(mDuration); fdDuration->setValue(mDuration);
auto outFile = transcoding(wgtAttr, rawFile, mRawName, mPageItem->mPageDir, mCoverImg.width(), mCoverImg.height(), codecId); auto outFile = transcoding(wgtAttr, rawFile, mRawName, mPageItem->mPageDir, mCoverImg.width(), mCoverImg.height(), codecId);
if(outFile.isEmpty()) return; if(outFile.isEmpty()) return;
QFile oldfile(mDir+"/"+mName);
if(oldfile.exists()) oldfile.remove();
QFileInfo outInfo(outFile); QFileInfo outInfo(outFile);
mDir = outInfo.absolutePath(); mDir = outInfo.absolutePath();
mName = outInfo.fileName(); mName = outInfo.fileName();

View File

@ -125,7 +125,7 @@ SendProgramDialog::SendProgramDialog(QString progName, QWidget *parent) : QDialo
bool ok; bool ok;
auto pwd = QInputDialog::getText(this, tr("Input password"), tr("Input password"), QLineEdit::Password, QString(), &ok); auto pwd = QInputDialog::getText(this, tr("Input password"), tr("Input password"), QLineEdit::Password, QString(), &ok);
if(! ok) return; if(! ok) return;
QJsonObject json; JObj json;
json.insert("_id", "VerifyPassword"); json.insert("_id", "VerifyPassword");
json.insert("_type", "VerifyPassword"); json.insert("_type", "VerifyPassword");
json.insert("pwd", pwd); json.insert("pwd", pwd);

View File

@ -2,7 +2,6 @@
#include "gutil/qnetwork.h" #include "gutil/qnetwork.h"
#include <QHostAddress> #include <QHostAddress>
#include <QDir> #include <QDir>
#include <QJsonArray>
#include <QDirIterator> #include <QDirIterator>
#include <QMessageBox> #include <QMessageBox>
#include <QMetaEnum> #include <QMetaEnum>
@ -13,8 +12,8 @@ SendProgThread::SendProgThread(const QString &progDir, const QString &ip, int po
void SendProgThread::run() { void SendProgThread::run() {
emit emProgress(0); // 进度条归零 emit emProgress(0); // 进度条归零
auto fileInfos = QDir(prog_dir).entryInfoList(QDir::Files); auto fileNames = QDir(prog_dir).entryList(QDir::Files);
if(fileInfos.isEmpty()) { if(fileNames.isEmpty()) {
emit emErr(tr("Program is empty")); emit emErr(tr("Program is empty"));
return; return;
} }
@ -22,7 +21,7 @@ void SendProgThread::run() {
TcpSocket tcp; TcpSocket tcp;
tcp.connectToHost(ip, port); tcp.connectToHost(ip, port);
if(! tcp.waitForConnected()) { if(! tcp.waitForConnected()) {
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when waitForConnected"); emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at waitForConnected");
tcp.close(); tcp.close();
return; return;
} }
@ -31,88 +30,64 @@ void SendProgThread::run() {
return; return;
}; };
//发送节目列表协商 //发送节目列表协商
QJsonArray ids; JArray files;
foreach(auto fileInfo, fileInfos) { for(auto &name : fileNames) if(name!="program") {
auto baseName = fileInfo.baseName(); QFileInfo info(prog_dir+"/"+name);
if(baseName!="program") ids.append(baseName); files.append(JObj{{"name", info.baseName()}, {"size", info.size()}});
} }
if(! ids.isEmpty()) { if(! files.empty()) {
QJsonObject req; JObj req;
req.insert("_type", "consult"); req.insert("_type", "consult");
req.insert("proName", "program"); req.insert("files", files);
req.insert("idList", ids); req.insert("idList", JArray{"aaa"});
req.insert("zVer", "xixun1"); req.insert("zVer", "xixun1");
auto requ = QJsonDocument(req).toJson(QJsonDocument::Compact); auto resNum = tcp.write(JToBytes(req));
auto resNum = tcp.write(requ);
tcp.flush(); tcp.flush();
if(resNum == -1 || ! tcp.waitForBytesWritten()) { if(resNum == -1 || ! tcp.waitForBytesWritten() || ! tcp.waitForReadyRead()) {
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when write 'consult'. size"+QString::number(requ.size())); emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at waitForRead 'checkExist'");
tcp.close();
return;
}
if(! tcp.waitForReadyRead()) {
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when waitForRead 'consult'. size"+QString::number(requ.size()));
tcp.close(); tcp.close();
return; return;
} }
auto resp = tcp.readAll(); auto resp = tcp.readAll();
if(resp.isEmpty()) { QString error;
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when read 'consult'. size"+QString::number(requ.size())); auto res = JFrom(resp, &error);
tcp.close(); while(error.endsWith("end-of-input")) {
return;
}
if(stoped) {
tcp.close();
return;
};
QJsonParseError parseErr;
QJsonDocument res = QJsonDocument::fromJson(resp, &parseErr);
for(int i=2; parseErr.error == QJsonParseError::UnterminatedString && i < 10; i++) {
if(! tcp.waitForReadyRead()) { if(! tcp.waitForReadyRead()) {
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when waitForRead 'consult' "+QString::number(i)); emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at waitForRead2 'checkExist'");
tcp.close(); tcp.close();
return; return;
} }
auto resp2 = tcp.readAll(); resp += tcp.readAll();
if(resp2.isEmpty()) { res = JFrom(resp, &error);
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when read 'consult' "+QString::number(i)); }
if(! error.isEmpty()) {
emit emErr(error+" at parse 'checkExist'");
tcp.close(); tcp.close();
return; return;
} }
resp += resp2; auto existeds = res["existed"].toArray();
res = QJsonDocument::fromJson(resp, &parseErr); for(auto &existed : existeds) fileNames.removeAll(existed.toString());
}
if(parseErr.error != QJsonParseError::NoError) {
emit emErr(parseErr.errorString()+" when parse consult. size:"+QString::number(resp.size()));
tcp.close();
return;
}
if(res["_type"].toString()=="consult") {
fileInfos.clear();
fileInfos.append(QFileInfo(prog_dir+"/program"));
auto ids = res["idList"].toArray();
for(auto id : ids) fileInfos.append(QFileInfo(prog_dir+"/"+id.toString()));
}
} }
if(stoped) { if(stoped) {
tcp.close(); tcp.close();
return; return;
} }
qint64 progSize = 0; qint64 progSize = 0;
foreach(auto fileInfo, fileInfos) progSize += fileInfo.size(); for(auto &name : fileNames) progSize += QFileInfo(prog_dir+"/"+name).size();
if(progSize == 0) { if(progSize == 0) {
emit emErr(tr("Program is empty")); emit emErr(tr("Program is empty"));
tcp.close(); tcp.close();
return; return;
} }
auto req = QJsonObject(); auto req = JObj();
req.insert("_type", "proStart"); req.insert("_type", "proStart");
req.insert("proName", "program"); req.insert("proName", "program");
req.insert("proSize", progSize); req.insert("proSize", progSize);
req.insert("zVer","xixun1"); req.insert("zVer","xixun1");
auto resNum = tcp.write(QJsonDocument(req).toJson(QJsonDocument::Compact)); auto resNum = tcp.write(JToBytes(req));
tcp.flush();
if(resNum == -1 || ! tcp.waitForBytesWritten()) { if(resNum == -1 || ! tcp.waitForBytesWritten()) {
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when write 'proStart'"); emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at write 'proStart'");
tcp.close(); tcp.close();
return; return;
} }
@ -123,18 +98,18 @@ void SendProgThread::run() {
//4.发送协商列表应答里的文件 //4.发送协商列表应答里的文件
int64_t sentBytes = 0; int64_t sentBytes = 0;
char buf[8192]; char buf[8192];
for(auto &info : fileInfos) if(info.isFile()) { for(auto &name : fileNames) {
QFileInfo info(prog_dir+"/"+name);
auto baseName = info.baseName(); auto baseName = info.baseName();
auto remain = info.size(); auto remain = info.size();
req = QJsonObject(); req = JObj();
req.insert("_type", "fileStart"); req.insert("_type", "fileStart");
req.insert("id", baseName); req.insert("id", baseName);
req.insert("size", remain); req.insert("size", remain);
req.insert("relative_path", "");
req.insert("zVer","xixun1"); req.insert("zVer","xixun1");
auto resNum = tcp.write(QJsonDocument(req).toJson(QJsonDocument::Compact)); auto resNum = tcp.write(JToBytes(req));
if(resNum == -1 || ! tcp.waitForBytesWritten()) { if(resNum == -1) {
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when write 'fileStart'"); emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at write 'fileStart'");
tcp.close(); tcp.close();
return; return;
} }
@ -158,14 +133,14 @@ void SendProgThread::run() {
return; return;
}; };
if(! tcp.waitForBytesWritten(60000)) { if(! tcp.waitForBytesWritten(60000)) {
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when waitForWritten file: "+file->fileName()); emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at waitForWritten file: "+file->fileName());
tcp.close(); tcp.close();
file->close(); file->close();
return; return;
} }
resNum = tcp.write(buf, resNum); resNum = tcp.write(buf, resNum);
if(resNum <= 0) { if(resNum <= 0) {
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when write file: "+file->fileName()); emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at write file: "+file->fileName());
tcp.close(); tcp.close();
file->close(); file->close();
return; return;
@ -184,13 +159,14 @@ void SendProgThread::run() {
tcp.close(); tcp.close();
return; return;
}; };
req = QJsonObject(); req = JObj();
req.insert("_type", "fileEnd"); req.insert("_type", "fileEnd");
req.insert("id", baseName); req.insert("id", baseName);
req.insert("zVer", "xixun1"); req.insert("zVer", "xixun1");
resNum = tcp.write(QJsonDocument(req).toJson(QJsonDocument::Compact)); resNum = tcp.write(JToBytes(req));
tcp.flush();
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()+" at write 'fileEnd'");
tcp.close(); tcp.close();
return; return;
} }
@ -200,24 +176,25 @@ void SendProgThread::run() {
return; return;
}; };
//5.发送结束 //5.发送结束
req = QJsonObject(); req = JObj();
req.insert("_type", "proEnd"); req.insert("_type", "proEnd");
req.insert("proName", "program"); req.insert("proName", "program");
req.insert("zVer","xixun1"); req.insert("zVer","xixun1");
resNum = tcp.write(QJsonDocument(req).toJson(QJsonDocument::Compact)); resNum = tcp.write(JToBytes(req));
tcp.flush();
if(resNum == -1 || ! tcp.waitForBytesWritten()) { if(resNum == -1 || ! tcp.waitForBytesWritten()) {
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when write 'proEnd'"); emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at write 'proEnd'");
tcp.close(); tcp.close();
return; 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()+" at waitForRead 'proEnd'");
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()+" at read 'proEnd'");
tcp.close(); tcp.close();
return; return;
} }

View File

@ -1,13 +1,6 @@
#ifndef SENDPROGTHREAD_H #ifndef SENDPROGTHREAD_H
#define SENDPROGTHREAD_H #define SENDPROGTHREAD_H
#include <QThread> #include <QThread>
#include <QFileInfo>
#include <QJsonValue>
#include <QJsonObject>
#include <QJsonDocument>
#include <QAbstractSocket>
#include <QSemaphore>
#include <QDataStream>
class SendProgThread : public QThread { class SendProgThread : public QThread {
Q_OBJECT Q_OBJECT
@ -28,7 +21,7 @@ private:
QString prog_dir; QString prog_dir;
QString ip; QString ip;
int port = 3333; int port = 3333;
std::atomic_bool stoped{false}; std::atomic_bool stoped = false;
}; };
#endif // SENDPROGTHREAD_H #endif // SENDPROGTHREAD_H

View File

@ -29,8 +29,9 @@
<file>res/GuangYingPin_s.png</file> <file>res/GuangYingPin_s.png</file>
<file>res/GuangYingPin_u.png</file> <file>res/GuangYingPin_u.png</file>
<file>res/Hdmi.png</file> <file>res/Hdmi.png</file>
<file>res/Logo.ico</file>
<file>res/Logo.png</file> <file>res/Logo.png</file>
<file>res/Logo-leyide.png</file>
<file>res/Logo-citta.png</file>
<file>res/program/AClock.png</file> <file>res/program/AClock.png</file>
<file>res/program/Add.png</file> <file>res/program/Add.png</file>
<file>res/program/AddPlan.png</file> <file>res/program/AddPlan.png</file>

BIN
LedOK/res/Logo-citta.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

BIN
LedOK/res/Logo-citta.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
LedOK/res/Logo-leyide.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

BIN
LedOK/res/Logo-leyide.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB