ledok增加版本提示

This commit is contained in:
Gangphon 2024-03-29 15:23:12 +08:00
parent 6015d932d3
commit 332897f9cf
12 changed files with 2425 additions and 2466 deletions

View File

@ -25,7 +25,7 @@ CONFIG += embed_translations
# 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.0 VERSION = 1.5.1
DEFINES += APP_VERSION=\\\"$$VERSION\\\" DEFINES += APP_VERSION=\\\"$$VERSION\\\"
msvc { msvc {
contains(QT_ARCH, i386) { contains(QT_ARCH, i386) {

View File

@ -232,7 +232,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
if(isApk || ! json["hasProgress"].toBool()) { if(isApk || ! json["hasProgress"].toBool()) {
item->isUpdating = false; item->isUpdating = false;
item->setResult(tr("Install Success"), Qt::darkGreen); item->setResult(tr("Install Success"), Qt::darkGreen);
if(isApk) item->OnCheckSoftVersions(); if(isApk) item->OnCheckSoftVersions(1);
else item->OnCheckFpgaVersions(); else item->OnCheckFpgaVersions();
} else { } else {
sendProgress(item); sendProgress(item);
@ -427,7 +427,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
} }
if(isEmpty) for(int rr=0; rr<cnt; rr++) { if(isEmpty) for(int rr=0; rr<cnt; rr++) {
auto item = table->item(rr); auto item = table->item(rr);
item->setHidden(! (item->text("xixunplayer").contains(text) item->setHidden(! (item->text("playerVer").contains(text)
|| item->text("cardsystem").contains(text) || item->text("cardsystem").contains(text)
|| item->text("starter").contains(text) || item->text("starter").contains(text)
|| item->text("taxiapp").contains(text) || item->text("taxiapp").contains(text)
@ -449,7 +449,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
table->addCol("encrypt", tr("Security"), 40); table->addCol("encrypt", tr("Security"), 40);
table->addCol("progress", tr("Progress"), 100); table->addCol("progress", tr("Progress"), 100);
table->addCol("remarks", tr("State"), 200, QHeaderView::Stretch); table->addCol("remarks", tr("State"), 200, QHeaderView::Stretch);
table->addCol("xixunplayer", "xixunplayer", 70); table->addCol("playerVer", "XixunPlayer", 70);
table->addCol("cardsystem", "cardsystem", 70); table->addCol("cardsystem", "cardsystem", 70);
table->addCol("starter", "starter", 70); table->addCol("starter", "starter", 70);
table->addCol("taxiapp", "taxiapp", 70); table->addCol("taxiapp", "taxiapp", 70);
@ -504,7 +504,7 @@ void UpgradeApkDialog::sendProgress(UpdateApkItem *item) {
if(progre >= 100) { if(progre >= 100) {
item->isUpdating = false; item->isUpdating = false;
item->fdProgress->setValue(100); item->fdProgress->setValue(100);
item->setResult(tr("Install Success"), Qt::darkGreen); item->setResult("FPGA "+tr("Install Success"), Qt::darkGreen);
item->OnCheckFpgaVersions(); item->OnCheckFpgaVersions();
} else if(progre == -1) { } else if(progre == -1) {
item->isUpdating = false; item->isUpdating = false;
@ -536,47 +536,45 @@ void UpdateApkItem::OnCheckFpgaVersions() {
auto reply = NetReq("http://"+text("ip")+":2016/settings").timeout(60000).post(json); auto reply = NetReq("http://"+text("ip")+":2016/settings").timeout(60000).post(json);
ConnReply(reply, fdProgress) [=] { ConnReply(reply, fdProgress) [=] {
if(treeWidget()==0) return; if(treeWidget()==0) return;
QJsonDocument json; JValue json;
QString err = checkReplyForJson(reply, &json); auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) { if(! err.isEmpty()) return;
return;
}
QString strBuf; QString strBuf;
auto vers = json["versions"].toArray(); auto vers = json["versions"];
for(int i=0; i<vers.size(); i++) { for(auto &ver : vers) {
if(i) strBuf += "\n"; if(! strBuf.isEmpty()) strBuf += ", ";
strBuf += "["+QString::number(i)+"]:"+vers[i].toString(); strBuf += ver.toStr();
} }
setText("fpga", strBuf); setText("fpga", strBuf);
auto item = findItem(text("id")); auto item = findItem(text("id"));
if(item) { if(item) item->mCard.HardVersion = strBuf;
item->mCard.HardVersion = strBuf;
}
}); });
} }
void UpdateApkItem::OnCheckSoftVersions() { void UpdateApkItem::OnCheckSoftVersions(int repeat) {
QJsonObject json; QJsonObject json;
json.insert("_id", "CheckSoftVersions"); json.insert("_id", "CheckSoftVersions");
json.insert("_type", "CheckSoftVersions"); json.insert("_type", "CheckSoftVersions");
auto reply = NetReq("http://"+text("ip")+":2016/settings").timeout(60000).post(json); auto reply = NetReq("http://"+text("ip")+":2016/settings").timeout(60000).post(json);
ConnReply(reply, fdProgress) [=] { ConnReply(reply, fdProgress) [=] {
if(treeWidget()==0) return; if(treeWidget()==0) return;
QJsonDocument json; JValue json;
QString err = checkReplyForJson(reply, &json); auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) { if(! err.isEmpty()) return;
return; QString playerVer;
} auto apps = json["apps"];
auto apps = json["apps"].toArray(); for(auto &app : apps) {
foreach(QJsonValue app, apps) { auto packageName = app["packageName"].toStr();
QString packageName = app["packageName"].toString(); if(packageName=="com.xixun.xixunplayer") playerVer = app["versionName"].toStr();
QString verName = app["versionName"].toString(); else if(packageName=="com.xixun.joey.cardsystem") setText("cardsystem", app["versionName"].toStr());
if(packageName=="com.xixun.xixunplayer") setText("xixunplayer", verName); else if(packageName=="net.sysolution.starter") setText("starter", app["versionName"].toStr());
else if(packageName=="com.xixun.joey.cardsystem") setText("cardsystem", verName); else if(packageName=="net.sysolution.taxiapp") setText("taxiapp", app["versionName"].toStr());
else if(packageName=="net.sysolution.starter") setText("starter", verName); else if(packageName=="com.xixun.display") setText("displayer", app["versionName"].toStr());
else if(packageName=="net.sysolution.taxiapp") setText("taxiapp", verName); else if(packageName=="com.xixun.xy.conn") setText("connection", app["versionName"].toStr());
else if(packageName=="com.xixun.display") setText("displayer", verName); else if(packageName=="com.xixun.xy.update") setText("update", app["versionName"].toStr());
else if(packageName=="com.xixun.xy.conn") setText("connection", verName);
else if(packageName=="com.xixun.xy.update") setText("update", verName);
} }
setText("playerVer", playerVer);
auto item = findItem(text("id"));
if(item) item->mCard.playerVer = playerVer;
if(playerVer.isEmpty() && repeat) OnCheckSoftVersions(repeat-1);
}); });
} }

View File

@ -27,7 +27,7 @@ public:
setToolTip(remarks, tip); setToolTip(remarks, tip);
setForeground(remarks, color); setForeground(remarks, color);
} }
void OnCheckSoftVersions(); void OnCheckSoftVersions(int = 0);
void OnCheckFpgaVersions(); void OnCheckFpgaVersions();
QLabel *fdOnline; QLabel *fdOnline;

View File

@ -506,15 +506,15 @@ void DevicePanel::init(DeviceItem *item) {
json.insert("_type", "GetBuildInformation"); json.insert("_type", "GetBuildInformation");
auto reply = NetReq("http://"+item->mCard.ip+":2016/settings").timeout(120000).post(json); auto reply = NetReq("http://"+item->mCard.ip+":2016/settings").timeout(120000).post(json);
ConnReply(reply, item) [=] { ConnReply(reply, item) [=] {
QJsonDocument json; JValue json;
QString err = checkReplyForJson(reply, &json); auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) return; if(! err.isEmpty()) return;
item->mCard.BrightnessLevel = json["BrightnessLevel"].toInt(); item->mCard.BrightnessLevel = json["BrightnessLevel"].toInt();
item->mCard.FirmwareVersion = json["FirmwareVersion"].toString(); item->mCard.FirmwareVersion = json["FirmwareVersion"].toStr();
item->mCard.HardVersion = json["HardVersion"].toString(); item->mCard.HardVersion = json["HardVersion"].toStr();
item->mCard.ScreenResolution = json["ScreenResolution"].toString(); item->mCard.ScreenResolution = json["ScreenResolution"].toStr();
item->mCard.IMEI = json["IMEI"].toString(); item->mCard.IMEI = json["IMEI"].toStr();
auto androidVersion = json["AndroidVersion"].toString(); auto androidVersion = json["AndroidVersion"].toStr();
if(! androidVersion.isEmpty()) item->mCard.androidVersion = androidVersion; if(! androidVersion.isEmpty()) item->mCard.androidVersion = androidVersion;
}); });
@ -524,8 +524,8 @@ void DevicePanel::init(DeviceItem *item) {
json.insert("_type", "GetScreenSize"); json.insert("_type", "GetScreenSize");
reply = NetReq("http://"+item->mCard.ip+":2016/settings").timeout(120000).post(json); reply = NetReq("http://"+item->mCard.ip+":2016/settings").timeout(120000).post(json);
ConnReply(reply, item) [=] { ConnReply(reply, item) [=] {
QJsonDocument json; JValue json;
QString err = checkReplyForJson(reply, &json); auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) return; if(! err.isEmpty()) return;
item->mCard.mWidth = json["width"].toInt(); item->mCard.mWidth = json["width"].toInt();
item->mCard.mHeight = json["height"].toInt(); item->mCard.mHeight = json["height"].toInt();
@ -538,8 +538,8 @@ void DevicePanel::init(DeviceItem *item) {
json.insert("_type", "GetBrightness"); json.insert("_type", "GetBrightness");
reply = NetReq("http://"+item->mCard.ip+":2016/settings").timeout(120000).post(json); reply = NetReq("http://"+item->mCard.ip+":2016/settings").timeout(120000).post(json);
ConnReply(reply, item) [=] { ConnReply(reply, item) [=] {
QJsonDocument json; JValue json;
QString err = checkReplyForJson(reply, &json); auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) return; if(! err.isEmpty()) return;
item->mCard.bright = json["brightnessPercentage"].toInt(-1); item->mCard.bright = json["brightnessPercentage"].toInt(-1);
if(item->mCard.bright==-1) item->mCard.bright = qRound(json["brightness"].toInt() * 100.0 / item->mCard.BrightnessLevel); if(item->mCard.bright==-1) item->mCard.bright = qRound(json["brightness"].toInt() * 100.0 / item->mCard.BrightnessLevel);
@ -550,8 +550,8 @@ void DevicePanel::init(DeviceItem *item) {
json.insert("_type", "IsScreenOn"); json.insert("_type", "IsScreenOn");
reply = NetReq("http://"+item->mCard.ip+":2016/settings").timeout(120000).post(json); reply = NetReq("http://"+item->mCard.ip+":2016/settings").timeout(120000).post(json);
ConnReply(reply, item) [=] { ConnReply(reply, item) [=] {
QJsonDocument json; JValue json;
QString err = checkReplyForJson(reply, &json); auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) return; if(! err.isEmpty()) return;
item->mCard.isScreenOn = json["on"].toBool(); item->mCard.isScreenOn = json["on"].toBool();
item->setForeground("power"**mDeviceTable, item->mCard.isScreenOn ? Qt::green : Qt::red); item->setForeground("power"**mDeviceTable, item->mCard.isScreenOn ? Qt::green : Qt::red);
@ -562,10 +562,10 @@ void DevicePanel::init(DeviceItem *item) {
json.insert("_type", "GetCardAlias"); json.insert("_type", "GetCardAlias");
reply = NetReq("http://"+item->mCard.ip+":2016/settings").timeout(120000).post(json); reply = NetReq("http://"+item->mCard.ip+":2016/settings").timeout(120000).post(json);
ConnReply(reply, item) [=] { ConnReply(reply, item) [=] {
QJsonDocument json; JValue json;
QString err = checkReplyForJson(reply, &json); auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) return; if(! err.isEmpty()) return;
item->mCard.alias = QString::fromUtf8(QByteArray::fromBase64(json["alias"].toString().toLatin1())); item->mCard.alias = QString::fromUtf8(QByteArray::fromBase64(json["alias"].toStr().toLatin1()));
item->setText("alias", item->mCard.alias); item->setText("alias", item->mCard.alias);
}); });
@ -574,8 +574,8 @@ void DevicePanel::init(DeviceItem *item) {
json.insert("_type", "HasControllerPassword"); json.insert("_type", "HasControllerPassword");
reply = NetReq("http://"+item->mCard.ip+":2016/settings").timeout(120000).post(json); reply = NetReq("http://"+item->mCard.ip+":2016/settings").timeout(120000).post(json);
ConnReply(reply, item) [=] { ConnReply(reply, item) [=] {
QJsonDocument json; JValue json;
QString err = checkReplyForJson(reply, &json); auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) return; if(! err.isEmpty()) return;
item->mCard.hasPassword = json["result"].toBool(); item->mCard.hasPassword = json["result"].toBool();
if(item->mCard.hasPassword) {//加过密 if(item->mCard.hasPassword) {//加过密
@ -583,6 +583,21 @@ void DevicePanel::init(DeviceItem *item) {
item->btnUnlock->setIcon(QIcon(item->mCard.isLocked ? ":/res/Lock.png" : ":/res/UnLock.png")); item->btnUnlock->setIcon(QIcon(item->mCard.isLocked ? ":/res/Lock.png" : ":/res/UnLock.png"));
} else item->btnUnlock->hide(); } else item->btnUnlock->hide();
}); });
json = QJsonObject();
json.insert("_id", "CheckSoftVersions");
json.insert("_type", "CheckSoftVersions");
reply = NetReq("http://"+item->mCard.ip+":2016/settings").timeout(120000).post(json);
ConnReply(reply, item) [=] {
JValue json;
auto err = errStrWithJson(reply, &json);
if(! err.isEmpty()) return;
auto apps = json["apps"];
for(auto &app : apps) if(app["packageName"].toStr().contains("xixunplayer")) {
item->mCard.playerVer = app["versionName"].toStr();
return;
}
});
} }
ImgDlg::ImgDlg(const QByteArray &data, QWidget *parent) : QDialog(parent) { ImgDlg::ImgDlg(const QByteArray &data, QWidget *parent) : QDialog(parent) {

View File

@ -45,6 +45,21 @@ QString checkReply(QNetworkReply *reply, QJsonDocument *outJson) {
} }
return ""; return "";
} }
QString errStrWithJson(QNetworkReply *reply, JValue *outJson, QByteArray *outData) {
auto err = errStr(reply);
auto data = reply->readAll();
if(outData) *outData = data;
if(! err.isEmpty()) {
if(! data.isEmpty()) err = err+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
return err;
}
QString error;
auto json = JFrom(data, &error);
if(! error.isEmpty()) return "JSON Error: "+error+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
if(! json["success"].toBool()) return QCoreApplication::translate("Def","Fail")+". "+QCoreApplication::translate("Def","Device replied")+": "+data;
if(outJson) *outJson = json;
return "";
}
QString checkReplyForJson(QNetworkReply *reply, QJsonDocument *outJson, QByteArray *outData) { QString checkReplyForJson(QNetworkReply *reply, QJsonDocument *outJson, QByteArray *outData) {
auto err = errStr(reply); auto err = errStr(reply);
auto data = reply->readAll(); auto data = reply->readAll();

View File

@ -1,20 +1,22 @@
#ifndef GLOBALDEFINE_H #ifndef GLOBALDEFINE_H
#define GLOBALDEFINE_H #define GLOBALDEFINE_H
#include "gutil/qjson.h"
#include <QJsonDocument> #include <QJsonDocument>
#include <QNetworkReply> #include <QNetworkReply>
struct LedCard { struct LedCard {
QString id; QString id;
QString ip; QString ip;
int mWidth{0}; int mWidth = 0;
int mHeight{0}; int mHeight = 0;
int bright{100}; int bright = 100;
int BrightnessLevel{255}; int BrightnessLevel = 255;
QString FirmwareVersion; QString FirmwareVersion;
QString HardVersion = "0000"; QString HardVersion = "0000";
QString ScreenResolution; QString ScreenResolution;
QString androidVersion; QString androidVersion;
QString playerVer;
QString alias; QString alias;
QString IMEI; QString IMEI;
bool hasPassword{false}; bool hasPassword{false};
@ -87,6 +89,7 @@ inline int verCompare(const QString& a, const QString& b) {
} }
QString checkReply(QNetworkReply *, QJsonDocument * = 0); QString checkReply(QNetworkReply *, QJsonDocument * = 0);
QString errStrWithJson(QNetworkReply *, JValue * = 0, QByteArray * = 0);
QString checkReplyForJson(QNetworkReply *, QJsonDocument * = 0, QByteArray * = 0); QString checkReplyForJson(QNetworkReply *, QJsonDocument * = 0, QByteArray * = 0);
QString checkReplyForJson(QNetworkReply *, QString errField); QString checkReplyForJson(QNetworkReply *, QString errField);

View File

@ -35,6 +35,13 @@ SendProgramDialog::SendProgramDialog(QString progName, QWidget *parent) : QDialo
int sentCnt = 0; int sentCnt = 0;
SendProgramItem *item; SendProgramItem *item;
auto remarks = "remarks"**table; auto remarks = "remarks"**table;
for(int rr=0; rr<cnt; rr++) if(! (item = (SendProgramItem*) table->topLevelItem(rr))->isHidden() && item->checkState("id") == Qt::Checked && ! item->isSending) {
auto playerVer = item->text("playerVer");
if(! playerVer.isEmpty() && playerVer[0]>='a' && playerVer[0]<='z') {
if(QMessageBox::No == QMessageBox::question(this, tr("Info"), tr("Some player versions are too low and may not be compatible. It's recommended to update the player to 2.0. Or download the old version %1 from website").arg("<a href='https://ledok.cn/download.html'>LedOK Express 1.4.1</a>")+"<br>\n"+tr("Do you want to continue?"))) return;
break;
}
}
for(int rr=0; rr<cnt; rr++) if(! (item = (SendProgramItem*) table->topLevelItem(rr))->isHidden() && item->checkState("id") == Qt::Checked && ! item->isSending) { for(int rr=0; rr<cnt; rr++) if(! (item = (SendProgramItem*) table->topLevelItem(rr))->isHidden() && item->checkState("id") == Qt::Checked && ! item->isSending) {
if(item->btnUnlock && item->isLocked) { if(item->btnUnlock && item->isLocked) {
item->setResult(tr("This screen is encrypted"), Qt::red); item->setResult(tr("This screen is encrypted"), Qt::red);
@ -101,6 +108,7 @@ SendProgramDialog::SendProgramDialog(QString progName, QWidget *parent) : QDialo
end: end:
item->setText("ip", card.ip); item->setText("ip", card.ip);
item->setText("alias", card.alias); item->setText("alias", card.alias);
item->setText("playerVer", card.playerVer);
item->setText("size", QString("%1 x %2").arg(card.mWidth).arg(card.mHeight)); item->setText("size", QString("%1 x %2").arg(card.mWidth).arg(card.mHeight));
item->fdOnline->setPixmap({card.isOnline ? ":/res/online.png" : ":/res/offline.png"}); item->fdOnline->setPixmap({card.isOnline ? ":/res/online.png" : ":/res/offline.png"});
if(! card.hasPassword) { if(! card.hasPassword) {
@ -176,6 +184,7 @@ SendProgramDialog::SendProgramDialog(QString progName, QWidget *parent) : QDialo
table->addCol("ip", "IP", 100); table->addCol("ip", "IP", 100);
table->addCol("size", tr("Screen Size"), 80).alignC(), table->addCol("size", tr("Screen Size"), 80).alignC(),
table->addCol("alias", tr("Alias"), 120); table->addCol("alias", tr("Alias"), 120);
table->addCol("playerVer", "Player Ver", 70);
table->addCol("encrypt", tr("Security"), 40); table->addCol("encrypt", tr("Security"), 40);
table->addCol("progress", tr("Progress"), 120); table->addCol("progress", tr("Progress"), 120);
table->addCol("remarks", tr("Remarks"), QHeaderView::Stretch); table->addCol("remarks", tr("Remarks"), QHeaderView::Stretch);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff