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 += embed_translations
#DEFINES += leyide
#DEFINES += citta
# 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.
#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\\\"
msvc {
contains(QT_ARCH, i386) {
@ -39,7 +41,17 @@ win32 {
LIBS += -lwinmm
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
}
}
}
osx {
QMAKE_MACOSX_DEPLOYMENT_TARGET = 11.0

View File

@ -27,6 +27,8 @@
#include <QButtonGroup>
#include "devicepanel.h"
#include <QDialogButtonBox>
#include <QInputDialog>
#include <QStandardPaths>
CtrlAdvancedPanel::CtrlAdvancedPanel() {
setFocusPolicy(Qt::StrongFocus);
@ -89,8 +91,18 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
Def_CtrlSetMulti(tr("SetScreenSize"))
for(auto &card : gSelCards) {
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 {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
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));
if(! err.isEmpty()) return;
auto item = findItem(card.id);
@ -194,7 +206,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
for(auto &card :gSelCards) {
Def_CtrlSetMulti(tr("SetOnlineAddr"))
}
}
@ -230,7 +242,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("SetRealtimeServer"))
}
}
@ -256,7 +268,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("ClearRealtimeServer"))
}
}
@ -361,7 +373,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("UninstallSoftware"))
}
}
@ -393,7 +405,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
QMessageBox::information(this, tr("Tip"), json["running"].toBool() ? tr("running") : tr("no running"));
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
@ -426,7 +438,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("RestartAndroid"))
}
}
@ -555,7 +567,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
tcp->connectToHost(card.ip, 3333);
tcp->startTimer(10000);
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto tcp = new TcpSocket;
auto cardId = card.id;
connect(tcp, &QTcpSocket::connected, tcp, [=] {
@ -669,10 +681,10 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
tcp.close();
continue;
}
fd->append(tcp.readAll());
fd->insertPlainText(tcp.readAll());
while(tcp.waitForReadyRead(1000)) {
if(lll.cnt==0) return;
fd->append(tcp.readAll());
fd->insertPlainText(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");
@ -724,10 +736,10 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
tcp.close();
continue;
}
fd->append(tcp.readAll());
fd->insertPlainText(tcp.readAll());
while(tcp.waitForReadyRead(1000)) {
if(lll.cnt==0) return;
fd->append(tcp.readAll());
fd->insertPlainText(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");
@ -779,10 +791,10 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
tcp.close();
continue;
}
fd->append(tcp.readAll());
fd->insertPlainText(tcp.readAll());
while(tcp.waitForReadyRead(1000)) {
if(lll.cnt==0) return;
fd->append(tcp.readAll());
fd->insertPlainText(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");
@ -834,10 +846,10 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
tcp.close();
continue;
}
fd->append(tcp.readAll());
fd->insertPlainText(tcp.readAll());
while(tcp.waitForReadyRead(1000)) {
if(lll.cnt==0) return;
fd->append(tcp.readAll());
fd->insertPlainText(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");
@ -847,6 +859,87 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
});
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 = new HBox(vBox);
hBox->addWidget(lbTimingReboot = new QLabel);
@ -873,7 +966,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("Set Timing Reboot"))
}
}
@ -899,7 +992,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
fdRebootTime->setText(json["time"].toString());
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
@ -965,7 +1058,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
waitingDlg->success();
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
NetReq req("http://"+card.ip+":2016/upload?type=update_display");
auto reply = req.timeout(120000).type("multipart/form-data; boundary="+Boundary).post(data);
connect(reply, &QNetworkReply::finished, this, [=] {
@ -1010,7 +1103,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("Set Display Mode"))
}
}
@ -1036,7 +1129,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
SetCurData(fdDisMode, json["result"].toInt());
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [=] {
@ -1089,7 +1182,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("Set Screen Offset"))
}
}
@ -1116,7 +1209,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
fdScreenOff->setValue(json["offsetValue"].toInt());
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [=] {
@ -1166,7 +1259,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
QMessageBox::information(this, btnReceCardsGet->text(), QString::number(json["receCardNum"].toInt()));
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [=] {
@ -1269,7 +1362,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
waitingDlg->success();
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":3000").timeout(120000).post(json);
auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
@ -1327,7 +1420,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("SetHighForBusy"))
}
}
@ -1354,7 +1447,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
else fdHighForBusy->setChecked(true);
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
@ -1403,7 +1496,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("SetMinBrightness"))
}
}
@ -1432,7 +1525,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
fdMinBright->setText(QString::number(value));
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id;
auto brightLevel = card.BrightnessLevel;
@ -1480,7 +1573,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("SetMaxBrightness"))
}
}
@ -1509,7 +1602,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
fdMaxBright->setText(QString::number(value));
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id;
auto brightLevel = card.BrightnessLevel;
@ -1565,7 +1658,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("Set Wallpaper"))
}
}
@ -1589,7 +1682,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("System Update"))
}
}
@ -1678,7 +1771,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
QMessageBox::information(this, tr("Tip"), tr("MCU Version")+": "+json["mcuVersion"].toString());
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
@ -1719,7 +1812,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
});
thread->start();
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto thread = new PlayerBackSendThread(file, card.ip);
auto cardId = card.id;
connect(thread, &PlayerBackSendThread::emErr, this, [cardId](QString err) {
@ -1786,7 +1879,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
tcp->connectToHost(card.ip, 3333);
timer->start(10000);
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto tcp = new QTcpSocket();
auto timer = new QTimer(tcp);
timer->setSingleShot(true);
@ -1872,7 +1965,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("SetSpecialResolution"))
}
}
@ -1898,7 +1991,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
fdM80Resolu->setCurrentText(json["displayResolution"].toString());
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
@ -1929,7 +2022,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("CleanDisplayScreenSize"))
}
}
@ -1979,7 +2072,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("SetScreenRotation"))
}
}
@ -2006,7 +2099,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
if(btn) btn->setChecked(true);
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
connect(reply, &QNetworkReply::finished, this, [=] {
QJsonDocument json;
@ -2053,7 +2146,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("Set")+" "+tr("Charging Station")+" ID")
}
}
@ -2149,7 +2242,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("Set Baud Rate"))
}
}
@ -2176,7 +2269,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
fdBaud->setText(QString::number(json["baud"].toInt()));
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
@ -2209,7 +2302,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("OpenAdb"))
}
}
@ -2252,7 +2345,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("AliIotSetting"))
}
}
@ -2291,7 +2384,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
else QMessageBox::information(this, tr("Info"), reply->readAll());
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
connect(reply, &QNetworkReply::finished, gFdResInfo, [=] {
auto err = errStrWithData(reply);
@ -2340,7 +2433,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("Set protocol"))
}
}
@ -2366,7 +2459,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
SetCurData(fdTraficProtocol, json["protocolType"].toInt());
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [reply, cardId, fdTraficProtocol] {
@ -2427,7 +2520,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
Def_CtrlSetReqAfter
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
Def_CtrlSetMulti(tr("Set card work mode"))
}
}
@ -2454,7 +2547,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
fdPort->setValue(json["port"].toInt());
});
} else {
foreach(auto card, gSelCards) {
for(auto &card : gSelCards) {
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
auto cardId = card.id;
connect(reply, &QNetworkReply::finished, this, [=] {

View File

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

View File

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

View File

@ -12,6 +12,7 @@
#include <QProgressBar>
#include <QFileDialog>
#include <QLineEdit>
#include <QProcess>
ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
setAttribute(Qt::WA_DeleteOnClose);
@ -240,6 +241,17 @@ ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
bnExport->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);
auto dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);

View File

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

View File

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

View File

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

View File

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

View File

@ -29,8 +29,9 @@
<file>res/GuangYingPin_s.png</file>
<file>res/GuangYingPin_u.png</file>
<file>res/Hdmi.png</file>
<file>res/Logo.ico</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/Add.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