ledok
This commit is contained in:
parent
13ad4ec75f
commit
7fae3c0bd3
|
@ -11,6 +11,7 @@ greaterThan(QT_MAJOR_VERSION, 5) {
|
||||||
CONFIG += c++17
|
CONFIG += c++17
|
||||||
CONFIG += lrelease
|
CONFIG += lrelease
|
||||||
CONFIG += embed_translations
|
CONFIG += embed_translations
|
||||||
|
|
||||||
# CONFIG += console
|
# CONFIG += console
|
||||||
|
|
||||||
# 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.
|
||||||
|
@ -117,6 +118,7 @@ SOURCES += \
|
||||||
ffplayer.cpp \
|
ffplayer.cpp \
|
||||||
globaldefine.cpp \
|
globaldefine.cpp \
|
||||||
gutil/qgui.cpp \
|
gutil/qgui.cpp \
|
||||||
|
gutil/qjson.cpp \
|
||||||
gutil/qnetwork.cpp \
|
gutil/qnetwork.cpp \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
mainwindow.cpp \
|
mainwindow.cpp \
|
||||||
|
@ -164,7 +166,6 @@ SOURCES += \
|
||||||
program/videosplitthread.cpp \
|
program/videosplitthread.cpp \
|
||||||
program/wplanitem.cpp \
|
program/wplanitem.cpp \
|
||||||
program/wplanlist.cpp \
|
program/wplanlist.cpp \
|
||||||
program/wprogrampublishitem.cpp \
|
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
base/changepasswordform.h \
|
base/changepasswordform.h \
|
||||||
|
@ -189,6 +190,7 @@ HEADERS += \
|
||||||
ffplayer.h \
|
ffplayer.h \
|
||||||
globaldefine.h \
|
globaldefine.h \
|
||||||
gutil/qgui.h \
|
gutil/qgui.h \
|
||||||
|
gutil/qjson.h \
|
||||||
gutil/qnetwork.h \
|
gutil/qnetwork.h \
|
||||||
mainwindow.h \
|
mainwindow.h \
|
||||||
mguangyingpinwidget.h \
|
mguangyingpinwidget.h \
|
||||||
|
@ -235,7 +237,6 @@ HEADERS += \
|
||||||
program/videosplitthread.h \
|
program/videosplitthread.h \
|
||||||
program/wplanitem.h \
|
program/wplanitem.h \
|
||||||
program/wplanlist.h \
|
program/wplanlist.h \
|
||||||
program/wprogrampublishitem.h \
|
|
||||||
|
|
||||||
TRANSLATIONS += \
|
TRANSLATIONS += \
|
||||||
translations/app_zh_CN.ts \
|
translations/app_zh_CN.ts \
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
Table {selection-background-color: #8ce;}
|
Table {selection-background-color: #0ae;}
|
||||||
|
|
||||||
|
QCheckBox::indicator, QTableWidget::indicator, QTreeWidget::indicator {
|
||||||
|
width: 1.15em; height: 1.15em;
|
||||||
|
}
|
||||||
|
|
||||||
QLineEdit,QComboBox,QAbstractSpinBox {
|
QLineEdit,QComboBox,QAbstractSpinBox {
|
||||||
border: 1px solid #aaa;
|
border: 1px solid #aaa;
|
||||||
|
@ -38,16 +42,6 @@ QAbstractSpinBox::down-arrow:pressed {
|
||||||
top: 1px;
|
top: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
QCheckBox::indicator, QTreeWidget::indicator {
|
|
||||||
border-image: url(:/res/CheckBoxUnchecked.png); width: 1em; height: 1em; margin-left: 0.25em;
|
|
||||||
}
|
|
||||||
QCheckBox::indicator:checked, QTreeWidget::indicator:checked {
|
|
||||||
border-image: url(:/res/CheckBoxChecked.png);
|
|
||||||
}
|
|
||||||
QCheckBox::indicator:disabled {
|
|
||||||
background-color: #666;
|
|
||||||
}
|
|
||||||
|
|
||||||
ExtendedGroupBox::indicator {
|
ExtendedGroupBox::indicator {
|
||||||
border-image: url(:/res/groupbox-unchecked.png);
|
border-image: url(:/res/groupbox-unchecked.png);
|
||||||
}
|
}
|
||||||
|
@ -77,7 +71,7 @@ QMenu::item:selected {
|
||||||
}
|
}
|
||||||
|
|
||||||
QListWidget {
|
QListWidget {
|
||||||
selection-background-color: #8ce;
|
selection-background-color: #0ae;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoColorSelector {
|
LoColorSelector {
|
||||||
|
@ -92,14 +86,10 @@ LoColorSelector {
|
||||||
QTreeWidget[ssType="topList"]::item {
|
QTreeWidget[ssType="topList"]::item {
|
||||||
border-right: 1px solid #ddd;
|
border-right: 1px solid #ddd;
|
||||||
border-bottom: 1px solid #ddd;
|
border-bottom: 1px solid #ddd;
|
||||||
height: 40px;
|
height: 38px;
|
||||||
}
|
}
|
||||||
QTreeWidget[ssType="topList"] QHeaderView::section {
|
QTreeWidget[ssType="topList"]>QHeaderView::section {
|
||||||
border-top: 1px solid #aaa;
|
height: 30px;
|
||||||
border-bottom: 1px solid #aaa;
|
|
||||||
border-left: 0;
|
|
||||||
border-right: 0;
|
|
||||||
height: 36px;
|
|
||||||
}
|
}
|
||||||
QTreeWidget[ssType="topList"]::item:hover {
|
QTreeWidget[ssType="topList"]::item:hover {
|
||||||
background-color: #ddd;
|
background-color: #ddd;
|
||||||
|
|
|
@ -148,12 +148,12 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
hBox->addWidget(labelWebServer);
|
hBox->addWidget(labelWebServer);
|
||||||
|
|
||||||
fdWebServerAddr = new QComboBox;
|
fdWebServerAddr = new QComboBox;
|
||||||
fdWebServerAddr->addItem(tr("www.m2mled.net"));
|
fdWebServerAddr->addItem("www.m2mled.net");
|
||||||
fdWebServerAddr->addItem(tr("www.ledaips.com"));
|
fdWebServerAddr->addItem("www.ledaips.com");
|
||||||
fdWebServerAddr->addItem(tr("https://www.taxihub.cn:2340"));
|
fdWebServerAddr->addItem("https://www.taxihub.cn:2340");
|
||||||
fdWebServerAddr->addItem(tr("https://www.ledaips.com:2340"));
|
fdWebServerAddr->addItem("https://www.ledaips.com:2340");
|
||||||
fdWebServerAddr->addItem(tr("https://www.36taxi.com:2340"));
|
fdWebServerAddr->addItem("https://www.36taxi.com:2340");
|
||||||
fdWebServerAddr->addItem(tr("www.tlzxled.com"));
|
fdWebServerAddr->addItem("www.tlzxled.com");
|
||||||
fdWebServerAddr->setMinimumWidth(260);
|
fdWebServerAddr->setMinimumWidth(260);
|
||||||
fdWebServerAddr->setEditable(true);
|
fdWebServerAddr->setEditable(true);
|
||||||
hBox->addWidget(fdWebServerAddr);
|
hBox->addWidget(fdWebServerAddr);
|
||||||
|
@ -448,88 +448,71 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
JObj json{{"_type","DelPrograms"},{"_id","DelPrograms"},{"zVer","xixun1"}};
|
||||||
if(gSelCards.count() == 1) {
|
if(gSelCards.count() == 1) {
|
||||||
auto waitingDlg = new WaitingDlg(this, tr("Clearing Program")+" ...");
|
auto waitingDlg = new WaitingDlg(this, tr("Clearing Program")+" ...");
|
||||||
waitingDlg->show();
|
waitingDlg->show();
|
||||||
auto card = gSelCards[0];
|
auto card = gSelCards[0];
|
||||||
auto tcp = new QTcpSocket();
|
auto tcp = new TcpSocket;
|
||||||
auto timer = new QTimer(tcp);
|
|
||||||
timer->setSingleShot(true);
|
|
||||||
connect(timer, &QTimer::timeout, tcp, [=] {
|
|
||||||
waitingDlg->close();
|
|
||||||
tcp->abort();
|
|
||||||
tcp->deleteLater();
|
|
||||||
QMessageBox::critical(this, tr("Tip"), tr("Clear Program")+" "+tr("Timeout"));
|
|
||||||
});
|
|
||||||
connect(waitingDlg, &WaitingDlg::rejected, tcp, [=] {
|
connect(waitingDlg, &WaitingDlg::rejected, tcp, [=] {
|
||||||
timer->stop();
|
|
||||||
tcp->abort();
|
tcp->abort();
|
||||||
tcp->deleteLater();
|
tcp->deleteLater();
|
||||||
});
|
});
|
||||||
connect(tcp, &QTcpSocket::connected, tcp, [=] {
|
connect(tcp, &QTcpSocket::connected, tcp, [=] {
|
||||||
timer->stop();
|
tcp->stopTimer();
|
||||||
tcp->write("{\"_type\":\"DelPrograms\",\"_id\":\"DelPrograms\",\"zVer\":\"xixun1\"}");
|
tcp->write(JToBytes(json));
|
||||||
timer->start(10000);
|
tcp->startTimer(10000);
|
||||||
});
|
});
|
||||||
connect(tcp, &QTcpSocket::readyRead, tcp, [=] {
|
connect(tcp, &QTcpSocket::readyRead, tcp, [=] {
|
||||||
timer->stop();
|
tcp->stopTimer();
|
||||||
QByteArray resp = tcp->readAll();
|
auto resp = tcp->readAll();
|
||||||
tcp->close();
|
tcp->close();
|
||||||
tcp->deleteLater();
|
tcp->deleteLater();
|
||||||
QJsonParseError parseErr;
|
QString error;
|
||||||
QJsonDocument json = QJsonDocument::fromJson(resp, &parseErr);
|
auto json = JFrom(resp, &error);
|
||||||
if(parseErr.error != QJsonParseError::NoError) {
|
if(! error.isEmpty()) {
|
||||||
waitingDlg->close();
|
waitingDlg->close();
|
||||||
QMessageBox::critical(this, tr("Tip"), parseErr.errorString());
|
QMessageBox::critical(this, tr("Tip"), error);
|
||||||
} else if(! json["success"].toBool()) {
|
} else if(! json["success"].toBool()) {
|
||||||
waitingDlg->close();
|
waitingDlg->close();
|
||||||
QMessageBox::critical(this, tr("Tip"), tr("Clear Program")+" "+tr("Failed"));
|
QMessageBox::critical(this, tr("Tip"), tr("Clear Program")+" "+tr("Failed"));
|
||||||
} else waitingDlg->success();
|
} else waitingDlg->success();
|
||||||
});
|
});
|
||||||
connect(tcp, &QTcpSocket::errorOccurred, tcp, [=](QAbstractSocket::SocketError err) {
|
connect(tcp, &QTcpSocket::errorOccurred, tcp, [=](QAbstractSocket::SocketError err) {
|
||||||
timer->stop();
|
|
||||||
tcp->close();
|
tcp->close();
|
||||||
tcp->deleteLater();
|
tcp->deleteLater();
|
||||||
waitingDlg->close();
|
waitingDlg->close();
|
||||||
QMessageBox::critical(this, tr("Tip"), QString(socketErrKey(err))+" ("+QString::number(err)+") "+tcp->errorString());
|
QMessageBox::critical(this, tr("Tip"), QString(socketErrKey(err))+" ("+QString::number(err)+") "+tcp->errorString());
|
||||||
});
|
});
|
||||||
tcp->connectToHost(card.ip, 3333);
|
tcp->connectToHost(card.ip, 3333);
|
||||||
timer->start(10000);
|
tcp->startTimer(10000);
|
||||||
} else {
|
} else {
|
||||||
foreach(auto card, gSelCards) {
|
foreach(auto card, gSelCards) {
|
||||||
auto tcp = new QTcpSocket();
|
auto tcp = new TcpSocket;
|
||||||
auto timer = new QTimer(tcp);
|
|
||||||
timer->setSingleShot(true);
|
|
||||||
auto cardId = card.id;
|
auto cardId = card.id;
|
||||||
connect(timer, &QTimer::timeout, tcp, [tcp, cardId] {
|
connect(tcp, &QTcpSocket::connected, tcp, [=] {
|
||||||
tcp->abort();
|
tcp->stopTimer();
|
||||||
tcp->deleteLater();
|
tcp->write(JToBytes(json));
|
||||||
gFdResInfo->append(cardId+" "+tr("Clear Program")+" "+tr("Timeout"));
|
tcp->startTimer(10000);
|
||||||
});
|
});
|
||||||
connect(tcp, &QTcpSocket::connected, tcp, [tcp, timer] {
|
connect(tcp, &QTcpSocket::readyRead, tcp, [=] {
|
||||||
timer->stop();
|
tcp->stopTimer();
|
||||||
tcp->write("{\"_type\":\"DelPrograms\",\"_id\":\"DelPrograms\",\"zVer\":\"xixun1\"}");
|
auto resp = tcp->readAll();
|
||||||
timer->start(10000);
|
|
||||||
});
|
|
||||||
connect(tcp, &QTcpSocket::readyRead, tcp, [tcp, timer, cardId] {
|
|
||||||
timer->stop();
|
|
||||||
QByteArray resp = tcp->readAll();
|
|
||||||
tcp->close();
|
tcp->close();
|
||||||
tcp->deleteLater();
|
tcp->deleteLater();
|
||||||
QJsonParseError parseErr;
|
QString error;
|
||||||
QJsonDocument json = QJsonDocument::fromJson(resp, &parseErr);
|
auto json = JFrom(resp, &error);
|
||||||
if(parseErr.error != QJsonParseError::NoError) gFdResInfo->append(cardId+" "+tr("Clear Program")+" "+parseErr.errorString());
|
if(! error.isEmpty()) gFdResInfo->append(cardId+" "+tr("Clear Program")+" "+error);
|
||||||
else if(! json["success"].toBool()) gFdResInfo->append(cardId+" "+tr("Clear Program")+" "+tr("Failed"));
|
else if(! json["success"].toBool()) gFdResInfo->append(cardId+" "+tr("Clear Program")+" "+tr("Failed"));
|
||||||
else gFdResInfo->append(cardId+" "+tr("Clear Program")+" "+tr("Success"));
|
else gFdResInfo->append(cardId+" "+tr("Clear Program")+" "+tr("Success"));
|
||||||
});
|
});
|
||||||
connect(tcp, &QTcpSocket::errorOccurred, tcp, [tcp, timer, cardId](QAbstractSocket::SocketError err) {
|
connect(tcp, &QTcpSocket::errorOccurred, tcp, [=](QAbstractSocket::SocketError err) {
|
||||||
timer->stop();
|
|
||||||
tcp->close();
|
tcp->close();
|
||||||
tcp->deleteLater();
|
tcp->deleteLater();
|
||||||
gFdResInfo->append(cardId+" "+tr("Clear Program")+" "+QMetaEnum::fromType<QAbstractSocket::SocketError>().valueToKey(err)+" ("+QString::number(err)+") "+tcp->errorString());
|
gFdResInfo->append(cardId+" "+tr("Clear Program")+" "+socketErrKey(err)+" ("+QString::number(err)+") "+tcp->errorString());
|
||||||
});
|
});
|
||||||
tcp->connectToHost(card.ip, 3333);
|
tcp->connectToHost(card.ip, 3333);
|
||||||
timer->start(10000);
|
tcp->startTimer(10000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -544,87 +527,70 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
}
|
}
|
||||||
JObj json{{"_type","getPlayerState"},{"_id","getPlayerState"},{"zVer","xixun1"}};
|
JObj json{{"_type","getPlayerState"},{"_id","getPlayerState"},{"zVer","xixun1"}};
|
||||||
if(gSelCards.count() == 1) {
|
if(gSelCards.count() == 1) {
|
||||||
auto waitingDlg = new WaitingDlg(this, tr("Clearing Program")+" ...");
|
auto waitingDlg = new WaitingDlg(this, tr("Getting Player State")+" ...");
|
||||||
waitingDlg->show();
|
waitingDlg->showLater();
|
||||||
auto card = gSelCards[0];
|
auto card = gSelCards[0];
|
||||||
auto tcp = new QTcpSocket();
|
auto tcp = new TcpSocket;
|
||||||
auto timer = new QTimer(tcp);
|
|
||||||
timer->setSingleShot(true);
|
|
||||||
connect(timer, &QTimer::timeout, tcp, [=] {
|
|
||||||
waitingDlg->close();
|
|
||||||
tcp->abort();
|
|
||||||
tcp->deleteLater();
|
|
||||||
QMessageBox::critical(this, tr("Tip"), tr("Clear Program")+" "+tr("Timeout"));
|
|
||||||
});
|
|
||||||
connect(waitingDlg, &WaitingDlg::rejected, tcp, [=] {
|
connect(waitingDlg, &WaitingDlg::rejected, tcp, [=] {
|
||||||
timer->stop();
|
|
||||||
tcp->abort();
|
tcp->abort();
|
||||||
tcp->deleteLater();
|
tcp->deleteLater();
|
||||||
});
|
});
|
||||||
connect(tcp, &QTcpSocket::connected, tcp, [=] {
|
connect(tcp, &QTcpSocket::connected, tcp, [=] {
|
||||||
timer->stop();
|
tcp->stopTimer();
|
||||||
tcp->write(JToBytes(json));
|
tcp->write(JToBytes(json));
|
||||||
timer->start(10000);
|
tcp->startTimer(10000);
|
||||||
});
|
});
|
||||||
connect(tcp, &QTcpSocket::readyRead, tcp, [=] {
|
connect(tcp, &QTcpSocket::readyRead, tcp, [=] {
|
||||||
timer->stop();
|
tcp->stopTimer();
|
||||||
QByteArray resp = tcp->readAll();
|
auto resp = tcp->readAll();
|
||||||
tcp->close();
|
|
||||||
tcp->deleteLater();
|
|
||||||
QJsonParseError parseErr;
|
|
||||||
QJsonDocument json = QJsonDocument::fromJson(resp, &parseErr);
|
|
||||||
if(parseErr.error != QJsonParseError::NoError) {
|
|
||||||
waitingDlg->close();
|
|
||||||
QMessageBox::critical(this, tr("Tip"), parseErr.errorString());
|
|
||||||
} else if(! json["success"].toBool()) {
|
|
||||||
waitingDlg->close();
|
|
||||||
QMessageBox::critical(this, tr("Tip"), tr("Clear Program")+" "+tr("Failed"));
|
|
||||||
} else waitingDlg->success();
|
|
||||||
});
|
|
||||||
connect(tcp, &QTcpSocket::errorOccurred, tcp, [=](QAbstractSocket::SocketError err) {
|
|
||||||
timer->stop();
|
|
||||||
tcp->close();
|
tcp->close();
|
||||||
tcp->deleteLater();
|
tcp->deleteLater();
|
||||||
waitingDlg->close();
|
waitingDlg->close();
|
||||||
QMessageBox::critical(this, tr("Tip"), QString(socketErrKey(err))+" ("+QString::number(err)+") "+tcp->errorString());
|
QString error;
|
||||||
|
auto json = JFrom(resp, &error);
|
||||||
|
if(! error.isEmpty()) {
|
||||||
|
QMessageBox::critical(this, tr("Error"), error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QMessageBox::information(this, tr("Player State"), json["code"].toStr()+". "+json["des_en"].toStr()+"\n"+json["des"].toStr());
|
||||||
|
});
|
||||||
|
connect(tcp, &QTcpSocket::errorOccurred, tcp, [=](QAbstractSocket::SocketError err) {
|
||||||
|
tcp->close();
|
||||||
|
tcp->deleteLater();
|
||||||
|
waitingDlg->close();
|
||||||
|
QMessageBox::critical(this, tr("Error"), QString(socketErrKey(err))+" ("+QString::number(err)+") "+tcp->errorString());
|
||||||
});
|
});
|
||||||
tcp->connectToHost(card.ip, 3333);
|
tcp->connectToHost(card.ip, 3333);
|
||||||
timer->start(10000);
|
tcp->startTimer(10000);
|
||||||
} else {
|
} else {
|
||||||
foreach(auto card, gSelCards) {
|
foreach(auto card, gSelCards) {
|
||||||
auto tcp = new QTcpSocket();
|
auto tcp = new TcpSocket;
|
||||||
auto timer = new QTimer(tcp);
|
|
||||||
timer->setSingleShot(true);
|
|
||||||
auto cardId = card.id;
|
auto cardId = card.id;
|
||||||
connect(timer, &QTimer::timeout, tcp, [tcp, cardId] {
|
connect(tcp, &QTcpSocket::connected, tcp, [=] {
|
||||||
tcp->abort();
|
tcp->stopTimer();
|
||||||
tcp->deleteLater();
|
|
||||||
gFdResInfo->append(cardId+" "+tr("Clear Program")+" "+tr("Timeout"));
|
|
||||||
});
|
|
||||||
connect(tcp, &QTcpSocket::connected, tcp, [tcp, json, timer] {
|
|
||||||
timer->stop();
|
|
||||||
tcp->write(JToBytes(json));
|
tcp->write(JToBytes(json));
|
||||||
timer->start(10000);
|
tcp->startTimer(10000);
|
||||||
});
|
});
|
||||||
connect(tcp, &QTcpSocket::readyRead, tcp, [tcp, timer, cardId] {
|
connect(tcp, &QTcpSocket::readyRead, tcp, [=] {
|
||||||
timer->stop();
|
tcp->stopTimer();
|
||||||
QByteArray resp = tcp->readAll();
|
auto resp = tcp->readAll();
|
||||||
tcp->close();
|
tcp->close();
|
||||||
tcp->deleteLater();
|
tcp->deleteLater();
|
||||||
QJsonParseError parseErr;
|
QString error;
|
||||||
QJsonDocument json = QJsonDocument::fromJson(resp, &parseErr);
|
auto json = JFrom(resp, &error);
|
||||||
if(parseErr.error != QJsonParseError::NoError) gFdResInfo->append(cardId+" "+tr("Clear Program")+" "+parseErr.errorString());
|
if(! error.isEmpty()) {
|
||||||
else if(! json["success"].toBool()) gFdResInfo->append(cardId+" "+tr("Clear Program")+" "+tr("Failed"));
|
gFdResInfo->append(cardId+" "+tr("Get Player State")+" "+error);
|
||||||
else gFdResInfo->append(cardId+" "+tr("Clear Program")+" "+tr("Success"));
|
return;
|
||||||
|
}
|
||||||
|
gFdResInfo->append(cardId+" "+tr("Player State")+" "+json["code"].toStr()+". "+json["des_en"].toStr()+"\n"+json["des"].toStr());
|
||||||
});
|
});
|
||||||
connect(tcp, &QTcpSocket::errorOccurred, tcp, [tcp, timer, cardId](QAbstractSocket::SocketError err) {
|
connect(tcp, &QTcpSocket::errorOccurred, tcp, [=](QAbstractSocket::SocketError err) {
|
||||||
timer->stop();
|
|
||||||
tcp->close();
|
tcp->close();
|
||||||
tcp->deleteLater();
|
tcp->deleteLater();
|
||||||
gFdResInfo->append(cardId+" "+tr("Clear Program")+" "+QMetaEnum::fromType<QAbstractSocket::SocketError>().valueToKey(err)+" ("+QString::number(err)+") "+tcp->errorString());
|
gFdResInfo->append(cardId+" "+tr("Get Player State")+" "+socketErrKey(err)+" ("+QString::number(err)+") "+tcp->errorString());
|
||||||
});
|
});
|
||||||
tcp->connectToHost(card.ip, 3333);
|
tcp->connectToHost(card.ip, 3333);
|
||||||
timer->start(10000);
|
tcp->startTimer(10000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1519,7 +1485,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
});
|
});
|
||||||
connect(tcp, &QTcpSocket::readyRead, tcp, [=] {
|
connect(tcp, &QTcpSocket::readyRead, tcp, [=] {
|
||||||
timer->stop();
|
timer->stop();
|
||||||
QByteArray resp = tcp->readAll();
|
auto resp = tcp->readAll();
|
||||||
tcp->close();
|
tcp->close();
|
||||||
tcp->deleteLater();
|
tcp->deleteLater();
|
||||||
QJsonParseError parseErr;
|
QJsonParseError parseErr;
|
||||||
|
@ -1559,7 +1525,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
});
|
});
|
||||||
connect(tcp, &QTcpSocket::readyRead, tcp, [tcp, timer, cardId] {
|
connect(tcp, &QTcpSocket::readyRead, tcp, [tcp, timer, cardId] {
|
||||||
timer->stop();
|
timer->stop();
|
||||||
QByteArray resp = tcp->readAll();
|
auto resp = tcp->readAll();
|
||||||
tcp->close();
|
tcp->close();
|
||||||
tcp->deleteLater();
|
tcp->deleteLater();
|
||||||
QJsonParseError parseErr;
|
QJsonParseError parseErr;
|
||||||
|
@ -2329,6 +2295,7 @@ void CtrlAdvancedPanel::transUi() {
|
||||||
btnGetLog->setText(tr("Check Log"));
|
btnGetLog->setText(tr("Check Log"));
|
||||||
btnSetBack->setText(tr("Set Wallpaper"));
|
btnSetBack->setText(tr("Set Wallpaper"));
|
||||||
btnClearProg->setText(tr("Clear Program"));
|
btnClearProg->setText(tr("Clear Program"));
|
||||||
|
btnGetPlayerState->setText(tr("Get Player State"));
|
||||||
btnPlayerBackSet->setText(tr("Set player background"));
|
btnPlayerBackSet->setText(tr("Set player background"));
|
||||||
btnPlayerBackClear->setText(tr("Clear player background"));
|
btnPlayerBackClear->setText(tr("Clear player background"));
|
||||||
|
|
||||||
|
@ -2407,7 +2374,7 @@ void PlayerBackSendThread::run() {
|
||||||
req.insert("zVer","xixun1");
|
req.insert("zVer","xixun1");
|
||||||
auto resNum = tcp.write(QJsonDocument(req).toJson(QJsonDocument::Compact));
|
auto resNum = tcp.write(QJsonDocument(req).toJson(QJsonDocument::Compact));
|
||||||
if(resNum == -1 || ! tcp.waitForBytesWritten()) {
|
if(resNum == -1 || ! tcp.waitForBytesWritten()) {
|
||||||
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") when write 'proStart'");
|
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when write 'proStart'");
|
||||||
tcp.close();
|
tcp.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2418,7 +2385,7 @@ void PlayerBackSendThread::run() {
|
||||||
req.insert("zVer","xixun1");
|
req.insert("zVer","xixun1");
|
||||||
resNum = tcp.write(QJsonDocument(req).toJson(QJsonDocument::Compact));
|
resNum = tcp.write(QJsonDocument(req).toJson(QJsonDocument::Compact));
|
||||||
if(resNum == -1 || ! tcp.waitForBytesWritten()) {
|
if(resNum == -1 || ! tcp.waitForBytesWritten()) {
|
||||||
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") when write 'imgFileStart'");
|
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when write 'imgFileStart'");
|
||||||
tcp.close();
|
tcp.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2438,13 +2405,13 @@ void PlayerBackSendThread::run() {
|
||||||
}
|
}
|
||||||
resNum = tcp.write(readed);
|
resNum = tcp.write(readed);
|
||||||
if(resNum == -1) {
|
if(resNum == -1) {
|
||||||
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") when write file: "+file->fileName());
|
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when write file: "+file->fileName());
|
||||||
tcp.close();
|
tcp.close();
|
||||||
file->close();
|
file->close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(! tcp.waitForBytesWritten()) {
|
if(! tcp.waitForBytesWritten()) {
|
||||||
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") when waitForWritten file: "+file->fileName());
|
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when waitForWritten file: "+file->fileName());
|
||||||
tcp.close();
|
tcp.close();
|
||||||
file->close();
|
file->close();
|
||||||
return;
|
return;
|
||||||
|
@ -2458,7 +2425,7 @@ void PlayerBackSendThread::run() {
|
||||||
req.insert("zVer","xixun1");
|
req.insert("zVer","xixun1");
|
||||||
resNum = tcp.write(QJsonDocument(req).toJson(QJsonDocument::Compact));
|
resNum = tcp.write(QJsonDocument(req).toJson(QJsonDocument::Compact));
|
||||||
if(resNum == -1 || ! tcp.waitForBytesWritten()) {
|
if(resNum == -1 || ! tcp.waitForBytesWritten()) {
|
||||||
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") when write 'fileEnd'");
|
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when write 'fileEnd'");
|
||||||
tcp.close();
|
tcp.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2468,18 +2435,18 @@ void PlayerBackSendThread::run() {
|
||||||
req.insert("zVer","xixun1");
|
req.insert("zVer","xixun1");
|
||||||
resNum = tcp.write(QJsonDocument(req).toJson(QJsonDocument::Compact));
|
resNum = tcp.write(QJsonDocument(req).toJson(QJsonDocument::Compact));
|
||||||
if(resNum == -1 || ! tcp.waitForBytesWritten()) {
|
if(resNum == -1 || ! tcp.waitForBytesWritten()) {
|
||||||
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") when write 'proEnd'");
|
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when write 'proEnd'");
|
||||||
tcp.close();
|
tcp.close();
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
if(! tcp.waitForReadyRead()) {
|
if(! tcp.waitForReadyRead()) {
|
||||||
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") when waitForRead 'proEnd'");
|
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when 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())+") when read 'proEnd'");
|
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when read 'proEnd'");
|
||||||
tcp.close();
|
tcp.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -364,7 +364,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
||||||
m_headerItem->setText(Upgrade_ONLINE, tr("Online"));
|
m_headerItem->setText(Upgrade_ONLINE, tr("Online"));
|
||||||
m_headerItem->setText(Upgrade_SCREEN_IP, tr("Screen IP"));
|
m_headerItem->setText(Upgrade_SCREEN_IP, tr("Screen IP"));
|
||||||
m_headerItem->setText(Upgrade_ENCRYPT, tr("Security"));
|
m_headerItem->setText(Upgrade_ENCRYPT, tr("Security"));
|
||||||
m_headerItem->setText(Upgrade_REMARK_NAME, tr("Remark Name"));
|
m_headerItem->setText(Upgrade_REMARK_NAME, tr("Alias"));
|
||||||
m_headerItem->setText(Upgrade_PROGRESS, tr("Progress"));
|
m_headerItem->setText(Upgrade_PROGRESS, tr("Progress"));
|
||||||
m_headerItem->setText(Upgrade_Remark, tr("State"));
|
m_headerItem->setText(Upgrade_Remark, tr("State"));
|
||||||
m_headerItem->setText(Upgrade_XIXUNPLAYER_VERSION, tr("xixunplayer"));
|
m_headerItem->setText(Upgrade_XIXUNPLAYER_VERSION, tr("xixunplayer"));
|
||||||
|
|
|
@ -362,7 +362,7 @@ void DevicePanel::transUi() {
|
||||||
m_headerItem->setText(DeviceTable_ID, tr("Screen ID"));
|
m_headerItem->setText(DeviceTable_ID, tr("Screen ID"));
|
||||||
m_headerItem->setText(DeviceTable_IP, tr("Screen IP"));
|
m_headerItem->setText(DeviceTable_IP, tr("Screen IP"));
|
||||||
m_headerItem->setText(DeviceTable_ScreenSize, tr("Screen Size"));
|
m_headerItem->setText(DeviceTable_ScreenSize, tr("Screen Size"));
|
||||||
m_headerItem->setText(DeviceTable_Remark, tr("Remark Name"));
|
m_headerItem->setText(DeviceTable_Remark, tr("Alias"));
|
||||||
m_headerItem->setText(DeviceTable_Screenshot, tr("readback pic"));
|
m_headerItem->setText(DeviceTable_Screenshot, tr("readback pic"));
|
||||||
m_headerItem->setText(DeviceTable_Brightness, tr("Screen Brightness"));
|
m_headerItem->setText(DeviceTable_Brightness, tr("Screen Brightness"));
|
||||||
m_headerItem->setText(DeviceTable_Power, tr("Power Status"));
|
m_headerItem->setText(DeviceTable_Power, tr("Power Status"));
|
||||||
|
|
|
@ -4,8 +4,7 @@
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
|
||||||
class LedCard {
|
struct LedCard {
|
||||||
public:
|
|
||||||
QString id;
|
QString id;
|
||||||
QString ip;
|
QString ip;
|
||||||
int mWidth{0};
|
int mWidth{0};
|
||||||
|
|
|
@ -16,7 +16,7 @@ Table::Table(std::initializer_list<ColAttr> colAttrs, int rows, QWidget *parent)
|
||||||
noStretch = false;
|
noStretch = false;
|
||||||
} else horizontalHeader()->setSectionResizeMode(i, (QHeaderView::ResizeMode)it->resizeMode);
|
} else horizontalHeader()->setSectionResizeMode(i, (QHeaderView::ResizeMode)it->resizeMode);
|
||||||
}
|
}
|
||||||
mFieldMap.insert(it->field, i++);
|
mFieldMap.emplace(it->field, i++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,9 +31,14 @@ void Table::resizeSec() {
|
||||||
int colCnt = columnCount(), remainWidth = header->width(), stretchWidth = 0, secWidth;
|
int colCnt = columnCount(), remainWidth = header->width(), stretchWidth = 0, secWidth;
|
||||||
QTableWidgetItem *item;
|
QTableWidgetItem *item;
|
||||||
for(int cc=0; cc<colCnt; cc++) if((item = horizontalHeaderItem(cc))) {
|
for(int cc=0; cc<colCnt; cc++) if((item = horizontalHeaderItem(cc))) {
|
||||||
if((secWidth = item->data(0x99).toInt()) > 0) stretchWidth += secWidth;
|
if((secWidth = item->data(0x99).toInt()) > 0) stretchWidth += secWidth;
|
||||||
else remainWidth -= header->sectionSize(cc);
|
else remainWidth -= header->sectionSize(cc);
|
||||||
}
|
}
|
||||||
if(remainWidth<=0 || stretchWidth==0) return;
|
if(remainWidth<=0 || stretchWidth==0) return;
|
||||||
for(int cc=0; cc<colCnt; cc++) if((item = horizontalHeaderItem(cc)) && (secWidth = item->data(0x99).toInt()) > 0) header->resizeSection(cc, secWidth * remainWidth / stretchWidth);
|
for(int cc=0; cc<colCnt; cc++) if((item = horizontalHeaderItem(cc)) && (secWidth = item->data(0x99).toInt()) > 0) header->resizeSection(cc, secWidth * remainWidth / stretchWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Table::updateGeometries() {
|
||||||
|
QTableWidget::updateGeometries();
|
||||||
|
emit updGeos();
|
||||||
|
}
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
#define QGUI_H
|
#define QGUI_H
|
||||||
|
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QStackedLayout>
|
|
||||||
#include <QSplitter>
|
|
||||||
#include <QListWidget>
|
|
||||||
#include <QTableWidget>
|
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QListWidget>
|
||||||
|
#include <QSplitter>
|
||||||
|
#include <QStackedLayout>
|
||||||
|
#include <QTableWidget>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
|
|
||||||
#define MainMust \
|
#define MainMust \
|
||||||
|
@ -155,10 +155,6 @@ public:
|
||||||
Table() {}
|
Table() {}
|
||||||
Table(std::initializer_list<ColAttr> colAttrs, int rows = 0, QWidget *parent = 0);
|
Table(std::initializer_list<ColAttr> colAttrs, int rows = 0, QWidget *parent = 0);
|
||||||
|
|
||||||
inline auto setNoEdit() {
|
|
||||||
setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
inline auto setDefs() {
|
inline auto setDefs() {
|
||||||
setSelectionBehavior(QTableWidget::SelectRows);
|
setSelectionBehavior(QTableWidget::SelectRows);
|
||||||
setEditTriggers(QAbstractItemView::NoEditTriggers);
|
setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||||
|
@ -291,13 +287,15 @@ public:
|
||||||
setCellWidget(row, col, widget);
|
setCellWidget(row, col, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::map<QString, int> mFieldMap;
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
inline void clearRows() {setRowCount(0);}
|
inline void clearRows() {setRowCount(0);}
|
||||||
|
signals:
|
||||||
|
void updGeos();
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
|
void updateGeometries() override;
|
||||||
void resizeSec();
|
void resizeSec();
|
||||||
QMap<QString,int> mFieldMap;
|
|
||||||
bool noStretch{true};
|
bool noStretch{true};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -94,13 +94,23 @@ public:
|
||||||
if(type==Array) return *(JArray*) data;
|
if(type==Array) return *(JArray*) data;
|
||||||
return JArray();
|
return JArray();
|
||||||
}
|
}
|
||||||
|
const JValue operator[](const QString &key) const {
|
||||||
|
return type==Obj ? (*(JObj*) data)[key] : JValue();
|
||||||
|
}
|
||||||
|
const JValue operator[](int i) const {
|
||||||
|
return type==Array ? (*(JArray*) data)[i] : JValue();
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
JValue(const void *) = delete; // avoid implicit conversions from char * to bool
|
JValue(const void *) = delete; // avoid implicit conversions from char * to bool
|
||||||
};
|
};
|
||||||
|
|
||||||
class JParser {
|
class JParser {
|
||||||
public:
|
public:
|
||||||
JParser(QTextStream &in) : in(in) {}
|
JParser(QTextStream &in) : in(in) {
|
||||||
|
#if(QT_VERSION_MAJOR < 6)
|
||||||
|
in.setCodec("UTF-8");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
inline JValue read() {
|
inline JValue read() {
|
||||||
skipSpace();
|
skipSpace();
|
||||||
|
@ -144,7 +154,11 @@ inline JValue JFrom(QIODevice *device, QString *err = 0) {
|
||||||
|
|
||||||
class JOut {
|
class JOut {
|
||||||
public:
|
public:
|
||||||
JOut(QTextStream &out, QString indent = "") : out(out), indent(indent) {}
|
JOut(QTextStream &out, QString indent = "") : out(out), indent(indent) {
|
||||||
|
#if(QT_VERSION_MAJOR < 6)
|
||||||
|
out.setCodec("UTF-8");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void write(const JValue &obj);
|
void write(const JValue &obj);
|
||||||
void writeStr(const QString &str);
|
void writeStr(const QString &str);
|
||||||
|
|
|
@ -71,13 +71,12 @@ bool TcpSocket::connAndExec(int msecs, QEventLoop *loop) {
|
||||||
connect(this, &QTcpSocket::errorOccurred, loop, [loop] {
|
connect(this, &QTcpSocket::errorOccurred, loop, [loop] {
|
||||||
loop->exit(1);
|
loop->exit(1);
|
||||||
});
|
});
|
||||||
if(msecs > 0) {
|
if(timerId) {
|
||||||
connect(this, &TcpSocket::timeout, loop, &QEventLoop::exit);
|
killTimer(timerId);
|
||||||
if(timerId!=0) killTimer(timerId);
|
timerId = 0;
|
||||||
timerId = startTimer(msecs);
|
|
||||||
}
|
}
|
||||||
|
if(msecs > 0) startTimer(msecs);
|
||||||
auto res = loop->exec();
|
auto res = loop->exec();
|
||||||
timerStop();
|
stopTimer();
|
||||||
if(res==5) setSocketError(SocketTimeoutError);
|
|
||||||
return res==0;
|
return res==0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
#include <QTimerEvent>
|
#include <QTimerEvent>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
extern const char *const FormBoundary;
|
extern const char *const FormBoundary;
|
||||||
|
|
||||||
|
@ -101,30 +102,45 @@ const char* socketErrKey(int value);
|
||||||
class TcpSocket : public QTcpSocket {
|
class TcpSocket : public QTcpSocket {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit TcpSocket(QObject *parent = nullptr) : QTcpSocket{parent} {};
|
using QTcpSocket::QTcpSocket;
|
||||||
~TcpSocket() {
|
~TcpSocket() {
|
||||||
if(timerId!=0) killTimer(timerId);
|
if(timerId) killTimer(timerId);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void abort() {
|
||||||
|
stopTimer();
|
||||||
|
QTcpSocket::abort();
|
||||||
|
}
|
||||||
|
void close() override {
|
||||||
|
stopTimer();
|
||||||
|
QTcpSocket::close();
|
||||||
|
}
|
||||||
bool waitForConnected(int msecs = 30000) override;
|
bool waitForConnected(int msecs = 30000) override;
|
||||||
bool waitForDisconnected(int msecs = 30000) override;
|
bool waitForDisconnected(int msecs = 30000) override;
|
||||||
bool waitForBytesWritten(int msecs = 30000) override;
|
bool waitForBytesWritten(int msecs = 30000) override;
|
||||||
bool waitForReadyRead(int msecs = 30000) override;
|
bool waitForReadyRead(int msecs = 30000) override;
|
||||||
protected:
|
void startTimer(int interval, Qt::TimerType timerType = Qt::CoarseTimer) {
|
||||||
void timerEvent(QTimerEvent *e) override {
|
if(timerId) killTimer(timerId);
|
||||||
if(e->timerId()!=timerId) return;
|
timerId = QTcpSocket::startTimer(interval, timerType);
|
||||||
killTimer(timerId);
|
}
|
||||||
timerId = 0;
|
void stopTimer() {
|
||||||
emit timeout(5);
|
|
||||||
};
|
|
||||||
bool connAndExec(int msecs, QEventLoop *loop);
|
|
||||||
inline void timerStop() {
|
|
||||||
if(timerId==0) return;
|
if(timerId==0) return;
|
||||||
killTimer(timerId);
|
killTimer(timerId);
|
||||||
timerId = 0;
|
timerId = 0;
|
||||||
}
|
}
|
||||||
int timerId = 0;
|
int timerId{0};
|
||||||
signals:
|
|
||||||
void timeout(int);
|
protected:
|
||||||
|
void timerEvent(QTimerEvent *e) override {
|
||||||
|
if(e->timerId()!=timerId) QTcpSocket::timerEvent(e);
|
||||||
|
else {
|
||||||
|
abort();
|
||||||
|
setSocketError(SocketTimeoutError);
|
||||||
|
setErrorString(QCoreApplication::translate("QAbstractSocket", "Socket operation timed out"));
|
||||||
|
emit errorOccurred(QAbstractSocket::SocketTimeoutError);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
bool connAndExec(int msecs, QEventLoop *loop);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QNETWORK_H
|
#endif // QNETWORK_H
|
||||||
|
|
|
@ -37,7 +37,7 @@ int main(int argc, char *argv[]) {
|
||||||
QApplication::setOrganizationDomain("www.ledok.cn");
|
QApplication::setOrganizationDomain("www.ledok.cn");
|
||||||
QApplication::setApplicationName("LedOK Express");
|
QApplication::setApplicationName("LedOK Express");
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
a.setStyle(QStyleFactory::create("Fusion"));
|
QApplication::setStyle(QStyleFactory::create("Fusion"));
|
||||||
QFile file(":/css.css");
|
QFile file(":/css.css");
|
||||||
if(file.exists() && file.open(QFile::ReadOnly)) {
|
if(file.exists() && file.open(QFile::ReadOnly)) {
|
||||||
a.setStyleSheet(css = file.readAll());
|
a.setStyleSheet(css = file.readAll());
|
||||||
|
|
|
@ -214,7 +214,7 @@ ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
|
||||||
connect(txtSearch,SIGNAL(textChanged(const QString &)),this,SLOT(FilterProgram(const QString &)));
|
connect(txtSearch,SIGNAL(textChanged(const QString &)),this,SLOT(FilterProgram(const QString &)));
|
||||||
|
|
||||||
mProgTree = new LoQTreeWidget();
|
mProgTree = new LoQTreeWidget();
|
||||||
mProgTree->setIndentation(10);
|
mProgTree->setIndentation(6);
|
||||||
mProgTree->setSortingEnabled(true);
|
mProgTree->setSortingEnabled(true);
|
||||||
m_headerItem = new QTreeWidgetItem();
|
m_headerItem = new QTreeWidgetItem();
|
||||||
for(int i=1; i<ENUM_PROGRAMLISTHEADERITEM_END; i++) m_headerItem->setTextAlignment(i, Qt::AlignCenter);
|
for(int i=1; i<ENUM_PROGRAMLISTHEADERITEM_END; i++) m_headerItem->setTextAlignment(i, Qt::AlignCenter);
|
||||||
|
@ -223,7 +223,7 @@ ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
|
||||||
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_RESOLUTION, Qt::DisplayRole, tr("Resolution"));
|
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_RESOLUTION, Qt::DisplayRole, tr("Resolution"));
|
||||||
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_SIZE, Qt::DisplayRole, tr("File Size"));
|
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_SIZE, Qt::DisplayRole, tr("File Size"));
|
||||||
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_LASTTIME, Qt::DisplayRole, tr("Last Modify"));
|
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_LASTTIME, Qt::DisplayRole, tr("Last Modify"));
|
||||||
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_USB_EXPORT, Qt::DisplayRole, tr("Usb playback"));
|
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_USB_EXPORT, Qt::DisplayRole, tr("USB Update"));
|
||||||
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_SEND, Qt::DisplayRole, tr("Publish"));
|
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_SEND, Qt::DisplayRole, tr("Publish"));
|
||||||
mProgTree->setHeaderItem(m_headerItem);
|
mProgTree->setHeaderItem(m_headerItem);
|
||||||
mProgTree->header()->setSectionResizeMode(ENUM_PROGRAMLISTHEADERITEM_CHECK, QHeaderView::Fixed);
|
mProgTree->header()->setSectionResizeMode(ENUM_PROGRAMLISTHEADERITEM_CHECK, QHeaderView::Fixed);
|
||||||
|
@ -308,7 +308,7 @@ void ProgPanel::transUi() {
|
||||||
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_RESOLUTION, 0, tr("Resolution"));
|
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_RESOLUTION, 0, tr("Resolution"));
|
||||||
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_SIZE, 0, tr("File Size"));
|
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_SIZE, 0, tr("File Size"));
|
||||||
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_LASTTIME, 0, tr("Last Modify"));
|
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_LASTTIME, 0, tr("Last Modify"));
|
||||||
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_USB_EXPORT, 0, tr("Usb playback"));
|
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_USB_EXPORT, 0, tr("USB Update"));
|
||||||
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_SEND, 0, tr("Publish"));
|
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_SEND, 0, tr("Publish"));
|
||||||
bnNew->setText(tr("New"));
|
bnNew->setText(tr("New"));
|
||||||
bnEdit->setText(tr("Edit"));
|
bnEdit->setText(tr("Edit"));
|
||||||
|
@ -317,7 +317,6 @@ void ProgPanel::transUi() {
|
||||||
bnExport->setText(tr("Export"));
|
bnExport->setText(tr("Export"));
|
||||||
bnSend->setText(tr("Send"));
|
bnSend->setText(tr("Send"));
|
||||||
btnPlay->setText(tr("Play")+"/"+tr("Stop"));
|
btnPlay->setText(tr("Play")+"/"+tr("Stop"));
|
||||||
for(int i=0;i<m_pwPorgramItemList.count();i++) m_pwPorgramItemList.at(i)->refreshLable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgPanel::onEditClicked(bool){
|
void ProgPanel::onEditClicked(bool){
|
||||||
|
|
|
@ -74,7 +74,6 @@ QPushButton:hover {
|
||||||
});
|
});
|
||||||
m_bnExport = new QPushButton();
|
m_bnExport = new QPushButton();
|
||||||
m_bnExport->setCursor(QCursor(Qt::PointingHandCursor));
|
m_bnExport->setCursor(QCursor(Qt::PointingHandCursor));
|
||||||
m_bnExport->setToolTip(QObject::tr("ExportButtonTip"));
|
|
||||||
m_bnExport->setStyleSheet(R"rrr(
|
m_bnExport->setStyleSheet(R"rrr(
|
||||||
QPushButton {
|
QPushButton {
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
|
@ -87,7 +86,7 @@ QPushButton:hover{background-color: #cccccc;}
|
||||||
mTree->setItemWidget(this, ENUM_PROGRAMLISTHEADERITEM_USB_EXPORT, m_bnExport);
|
mTree->setItemWidget(this, ENUM_PROGRAMLISTHEADERITEM_USB_EXPORT, m_bnExport);
|
||||||
QObject::connect(m_bnExport, &QPushButton::clicked, mTree, [this] {
|
QObject::connect(m_bnExport, &QPushButton::clicked, mTree, [this] {
|
||||||
QDialog dlg(mTree);
|
QDialog dlg(mTree);
|
||||||
dlg.setWindowTitle(QObject::tr("Usb upgrade program"));
|
dlg.setWindowTitle(QObject::tr("USB Update Program"));
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
dlg.setWindowFlag(Qt::WindowContextHelpButtonHint, 0);
|
dlg.setWindowFlag(Qt::WindowContextHelpButtonHint, 0);
|
||||||
#endif
|
#endif
|
||||||
|
@ -140,7 +139,6 @@ QPushButton:hover{background-color: #cccccc;}
|
||||||
|
|
||||||
m_bnSend = new QPushButton();
|
m_bnSend = new QPushButton();
|
||||||
m_bnSend->setCursor(QCursor(Qt::PointingHandCursor));
|
m_bnSend->setCursor(QCursor(Qt::PointingHandCursor));
|
||||||
m_bnSend->setToolTip(QObject::tr("SendButtonTip"));
|
|
||||||
m_bnSend->setStyleSheet(R"rrr(
|
m_bnSend->setStyleSheet(R"rrr(
|
||||||
QPushButton{
|
QPushButton{
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
|
@ -164,10 +162,6 @@ QPushButton:hover{background-color: #cccccc;}
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void ProgItem::refreshLable() {
|
|
||||||
m_bnExport->setToolTip(QObject::tr("ExportButtonTip"));
|
|
||||||
m_bnSend->setToolTip(QObject::tr("SendButtonTip"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProgItem::save() {
|
void ProgItem::save() {
|
||||||
QDir dRoot(mProgDir);
|
QDir dRoot(mProgDir);
|
||||||
|
|
|
@ -18,7 +18,6 @@ public:
|
||||||
|
|
||||||
void save();
|
void save();
|
||||||
void del();
|
void del();
|
||||||
void refreshLable();
|
|
||||||
|
|
||||||
QString mName;
|
QString mName;
|
||||||
int mWidth;
|
int mWidth;
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
#include "sendprogramdialog.h"
|
#include "sendprogramdialog.h"
|
||||||
#include "cfg.h"
|
#include "cfg.h"
|
||||||
#include "wprogrampublishitem.h"
|
|
||||||
#include "sendprogthread.h"
|
#include "sendprogthread.h"
|
||||||
#include "gutil/qgui.h"
|
#include "deviceitem.h"
|
||||||
|
#include "devicepanel.h"
|
||||||
|
#include "gutil/qnetwork.h"
|
||||||
|
#include "base/waitingdlg.h"
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include "deviceitem.h"
|
#include <QInputDialog>
|
||||||
#include "devicepanel.h"
|
#include <QMessageBox>
|
||||||
|
#include <QProgressBar>
|
||||||
|
|
||||||
SendProgramDialog::SendProgramDialog(QString progName, QWidget *parent) : QDialog(parent), mProgName(progName) {
|
SendProgramDialog::SendProgramDialog(QString progName, QWidget *parent) : QDialog(parent), mProgName(progName) {
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
@ -18,6 +21,7 @@ SendProgramDialog::SendProgramDialog(QString progName, QWidget *parent) : QDialo
|
||||||
resize(1024, 700);
|
resize(1024, 700);
|
||||||
|
|
||||||
auto vBox = new VBox(this);
|
auto vBox = new VBox(this);
|
||||||
|
vBox->setContentsMargins(6,0,6,9);
|
||||||
auto hBox = new HBox(vBox);
|
auto hBox = new HBox(vBox);
|
||||||
|
|
||||||
label = new QLabel(tr("success info"));
|
label = new QLabel(tr("success info"));
|
||||||
|
@ -25,96 +29,107 @@ SendProgramDialog::SendProgramDialog(QString progName, QWidget *parent) : QDialo
|
||||||
|
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
auto pushButtonRefresh = new QPushButton(tr("Refresh"));
|
auto btnRefresh = new QPushButton(tr("Refresh"));
|
||||||
pushButtonRefresh->setProperty("ssType", "progManageTool");
|
btnRefresh->setProperty("ssType", "progManageTool");
|
||||||
connect(pushButtonRefresh, SIGNAL(clicked()),this, SLOT(onRefresh()));
|
connect(btnRefresh, &QPushButton::clicked, this, &SendProgramDialog::refresh);
|
||||||
hBox->addWidget(pushButtonRefresh);
|
hBox->addWidget(btnRefresh);
|
||||||
|
|
||||||
auto txtSearch = new QLineEdit();
|
auto txtSearch = new QLineEdit;
|
||||||
txtSearch->setFixedWidth(150);
|
txtSearch->setFixedWidth(150);
|
||||||
txtSearch->setClearButtonEnabled(true);
|
txtSearch->setClearButtonEnabled(true);
|
||||||
txtSearch->setStyleSheet("QLineEdit{border: 2px solid #aaaaaa; padding: 2px;}");
|
txtSearch->setStyleSheet("QLineEdit{border: 2px solid #aaa; padding: 2px;}");
|
||||||
txtSearch->addAction(new QAction(QIcon(":/res/program/bnSearch.png"), QString()), QLineEdit::LeadingPosition);
|
txtSearch->addAction(new QAction(QIcon(":/res/program/bnSearch.png"), QString()), QLineEdit::LeadingPosition);
|
||||||
connect(txtSearch,SIGNAL(textChanged(const QString &)),this,SLOT(FilterProgram(const QString &)));
|
connect(txtSearch, &QLineEdit::textEdited, this, [=](const QString &text) {
|
||||||
|
auto cnt = table->rowCount();
|
||||||
|
for(int rr=0; rr<cnt; rr++) table->setRowHidden(rr, !(text.isEmpty() || table->text(rr, "id").contains(text) || table->text(rr, "ip").contains(text) || table->text(rr, "alias").contains(text) || table->text(rr, "size").contains(text)));
|
||||||
|
});
|
||||||
hBox->addWidget(txtSearch);
|
hBox->addWidget(txtSearch);
|
||||||
|
|
||||||
|
table = new Table{
|
||||||
|
{"id", "ID", 140},
|
||||||
|
{"online", tr("Online"), 40},
|
||||||
|
{"ip", "IP", 100},
|
||||||
|
{"size", tr("Screen Size"), 80},
|
||||||
|
{"alias", tr("Alias"), 120},
|
||||||
|
{"encrypt", tr("Security"), 40},
|
||||||
|
{"progress", tr("Progress"), 120},
|
||||||
|
{"remarks", tr("Remarks"), QHeaderView::Stretch}
|
||||||
|
};
|
||||||
|
table->setDefs();
|
||||||
|
auto colId = table->mFieldMap["id"];
|
||||||
|
table->sortItems(colId);
|
||||||
|
table->setSelectionMode(Table::NoSelection);
|
||||||
|
table->setStyle(new ViewItemStyle);
|
||||||
|
vBox->addWidget(table);
|
||||||
|
|
||||||
wDevicePublishList = new LoQTreeWidget();
|
fdCheckAll = new QCheckBox(table);
|
||||||
wDevicePublishList->setProperty("ssType", "topList");
|
connect(fdCheckAll, &QCheckBox::stateChanged, this, [=](int state) {
|
||||||
m_headerItem = new QTreeWidgetItem();
|
if(state==Qt::PartiallyChecked) return;
|
||||||
m_headerItem->setTextAlignment(1, Qt::AlignHCenter | Qt::AlignVCenter);
|
int cnt = table->rowCount();
|
||||||
for(int i=1; i<ENUM_DEVICE_PUBLISH_HEADE_END; i++) m_headerItem->setTextAlignment(i, Qt::AlignCenter);
|
for(int i=0; i<cnt; i++) table->itemValid(i, colId)->setCheckState((Qt::CheckState) state);
|
||||||
m_headerItem->setData(ENUM_DEVICE_PUBLISH_HEADE_CHECK, 0, "");
|
});
|
||||||
m_headerItem->setData(ENUM_DEVICE_PUBLISH_HEADE_SCREEN_ID, 0, tr("Screen ID"));
|
connect(table, &Table::updGeos, this, [=] {
|
||||||
m_headerItem->setData(ENUM_DEVICE_PUBLISH_HEADE_ONLINE, 0, tr("Online"));
|
fdCheckAll->move(table->verticalHeader()->size().width() + 8, 2);
|
||||||
m_headerItem->setData(ENUM_DEVICE_PUBLISH_HEADE_SCREEN_IP, 0, tr("Screen IP"));
|
});
|
||||||
m_headerItem->setData(ENUM_DEVICE_PUBLISH_HEADE_SCREEN_SIZE, 0, tr("Screen Size"));
|
auto cellClicked = [=](int row, int column) {
|
||||||
m_headerItem->setData(ENUM_DEVICE_PUBLISH_HEADE_ENCRYPT,0,tr("Security"));
|
if(column!=colId) return;
|
||||||
m_headerItem->setData(ENUM_DEVICE_PUBLISH_HEADE_REMARK_NAME, 0, tr("Remark Name"));
|
auto item = table->itemValid(row, colId);
|
||||||
m_headerItem->setData(ENUM_DEVICE_PUBLISH_HEADE_PROGRESS, 0, tr("Progress"));
|
auto state = item->checkState()==Qt::Checked ? Qt::Unchecked : Qt::Checked;
|
||||||
m_headerItem->setData(ENUM_DEVICE_PUBLISH_HEADE_REMARKS, 0, tr("Remarks"));
|
item->setCheckState(state);
|
||||||
wDevicePublishList->setHeaderItem(m_headerItem);
|
int cnt = table->rowCount();
|
||||||
wDevicePublishList->header()->setSectionResizeMode(ENUM_DEVICE_PUBLISH_HEADE_CHECK, QHeaderView::Fixed);
|
fdCheckAll->blockSignals(true);
|
||||||
wDevicePublishList->header()->setSectionResizeMode(ENUM_DEVICE_PUBLISH_HEADE_ONLINE, QHeaderView::Fixed);
|
for(int i=0; i<cnt; i++) if(table->itemValid(i, colId)->checkState()!=state) {
|
||||||
wDevicePublishList->header()->setSectionResizeMode(ENUM_DEVICE_PUBLISH_HEADE_SCREEN_ID, QHeaderView::Fixed);
|
fdCheckAll->setCheckState(Qt::PartiallyChecked);
|
||||||
wDevicePublishList->header()->setSectionResizeMode(ENUM_DEVICE_PUBLISH_HEADE_SCREEN_IP, QHeaderView::Fixed);
|
goto end;
|
||||||
wDevicePublishList->header()->setSectionResizeMode(ENUM_DEVICE_PUBLISH_HEADE_SCREEN_SIZE, QHeaderView::Fixed);
|
}
|
||||||
wDevicePublishList->header()->setSectionResizeMode(ENUM_DEVICE_PUBLISH_HEADE_ENCRYPT, QHeaderView::Fixed);
|
fdCheckAll->setCheckState(state);
|
||||||
wDevicePublishList->header()->setSectionResizeMode(ENUM_DEVICE_PUBLISH_HEADE_PROGRESS, QHeaderView::Fixed);
|
end:fdCheckAll->blockSignals(false);
|
||||||
wDevicePublishList->header()->setSectionResizeMode(ENUM_DEVICE_PUBLISH_HEADE_REMARK_NAME, QHeaderView::Interactive);
|
};
|
||||||
wDevicePublishList->header()->setSectionResizeMode(ENUM_DEVICE_PUBLISH_HEADE_REMARKS, QHeaderView::Stretch);
|
connect(table, &Table::cellClicked, table, cellClicked);
|
||||||
wDevicePublishList->header()->setStretchLastSection(false);
|
connect(table, &Table::cellEntered, table, cellClicked);
|
||||||
wDevicePublishList->setColumnWidth(ENUM_DEVICE_PUBLISH_HEADE_CHECK, 52);
|
|
||||||
wDevicePublishList->setColumnWidth(ENUM_DEVICE_PUBLISH_HEADE_SCREEN_ID, 130);
|
|
||||||
wDevicePublishList->setColumnWidth(ENUM_DEVICE_PUBLISH_HEADE_SCREEN_IP, 130);
|
|
||||||
wDevicePublishList->setColumnWidth(ENUM_DEVICE_PUBLISH_HEADE_SCREEN_SIZE, 88);
|
|
||||||
wDevicePublishList->setColumnWidth(ENUM_DEVICE_PUBLISH_HEADE_ONLINE, 50);
|
|
||||||
wDevicePublishList->setColumnWidth(ENUM_DEVICE_PUBLISH_HEADE_ENCRYPT, 52);
|
|
||||||
wDevicePublishList->setColumnWidth(ENUM_DEVICE_PUBLISH_HEADE_REMARK_NAME, 160);
|
|
||||||
wDevicePublishList->setColumnWidth(ENUM_DEVICE_PUBLISH_HEADE_PROGRESS, 120);
|
|
||||||
vBox->addWidget(wDevicePublishList);
|
|
||||||
|
|
||||||
|
|
||||||
auto btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
auto btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
btnBox->button(QDialogButtonBox::Ok)->setText(tr("Publish"));
|
btnBox->button(QDialogButtonBox::Ok)->setText(tr("Publish"));
|
||||||
connect(btnBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
connect(btnBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
connect(btnBox, &QDialogButtonBox::accepted, this, [this] {
|
connect(btnBox, &QDialogButtonBox::accepted, this, [=] {
|
||||||
if(mWaitCnt > 0) return;
|
if(mWaitCnt > 0) return;
|
||||||
int cnt = wDevicePublishList->topLevelItemCount();
|
int cnt = table->rowCount();
|
||||||
int sentCnt{0};
|
int sentCnt{0};
|
||||||
for(int i=0; i<cnt; i++) {
|
for(int i=0; i<cnt; i++) {
|
||||||
auto item = wDevicePublishList->topLevelItem(i);
|
auto fdId = table->itemValid(i, colId);
|
||||||
if(item->checkState(0) != Qt::Checked) continue;
|
if(fdId->checkState()!=Qt::Checked) continue;
|
||||||
auto row = static_cast<wProgramPublishItem*>(item);
|
if(fdId->data(isSending).toBool()) continue;
|
||||||
if(row->mIsSending) continue;
|
auto btnUnlock = (QPushButton*) table->cellWidget(i, "encrypt");
|
||||||
if(row->mLedCard.hasPassword && row->mLedCard.isLocked) {
|
auto fdRemarks = table->itemValid(i, "remarks");
|
||||||
row->setData(ENUM_DEVICE_PUBLISH_HEADE_REMARKS, 0, tr("This screen is encrypted"));
|
if(btnUnlock && btnUnlock->property("isLocked").toBool()) {
|
||||||
row->setForeground(ENUM_DEVICE_PUBLISH_HEADE_REMARKS, Qt::red);
|
fdRemarks->setText(tr("This screen is encrypted"));
|
||||||
|
fdRemarks->setForeground(Qt::red);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
row->fdProgress->setValue(0);
|
auto fdProgress = (QProgressBar*) table->cellWidget(i, "progress");
|
||||||
|
fdProgress->setValue(0);
|
||||||
if(sentCnt>=5) {
|
if(sentCnt>=5) {
|
||||||
row->setData(ENUM_DEVICE_PUBLISH_HEADE_REMARKS, 0, " 等待中 ...");
|
fdRemarks->setText(" "+tr("Waiting")+" ...");
|
||||||
row->setForeground(ENUM_DEVICE_PUBLISH_HEADE_REMARKS, Qt::black);
|
fdRemarks->setForeground(Qt::black);
|
||||||
mWaitCnt++;
|
mWaitCnt++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
row->mIsSending = true;
|
fdId->setData(isSending, true);
|
||||||
row->setData(ENUM_DEVICE_PUBLISH_HEADE_REMARKS, 0, "");
|
fdRemarks->setText("");
|
||||||
auto sendProg = new SendProgThread(programsDir()+"/"+mProgName+"_tmp", row->mLedCard.ip, 3333);
|
auto sendProg = new SendProgThread(programsDir()+"/"+mProgName+"_tmp", table->text(i, "ip"), 3333);
|
||||||
connect(sendProg, &SendProgThread::emErr, row, [this, row](QString strTip) {
|
connect(sendProg, &SendProgThread::emErr, fdProgress, [=](QString strTip) {
|
||||||
row->mIsSending = false;
|
fdId->setData(isSending, false);
|
||||||
if(strTip=="OK") {
|
if(strTip=="OK") {
|
||||||
row->setCheckState(0, Qt::Unchecked);
|
fdId->setCheckState(Qt::Unchecked);
|
||||||
row->setData(ENUM_DEVICE_PUBLISH_HEADE_REMARKS, 0, "OK");
|
fdRemarks->setText("OK");
|
||||||
row->setForeground(ENUM_DEVICE_PUBLISH_HEADE_REMARKS, Qt::darkGreen);
|
fdRemarks->setForeground(Qt::darkGreen);
|
||||||
} else {
|
} else {
|
||||||
row->setData(ENUM_DEVICE_PUBLISH_HEADE_REMARKS, 0, strTip);
|
fdRemarks->setText(strTip);
|
||||||
row->setForeground(ENUM_DEVICE_PUBLISH_HEADE_REMARKS, Qt::red);
|
fdRemarks->setForeground(Qt::red);
|
||||||
}
|
}
|
||||||
sendNext();
|
sendNext();
|
||||||
});
|
});
|
||||||
connect(sendProg, &SendProgThread::emProgress, row->fdProgress, &QProgressBar::setValue);
|
connect(sendProg, &SendProgThread::emProgress, fdProgress, &QProgressBar::setValue);
|
||||||
connect(this, &SendProgramDialog::stopAllThd, sendProg, &SendProgThread::stop);
|
connect(this, &SendProgramDialog::stopAllThd, sendProg, &SendProgThread::stop);
|
||||||
sendProg->start();
|
sendProg->start();
|
||||||
sentCnt++;
|
sentCnt++;
|
||||||
|
@ -122,147 +137,133 @@ SendProgramDialog::SendProgramDialog(QString progName, QWidget *parent) : QDialo
|
||||||
});
|
});
|
||||||
vBox->addWidget(btnBox);
|
vBox->addWidget(btnBox);
|
||||||
|
|
||||||
onRefresh();
|
refresh();
|
||||||
|
|
||||||
auto timer = new QTimer(this);
|
auto timer = new QTimer(this);
|
||||||
connect(timer, &QTimer::timeout, this, &SendProgramDialog::onRefresh);
|
connect(timer, &QTimer::timeout, this, &SendProgramDialog::refresh);
|
||||||
timer->start(60000);
|
timer->start(60000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SendProgramDialog::addRow(LedCard card) {
|
||||||
|
int cnt = table->rowCount();
|
||||||
|
for(int rr=0; rr<cnt; rr++) if(table->text(rr, "id") == card.id) {
|
||||||
|
updRow(rr, card);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
table->setSortingEnabled(false);
|
||||||
|
table->setRowCount(cnt+1);
|
||||||
|
|
||||||
|
auto item = table->setText(cnt, "id", card.id);
|
||||||
|
item->setCheckState(Qt::Unchecked);
|
||||||
|
item->setFlags(Qt::ItemIsEnabled);
|
||||||
|
|
||||||
|
auto fdOnline = new QLabel;
|
||||||
|
fdOnline->setAlignment(Qt::AlignCenter);
|
||||||
|
table->setCellWidget(cnt, "online", fdOnline);
|
||||||
|
|
||||||
|
auto fdProgress = new QProgressBar;
|
||||||
|
fdProgress->setAlignment(Qt::AlignCenter);
|
||||||
|
fdProgress->setStyleSheet("QProgressBar {margin-top: 6px; margin-bottom: 6px;}");
|
||||||
|
table->setCellWidget(cnt, "progress", fdProgress);
|
||||||
|
|
||||||
|
updRow(cnt, card);
|
||||||
|
table->setSortingEnabled(true);
|
||||||
|
}
|
||||||
|
void SendProgramDialog::updRow(int row, LedCard card) {
|
||||||
|
table->setText(row, "alias", card.alias);
|
||||||
|
table->setText(row, "ip", card.ip);
|
||||||
|
table->setText(row, "size", QString("%1 x %2").arg(card.mWidth).arg(card.mHeight))->setTextAlignment(Qt::AlignCenter);
|
||||||
|
((QLabel*) table->cellWidget(row, "online"))->setPixmap(QPixmap(card.isOnline ? ":/res/O_Online.png" : ":/res/O_Offline.png"));
|
||||||
|
if(! card.hasPassword) table->setCellWidget(row, "encrypt", 0);
|
||||||
|
else {
|
||||||
|
auto btnUnlock = (QPushButton*) table->cellWidget(row, "encrypt");
|
||||||
|
if(btnUnlock==0) {
|
||||||
|
btnUnlock = new QPushButton;
|
||||||
|
btnUnlock->setMaximumHeight(40);
|
||||||
|
btnUnlock->setProperty("isLocked", card.isLocked);
|
||||||
|
table->setCellWidget(row, "encrypt", btnUnlock);
|
||||||
|
connect(btnUnlock, &QPushButton::clicked, btnUnlock, [=] {
|
||||||
|
if(! btnUnlock->property("isLocked").toBool()) return;
|
||||||
|
bool ok;
|
||||||
|
auto pwd = QInputDialog::getText(this, tr("Input password"), tr("Input password"), QLineEdit::Password, QString(), &ok);
|
||||||
|
if(! ok) return;
|
||||||
|
QJsonObject json;
|
||||||
|
json.insert("_id", "VerifyPassword");
|
||||||
|
json.insert("_type", "VerifyPassword");
|
||||||
|
json.insert("pwd", pwd);
|
||||||
|
auto waitingDlg = new WaitingDlg(this, tr("VerifyPassword")+" ...");
|
||||||
|
waitingDlg->show();
|
||||||
|
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(60000).post(json);
|
||||||
|
waitingDlg->connAbort(reply);
|
||||||
|
connect(reply, &QNetworkReply::finished, btnUnlock, [=] {
|
||||||
|
QJsonDocument json;
|
||||||
|
QString err = checkReplyForJson(reply, &json);
|
||||||
|
if(! err.isEmpty()) {
|
||||||
|
waitingDlg->close();
|
||||||
|
QMessageBox::critical(this, QObject::tr("Error"), err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(! json["result"].toBool()) {
|
||||||
|
waitingDlg->close();
|
||||||
|
QMessageBox::warning(this, tr("Tip Info"), tr("password is wrong"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
waitingDlg->success();
|
||||||
|
btnUnlock->setProperty("isLocked", false);
|
||||||
|
btnUnlock->setIcon(QIcon(":/res/UnLock.png"));
|
||||||
|
auto item = findItem(card.id);
|
||||||
|
if(item) {
|
||||||
|
item->mCard.isLocked = false;
|
||||||
|
item->btnUnlock->setIcon(QIcon(":/res/UnLock.png"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
btnUnlock->setIcon(QIcon(card.isLocked ? ":/res/Lock.png" : ":/res/UnLock.png")); //已验证显示绿色 没验证蓝色
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SendProgramDialog::closeEvent(QCloseEvent *) {
|
void SendProgramDialog::closeEvent(QCloseEvent *) {
|
||||||
emit stopAllThd();
|
emit stopAllThd();
|
||||||
}
|
}
|
||||||
void SendProgramDialog::sendNext() {
|
void SendProgramDialog::sendNext() {
|
||||||
if(mWaitCnt <= 0) return;
|
if(mWaitCnt <= 0) return;
|
||||||
int cnt = wDevicePublishList->topLevelItemCount();
|
int cnt = table->rowCount();
|
||||||
for(int i=0; i<cnt; i++) {
|
for(int i=0; i<cnt; i++) {
|
||||||
auto item = wDevicePublishList->topLevelItem(i);
|
auto fdId = table->itemValid(i, "id");
|
||||||
if(item->checkState(0) != Qt::Checked) continue;
|
if(fdId->checkState()!=Qt::Checked) continue;
|
||||||
auto row = static_cast<wProgramPublishItem*>(item);
|
if(fdId->data(isSending).toBool()) continue;
|
||||||
if(row->mIsSending) continue;
|
auto btnUnlock = (QPushButton*) table->cellWidget(i, "encrypt");
|
||||||
if(row->mLedCard.hasPassword && row->mLedCard.isLocked) continue;
|
if(btnUnlock && btnUnlock->property("isLocked").toBool()) continue;
|
||||||
if(! row->data(ENUM_DEVICE_PUBLISH_HEADE_REMARKS, 0).toString().startsWith(" ")) continue;
|
auto fdRemarks = table->itemValid(i, "remarks");
|
||||||
row->setData(ENUM_DEVICE_PUBLISH_HEADE_REMARKS, 0, "");
|
if(! fdRemarks->text().startsWith(" ")) continue;
|
||||||
row->fdProgress->setValue(0);
|
fdRemarks->setText("");
|
||||||
row->mIsSending = true;
|
auto fdProgress = (QProgressBar*) table->cellWidget(i, "progress");
|
||||||
|
fdProgress->setValue(0);
|
||||||
|
fdId->setData(isSending, true);
|
||||||
mWaitCnt--;
|
mWaitCnt--;
|
||||||
auto sendProg = new SendProgThread(programsDir()+"/"+mProgName+"_tmp", row->mLedCard.ip, 3333);
|
auto sendProg = new SendProgThread(programsDir()+"/"+mProgName+"_tmp", table->text(i, "ip"), 3333);
|
||||||
connect(sendProg, &SendProgThread::emErr, row, [this, row](QString strTip) {
|
connect(sendProg, &SendProgThread::emErr, fdProgress, [=](QString strTip) {
|
||||||
row->mIsSending = false;
|
fdId->setData(isSending, false);
|
||||||
if(strTip=="OK") {
|
if(strTip=="OK") {
|
||||||
row->setCheckState(0, Qt::Unchecked);
|
fdId->setCheckState(Qt::Unchecked);
|
||||||
row->setData(ENUM_DEVICE_PUBLISH_HEADE_REMARKS, 0, "OK");
|
fdRemarks->setText("OK");
|
||||||
row->setForeground(ENUM_DEVICE_PUBLISH_HEADE_REMARKS, Qt::darkGreen);
|
fdRemarks->setForeground(Qt::darkGreen);
|
||||||
} else {
|
} else {
|
||||||
row->setData(ENUM_DEVICE_PUBLISH_HEADE_REMARKS, 0, strTip);
|
fdRemarks->setText(strTip);
|
||||||
row->setForeground(ENUM_DEVICE_PUBLISH_HEADE_REMARKS, Qt::red);
|
fdRemarks->setForeground(Qt::red);
|
||||||
}
|
}
|
||||||
sendNext();
|
sendNext();
|
||||||
});
|
});
|
||||||
connect(sendProg, &SendProgThread::emProgress, row->fdProgress, &QProgressBar::setValue);
|
connect(sendProg, &SendProgThread::emProgress, fdProgress, &QProgressBar::setValue);
|
||||||
connect(this, &SendProgramDialog::stopAllThd, sendProg, &SendProgThread::stop);
|
connect(this, &SendProgramDialog::stopAllThd, sendProg, &SendProgThread::stop);
|
||||||
sendProg->start();
|
sendProg->start();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendProgramDialog::onRefresh() {
|
void SendProgramDialog::refresh() {
|
||||||
int cnt = gDevicePanel->mDeviceTable->topLevelItemCount();
|
int cnt = gDevicePanel->mDeviceTable->topLevelItemCount();
|
||||||
for(int i=0; i<cnt; i++) onAddLedCard(static_cast<DeviceItem*>(gDevicePanel->mDeviceTable->topLevelItem(i))->mCard);
|
for(int i=0; i<cnt; i++) addRow(static_cast<DeviceItem*>(gDevicePanel->mDeviceTable->topLevelItem(i))->mCard);
|
||||||
label->setText(tr("All")+":"+QString::number(cnt));
|
label->setText(tr("All")+": "+QString::number(cnt));
|
||||||
}
|
|
||||||
void SendProgramDialog::onAddLedCard(LedCard p) {
|
|
||||||
int iExistFlg=0;
|
|
||||||
int cnt = wDevicePublishList->topLevelItemCount();
|
|
||||||
for(int i=0; i<cnt; i++) {
|
|
||||||
QString strTempCardId=static_cast<wProgramPublishItem*>(wDevicePublishList->topLevelItem(i))->mLedCard.id;
|
|
||||||
if(strTempCardId == p.id) {
|
|
||||||
iExistFlg=1;
|
|
||||||
static_cast<wProgramPublishItem*>(wDevicePublishList->topLevelItem(i))->SetItemParam(p);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(iExistFlg==0) new wProgramPublishItem(p, wDevicePublishList, mProgName, programsDir());
|
|
||||||
}
|
|
||||||
void SendProgramDialog::FilterProgram(const QString &strtemp)
|
|
||||||
{
|
|
||||||
if (strtemp.isEmpty()) //显示全部
|
|
||||||
{
|
|
||||||
for (int i = 0; i< wDevicePublishList->topLevelItemCount(); ++i)
|
|
||||||
{
|
|
||||||
QTreeWidgetItem* topItem = wDevicePublishList->topLevelItem(i);
|
|
||||||
wDevicePublishList->setRowHidden(i,wDevicePublishList->indexFromItem(topItem->parent()),false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
QList<QTreeWidgetItem*> resultList = wDevicePublishList->findItems(strtemp, Qt::MatchContains,ENUM_DEVICE_PUBLISH_HEADE_SCREEN_ID); //搜索结果
|
|
||||||
if (resultList.size() > 0)
|
|
||||||
{
|
|
||||||
//QMessageBox::warning(this, "Export", QString(resultList.size()));
|
|
||||||
for (int i = 0; i< wDevicePublishList->topLevelItemCount(); ++i)
|
|
||||||
{
|
|
||||||
QTreeWidgetItem* topItem = wDevicePublishList->topLevelItem(i);
|
|
||||||
if (resultList.contains(topItem))
|
|
||||||
wDevicePublishList->setRowHidden(i,wDevicePublishList->indexFromItem(topItem->parent()),false); //显示匹配的结果
|
|
||||||
else
|
|
||||||
wDevicePublishList->setRowHidden(i,wDevicePublishList->indexFromItem(topItem->parent()),true); //隐藏不匹配的结果
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
QList<QTreeWidgetItem*> resultList6 = wDevicePublishList->findItems(strtemp, Qt::MatchContains,ENUM_DEVICE_PUBLISH_HEADE_REMARK_NAME); //搜索结果
|
|
||||||
if (resultList6.size() > 0)
|
|
||||||
{
|
|
||||||
//QMessageBox::warning(this, "Export", QString(resultList.size()));
|
|
||||||
for (int i = 0; i< wDevicePublishList->topLevelItemCount(); ++i)
|
|
||||||
{
|
|
||||||
QTreeWidgetItem* topItem = wDevicePublishList->topLevelItem(i);
|
|
||||||
if (resultList6.contains(topItem))
|
|
||||||
wDevicePublishList->setRowHidden(i,wDevicePublishList->indexFromItem(topItem->parent()),false); //显示匹配的结果
|
|
||||||
else
|
|
||||||
wDevicePublishList->setRowHidden(i,wDevicePublishList->indexFromItem(topItem->parent()),true); //隐藏不匹配的结果
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
|
|
||||||
//QMessageBox::warning(this, "Export", "FilterProgram");
|
|
||||||
QList<QTreeWidgetItem*> resultList1 = wDevicePublishList->findItems(strtemp, Qt::MatchContains,ENUM_DEVICE_PUBLISH_HEADE_SCREEN_SIZE); //搜索结果
|
|
||||||
if (resultList1.size() > 0)
|
|
||||||
{
|
|
||||||
//QMessageBox::warning(this, "Export", QString(resultList.size()));
|
|
||||||
for (int i = 0; i< wDevicePublishList->topLevelItemCount(); ++i)
|
|
||||||
{
|
|
||||||
QTreeWidgetItem* topItem = wDevicePublishList->topLevelItem(i);
|
|
||||||
if (resultList1.contains(topItem))
|
|
||||||
wDevicePublishList->setRowHidden(i,wDevicePublishList->indexFromItem(topItem->parent()),false); //显示匹配的结果
|
|
||||||
else
|
|
||||||
wDevicePublishList->setRowHidden(i,wDevicePublishList->indexFromItem(topItem->parent()),true); //隐藏不匹配的结果
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
QList<QTreeWidgetItem*> resultList2 = wDevicePublishList->findItems(strtemp, Qt::MatchContains,ENUM_DEVICE_PUBLISH_HEADE_SCREEN_IP); //搜索结果
|
|
||||||
if (resultList2.size() > 0)
|
|
||||||
{
|
|
||||||
//QMessageBox::warning(this, "Export", QString(resultList.size()));
|
|
||||||
for (int i = 0; i< wDevicePublishList->topLevelItemCount(); ++i)
|
|
||||||
{
|
|
||||||
QTreeWidgetItem* topItem = wDevicePublishList->topLevelItem(i);
|
|
||||||
if (resultList2.contains(topItem))
|
|
||||||
wDevicePublishList->setRowHidden(i,wDevicePublishList->indexFromItem(topItem->parent()),false); //显示匹配的结果
|
|
||||||
else
|
|
||||||
wDevicePublishList->setRowHidden(i,wDevicePublishList->indexFromItem(topItem->parent()),true); //隐藏不匹配的结果
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
for (int i = 0; i< wDevicePublishList->topLevelItemCount(); ++i)
|
|
||||||
{
|
|
||||||
QTreeWidgetItem* topItem = wDevicePublishList->topLevelItem(i);
|
|
||||||
wDevicePublishList->setRowHidden(i,wDevicePublishList->indexFromItem(topItem->parent()),true); //隐藏不匹配的结果
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,33 +1,51 @@
|
||||||
#ifndef SENDPROGRAMDIALOG_H
|
#ifndef SENDPROGRAMDIALOG_H
|
||||||
#define SENDPROGRAMDIALOG_H
|
#define SENDPROGRAMDIALOG_H
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include <QLabel>
|
|
||||||
#include "base/loqtreewidget.h"
|
|
||||||
#include "globaldefine.h"
|
#include "globaldefine.h"
|
||||||
|
#include "gutil/qgui.h"
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QProxyStyle>
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
class SendProgramDialog : public QDialog {
|
class SendProgramDialog : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit SendProgramDialog(QString, QWidget *parent = nullptr);
|
explicit SendProgramDialog(QString, QWidget *parent = nullptr);
|
||||||
protected:
|
|
||||||
void closeEvent(QCloseEvent *event) override;
|
|
||||||
signals:
|
signals:
|
||||||
void stopAllThd();
|
void stopAllThd();
|
||||||
protected slots:
|
protected slots:
|
||||||
void onRefresh();
|
void refresh();
|
||||||
void FilterProgram(const QString &strtemp);
|
protected:
|
||||||
private:
|
void closeEvent(QCloseEvent *event) override;
|
||||||
void sendNext();
|
void sendNext();
|
||||||
void onAddLedCard(LedCard);
|
void addRow(LedCard);
|
||||||
|
void updRow(int, LedCard);
|
||||||
|
|
||||||
LoQTreeWidget *wDevicePublishList;
|
Table *table;
|
||||||
|
QCheckBox *fdCheckAll;
|
||||||
int mWaitCnt{0};
|
int mWaitCnt{0};
|
||||||
QLabel *label;
|
QLabel *label;
|
||||||
|
|
||||||
QTreeWidgetItem *m_headerItem = nullptr;
|
|
||||||
QString mProgName;
|
QString mProgName;
|
||||||
QString m_strUrl;
|
QString m_strUrl;
|
||||||
|
|
||||||
|
enum {isSending = Qt::UserRole};
|
||||||
|
};
|
||||||
|
|
||||||
|
class ViewItemStyle : public QProxyStyle {
|
||||||
|
public:
|
||||||
|
ViewItemStyle() : QProxyStyle(QApplication::style()) {}
|
||||||
|
QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const override {
|
||||||
|
auto res = QProxyStyle::subElementRect(element, option, widget);
|
||||||
|
if(option && option->type==QStyleOption::SO_ViewItem && ((QStyleOptionViewItem*)option)->features & QStyleOptionViewItem::HasCheckIndicator && ((QStyleOptionViewItem*)option)->index.internalId()==0) res.setLeft(res.x() + 6);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
int pixelMetric(QStyle::PixelMetric metric, const QStyleOption *option, const QWidget *widget) const override {
|
||||||
|
auto res = QProxyStyle::pixelMetric(metric, option, widget);
|
||||||
|
if(metric==PM_FocusFrameHMargin && option && option->type==QStyleOption::SO_ViewItem && ((QStyleOptionViewItem*)option)->features & QStyleOptionViewItem::HasCheckIndicator) res += 4;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SENDPROGRAMDIALOG_H
|
#endif // SENDPROGRAMDIALOG_H
|
||||||
|
|
|
@ -22,7 +22,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())+") when waitForConnected");
|
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when waitForConnected");
|
||||||
tcp.close();
|
tcp.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -45,18 +45,18 @@ void SendProgThread::run() {
|
||||||
auto requ = QJsonDocument(req).toJson(QJsonDocument::Compact);
|
auto requ = QJsonDocument(req).toJson(QJsonDocument::Compact);
|
||||||
auto resNum = tcp.write(requ);
|
auto resNum = tcp.write(requ);
|
||||||
if(resNum == -1 || ! tcp.waitForBytesWritten()) {
|
if(resNum == -1 || ! tcp.waitForBytesWritten()) {
|
||||||
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") when write 'consult'. size"+QString::number(requ.size()));
|
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when write 'consult'. size"+QString::number(requ.size()));
|
||||||
tcp.close();
|
tcp.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(! tcp.waitForReadyRead()) {
|
if(! tcp.waitForReadyRead()) {
|
||||||
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") when waitForRead 'consult'. size"+QString::number(requ.size()));
|
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()) {
|
if(resp.isEmpty()) {
|
||||||
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") when read 'consult'. size"+QString::number(requ.size()));
|
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when read 'consult'. size"+QString::number(requ.size()));
|
||||||
tcp.close();
|
tcp.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -68,13 +68,13 @@ void SendProgThread::run() {
|
||||||
QJsonDocument res = QJsonDocument::fromJson(resp, &parseErr);
|
QJsonDocument res = QJsonDocument::fromJson(resp, &parseErr);
|
||||||
for(int i=2; parseErr.error == QJsonParseError::UnterminatedString && i < 10; i++) {
|
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())+") when waitForRead 'consult' "+QString::number(i));
|
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when waitForRead 'consult' "+QString::number(i));
|
||||||
tcp.close();
|
tcp.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto resp2 = tcp.readAll();
|
auto resp2 = tcp.readAll();
|
||||||
if(resp2.isEmpty()) {
|
if(resp2.isEmpty()) {
|
||||||
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") when read 'consult' "+QString::number(i));
|
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when read 'consult' "+QString::number(i));
|
||||||
tcp.close();
|
tcp.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ void SendProgThread::run() {
|
||||||
req.insert("zVer","xixun1");
|
req.insert("zVer","xixun1");
|
||||||
auto resNum = tcp.write(QJsonDocument(req).toJson(QJsonDocument::Compact));
|
auto resNum = tcp.write(QJsonDocument(req).toJson(QJsonDocument::Compact));
|
||||||
if(resNum == -1 || ! tcp.waitForBytesWritten()) {
|
if(resNum == -1 || ! tcp.waitForBytesWritten()) {
|
||||||
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") when write 'proStart'");
|
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when write 'proStart'");
|
||||||
tcp.close();
|
tcp.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ void SendProgThread::run() {
|
||||||
req.insert("zVer","xixun1");
|
req.insert("zVer","xixun1");
|
||||||
auto resNum = tcp.write(QJsonDocument(req).toJson(QJsonDocument::Compact));
|
auto resNum = tcp.write(QJsonDocument(req).toJson(QJsonDocument::Compact));
|
||||||
if(resNum == -1 || ! tcp.waitForBytesWritten()) {
|
if(resNum == -1 || ! tcp.waitForBytesWritten()) {
|
||||||
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") when write 'fileStart'");
|
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when write 'fileStart'");
|
||||||
tcp.close();
|
tcp.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -157,13 +157,13 @@ void SendProgThread::run() {
|
||||||
};
|
};
|
||||||
resNum = tcp.write(readed);
|
resNum = tcp.write(readed);
|
||||||
if(resNum == -1) {
|
if(resNum == -1) {
|
||||||
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") when write file: "+file->fileName());
|
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when write file: "+file->fileName());
|
||||||
tcp.close();
|
tcp.close();
|
||||||
file->close();
|
file->close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(! tcp.waitForBytesWritten(60000)) {
|
if(! tcp.waitForBytesWritten(60000)) {
|
||||||
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") when waitForWritten file: "+file->fileName());
|
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when waitForWritten file: "+file->fileName());
|
||||||
tcp.close();
|
tcp.close();
|
||||||
file->close();
|
file->close();
|
||||||
return;
|
return;
|
||||||
|
@ -188,7 +188,7 @@ void SendProgThread::run() {
|
||||||
req.insert("zVer", "xixun1");
|
req.insert("zVer", "xixun1");
|
||||||
resNum = tcp.write(QJsonDocument(req).toJson(QJsonDocument::Compact));
|
resNum = tcp.write(QJsonDocument(req).toJson(QJsonDocument::Compact));
|
||||||
if(resNum == -1 || ! tcp.waitForBytesWritten()) {
|
if(resNum == -1 || ! tcp.waitForBytesWritten()) {
|
||||||
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") when write 'fileEnd'");
|
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when write 'fileEnd'");
|
||||||
tcp.close();
|
tcp.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -204,18 +204,18 @@ void SendProgThread::run() {
|
||||||
req.insert("zVer","xixun1");
|
req.insert("zVer","xixun1");
|
||||||
resNum = tcp.write(QJsonDocument(req).toJson(QJsonDocument::Compact));
|
resNum = tcp.write(QJsonDocument(req).toJson(QJsonDocument::Compact));
|
||||||
if(resNum == -1 || ! tcp.waitForBytesWritten()) {
|
if(resNum == -1 || ! tcp.waitForBytesWritten()) {
|
||||||
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") when write 'proEnd'");
|
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when write 'proEnd'");
|
||||||
tcp.close();
|
tcp.close();
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
if(! tcp.waitForReadyRead()) {
|
if(! tcp.waitForReadyRead()) {
|
||||||
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") when waitForRead 'proEnd'");
|
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when 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())+") when read 'proEnd'");
|
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when read 'proEnd'");
|
||||||
tcp.close();
|
tcp.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,89 +0,0 @@
|
||||||
#include "wprogrampublishitem.h"
|
|
||||||
#include "gutil/qgui.h"
|
|
||||||
#include "base/waitingdlg.h"
|
|
||||||
#include "gutil/qnetwork.h"
|
|
||||||
#include "deviceitem.h"
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QJsonObject>
|
|
||||||
#include <QJsonDocument>
|
|
||||||
#include <QProgressBar>
|
|
||||||
#include "globaldefine.h"
|
|
||||||
#include <QInputDialog>
|
|
||||||
#include <QMetaEnum>
|
|
||||||
|
|
||||||
wProgramPublishItem::wProgramPublishItem(LedCard pLedCard, LoQTreeWidget *parent, QString strProgramName, QString strProgramPath) : QObject(parent), QTreeWidgetItem(UserType), m_parent(parent) {
|
|
||||||
m_strProgramName = strProgramName;
|
|
||||||
m_strProgramPath = strProgramPath;
|
|
||||||
mLedCard = pLedCard;
|
|
||||||
|
|
||||||
setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
|
|
||||||
setCheckState(0, Qt::Unchecked);
|
|
||||||
m_parent->addTopLevelItem(this);
|
|
||||||
m_ImageOnline = new QLabel();
|
|
||||||
m_ImageOnline->setAlignment(Qt::AlignCenter);
|
|
||||||
m_parent->setItemWidget(this, ENUM_DEVICE_PUBLISH_HEADE_ONLINE, m_ImageOnline);
|
|
||||||
for(int i=1; i<ENUM_DEVICE_PUBLISH_HEADE_REMARKS; i++) setTextAlignment(i, Qt::AlignCenter);
|
|
||||||
fdProgress = new QProgressBar();
|
|
||||||
fdProgress->setStyleSheet("margin-top: 8px; margin-bottom: 8px;");
|
|
||||||
m_parent->setItemWidget(this, ENUM_DEVICE_PUBLISH_HEADE_PROGRESS, fdProgress);
|
|
||||||
fdProgress->setAlignment(Qt::AlignCenter);
|
|
||||||
|
|
||||||
btnUnlock = new QPushButton;
|
|
||||||
btnUnlock->setMaximumHeight(40);
|
|
||||||
auto wgt = new QWidget;
|
|
||||||
auto vBox = new VBox(wgt);
|
|
||||||
vBox->setContentsMargins(0,0,0,0);
|
|
||||||
vBox->addWidget(btnUnlock);
|
|
||||||
m_parent->setItemWidget(this, ENUM_DEVICE_PUBLISH_HEADE_ENCRYPT, wgt);
|
|
||||||
connect(btnUnlock, &QPushButton::clicked, this, [this] {
|
|
||||||
if(! mLedCard.isLocked) return;
|
|
||||||
bool ok;
|
|
||||||
auto pwd = QInputDialog::getText(treeWidget(), tr("Input password"), tr("Input password"), QLineEdit::Password, QString(), &ok);
|
|
||||||
if(! ok) return;
|
|
||||||
QJsonObject json;
|
|
||||||
json.insert("_id", "VerifyPassword");
|
|
||||||
json.insert("_type", "VerifyPassword");
|
|
||||||
json.insert("pwd", pwd);
|
|
||||||
auto waitingDlg = new WaitingDlg(treeWidget(), tr("VerifyPassword")+" ...");
|
|
||||||
waitingDlg->show();
|
|
||||||
auto reply = NetReq("http://"+mLedCard.ip+":2016/settings").timeout(60000).post(json);
|
|
||||||
waitingDlg->connAbort(reply);
|
|
||||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
|
||||||
QJsonDocument json;
|
|
||||||
QString err = checkReplyForJson(reply, &json);
|
|
||||||
if(! err.isEmpty()) {
|
|
||||||
waitingDlg->close();
|
|
||||||
QMessageBox::critical(m_parent, QObject::tr("Error"), err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(! json["result"].toBool()) {
|
|
||||||
waitingDlg->close();
|
|
||||||
QMessageBox::warning(treeWidget(), tr("Tip Info"), tr("password is wrong"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
waitingDlg->success();
|
|
||||||
mLedCard.isLocked = false;
|
|
||||||
btnUnlock->setIcon(QIcon(":/res/UnLock.png"));
|
|
||||||
auto item = findItem(mLedCard.id);
|
|
||||||
if(item) {
|
|
||||||
item->mCard.isLocked = false;
|
|
||||||
item->btnUnlock->setIcon(QIcon(":/res/UnLock.png"));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
SetItemParam(mLedCard);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wProgramPublishItem::SetItemParam(LedCard card) {
|
|
||||||
setData(ENUM_DEVICE_PUBLISH_HEADE_SCREEN_ID, 0, card.id);
|
|
||||||
setData(ENUM_DEVICE_PUBLISH_HEADE_REMARK_NAME, 0, card.alias);
|
|
||||||
setData(ENUM_DEVICE_PUBLISH_HEADE_SCREEN_IP, 0, card.ip);
|
|
||||||
setData(ENUM_DEVICE_PUBLISH_HEADE_SCREEN_SIZE, 0, QString("%1 x %2").arg(card.mWidth).arg(card.mHeight));
|
|
||||||
m_ImageOnline->setPixmap(QPixmap(mLedCard.isOnline ? ":/res/O_Online.png" : ":/res/O_Offline.png"));
|
|
||||||
if(! card.hasPassword) btnUnlock->hide();
|
|
||||||
else {
|
|
||||||
if(! btnUnlock->isVisible()) btnUnlock->show();
|
|
||||||
btnUnlock->setIcon(QIcon(card.isLocked ? ":/res/Lock.png" : ":/res/UnLock.png")); //如果已经验证通过密码显示绿色图标 没有验证显示蓝色锁图标
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
#ifndef WPROGRAMPUBLISHITEM_H
|
|
||||||
#define WPROGRAMPUBLISHITEM_H
|
|
||||||
|
|
||||||
#include <QDateTime>
|
|
||||||
#include <QDir>
|
|
||||||
#include <QJsonDocument>
|
|
||||||
#include <QJsonObject>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QProgressBar>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include "base/loqtreewidget.h"
|
|
||||||
#include "globaldefine.h"
|
|
||||||
|
|
||||||
class wProgramPublishItem : public QObject, public QTreeWidgetItem {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit wProgramPublishItem(LedCard pLedCard, LoQTreeWidget *parent = nullptr, QString strProgramName="",QString strProgramPath="");
|
|
||||||
void SetItemParam(LedCard p);
|
|
||||||
|
|
||||||
LedCard mLedCard;
|
|
||||||
QProgressBar *fdProgress{nullptr};
|
|
||||||
bool mIsSending{false};
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString m_strProgramName="";
|
|
||||||
QString m_strProgramPath="";
|
|
||||||
QLabel *m_ImageOnline=nullptr;
|
|
||||||
LoQTreeWidget *m_parent = nullptr;
|
|
||||||
QPushButton *btnUnlock = nullptr;//
|
|
||||||
|
|
||||||
};
|
|
||||||
enum ENUM_DEVICE_PUBLISH_HEADERITEM {
|
|
||||||
ENUM_DEVICE_PUBLISH_HEADE_CHECK=0,
|
|
||||||
ENUM_DEVICE_PUBLISH_HEADE_SCREEN_ID,
|
|
||||||
ENUM_DEVICE_PUBLISH_HEADE_ONLINE,
|
|
||||||
ENUM_DEVICE_PUBLISH_HEADE_SCREEN_IP,
|
|
||||||
ENUM_DEVICE_PUBLISH_HEADE_SCREEN_SIZE,
|
|
||||||
ENUM_DEVICE_PUBLISH_HEADE_ENCRYPT,
|
|
||||||
ENUM_DEVICE_PUBLISH_HEADE_REMARK_NAME,
|
|
||||||
ENUM_DEVICE_PUBLISH_HEADE_PROGRESS,
|
|
||||||
ENUM_DEVICE_PUBLISH_HEADE_REMARKS,
|
|
||||||
ENUM_DEVICE_PUBLISH_HEADE_END,
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // WPROGRAMPUBLISHITEM_H
|
|
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
Loading…
Reference in New Issue
Block a user