2022-01-04 18:11:48 +08:00
|
|
|
|
#include "wprogrampublishitem.h"
|
2023-05-11 11:47:00 +08:00
|
|
|
|
#include "gutil/qgui.h"
|
|
|
|
|
#include "base/waitingdlg.h"
|
2022-01-04 18:11:48 +08:00
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QJsonObject>
|
|
|
|
|
#include <QJsonDocument>
|
|
|
|
|
#include <QProgressBar>
|
2023-05-11 11:47:00 +08:00
|
|
|
|
#include "globaldefine.h"
|
2022-08-25 18:37:24 +08:00
|
|
|
|
#include <QInputDialog>
|
|
|
|
|
#include <QMetaEnum>
|
2023-05-11 11:47:00 +08:00
|
|
|
|
|
|
|
|
|
wProgramPublishItem::wProgramPublishItem(LedCard *pLedCard, LoQTreeWidget *parent, QString strProgramName, QString strProgramPath) : QObject(parent), QTreeWidgetItem(UserType), m_parent(parent) {
|
2022-08-25 18:37:24 +08:00
|
|
|
|
m_strProgramName = strProgramName;
|
|
|
|
|
m_strProgramPath = strProgramPath;
|
|
|
|
|
mLedCard = pLedCard;
|
2022-01-04 18:11:48 +08:00
|
|
|
|
|
|
|
|
|
setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
|
|
|
|
|
setCheckState(0, Qt::Unchecked);
|
|
|
|
|
m_parent->addTopLevelItem(this);
|
|
|
|
|
m_ImageOnline = new QLabel();
|
|
|
|
|
m_ImageOnline->setAlignment(Qt::AlignCenter);
|
2022-08-25 18:37:24 +08:00
|
|
|
|
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);
|
2022-01-04 18:11:48 +08:00
|
|
|
|
|
2023-05-11 11:47:00 +08:00
|
|
|
|
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->m_bLockStatus) 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("_type", "VerifyPassword");
|
|
|
|
|
json.insert("_type", "VerifyPassword");
|
|
|
|
|
json.insert("pwd", pwd);
|
|
|
|
|
auto waitingDlg = new WaitingDlg(treeWidget(), tr("VerifyPassword")+" ...");
|
|
|
|
|
waitingDlg->show();
|
|
|
|
|
auto reply = NetReq("http://"+mLedCard->m_strCardIp+":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->m_bLockStatus = false;
|
|
|
|
|
btnUnlock->setIcon(QIcon(":/res/device/UnLock.png"));
|
|
|
|
|
});
|
2022-08-25 18:37:24 +08:00
|
|
|
|
});
|
2023-05-11 11:47:00 +08:00
|
|
|
|
|
|
|
|
|
SetItemParam(mLedCard);
|
2022-01-04 18:11:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-11 11:47:00 +08:00
|
|
|
|
void wProgramPublishItem::SetItemParam(LedCard *card) {
|
|
|
|
|
setData(ENUM_DEVICE_PUBLISH_HEADE_SCREEN_ID, 0, card->m_strCardId);
|
|
|
|
|
setData(ENUM_DEVICE_PUBLISH_HEADE_REMARK_NAME, 0, card->m_strCardRemarkName);
|
|
|
|
|
setData(ENUM_DEVICE_PUBLISH_HEADE_SCREEN_IP, 0, card->m_strCardIp);
|
|
|
|
|
setData(ENUM_DEVICE_PUBLISH_HEADE_SCREEN_SIZE, 0, QString("%1 x %2").arg(card->m_iWidth).arg(card->m_iHeight));
|
2023-04-18 14:14:46 +08:00
|
|
|
|
m_ImageOnline->setPixmap(QPixmap(mLedCard->m_bOnLine ? ":/res/device/O_Online.png" : ":/res/device/O_Offline.png"));
|
2023-05-11 11:47:00 +08:00
|
|
|
|
if(! card->bPassword) btnUnlock->hide();
|
|
|
|
|
else {
|
|
|
|
|
if(! btnUnlock->isVisible()) btnUnlock->show();
|
|
|
|
|
btnUnlock->setIcon(QIcon(card->m_bLockStatus ? ":/res/device/Lock.png" : ":/res/device/UnLock.png")); //如果已经验证通过密码显示绿色图标 没有验证显示蓝色锁图标
|
|
|
|
|
}
|
2022-01-04 18:11:48 +08:00
|
|
|
|
}
|