1.添加图片注册和前后板主题图片上传;2.修改mdns连接方式

This commit is contained in:
2024-12-10 16:15:55 +08:00
parent 9d506e1cfc
commit d2bccd9c49
177 changed files with 4381 additions and 5709 deletions

View File

@@ -112,7 +112,7 @@ QString ClientHandler::getCurrentFuncItemData() const
QString ClientHandler::getCurrentItemLable() const
{
QString lable = currentItem.value("lable").toString();
//qDebug() << "Getting current item lable:" << lable;
qDebug() << "Getting current item lable:" << lable;
return lable; // 返回当前项的 "data" 字段
}
@@ -157,13 +157,16 @@ void ClientHandler::sendDataToClient(const QByteArray& data)
emit sendData(data, isBackBoardOrAllBoard);
}
void ClientHandler::onCommandError() {
isCommandError = true;
}
void ClientHandler::sendJsonItem(const QJsonArray& jsonArray, int itemIndex, const QString text, const QString backBoardSn, const QString& itemType)
{
startReadVideoDataTimer(preVideoClientId);
currentJson = jsonArray;
currentJsonItem = itemIndex;
QMutexLocker locker(&mutex);
if (itemType == "License") {
}
@@ -260,6 +263,7 @@ void ClientHandler::sendJsonItem(const QJsonArray& jsonArray, int itemIndex, con
}
}
QString itemData = QJsonDocument(currentItem).toJson();
emit currentSendItem(currentItem["cmd"].toString());
if (isBackBoardOrAllBoard) {
emit sendDataToSomeClient(isBackBoardOrAllBoard, itemData.toUtf8());
}
@@ -363,20 +367,21 @@ void ClientHandler::sendFrontItem(int itemIndex)
return;
}
else {
QString text = "";
QString text = "";
QJsonObject currentItem = frontBoardTest[itemIndex].toObject();
if (currentItem.contains("cmd") && currentItem["cmd"].toString() == "IMG_ENROLL") {
ImageEnrollWindow dialog;
if (dialog.exec() == QDialog::Accepted) {
text = dialog.getFilePath();
QByteArray imageData = dialog.getImageData();
if (!imageData.isEmpty()) {
text = QString::fromUtf8(imageData);
}
}
else {
return;
QString downloadUrl;
QEventLoop loop;
emit startImageSharing(IMG_ENROLL_W, IMG_ENROLL_H, "enroll", [&downloadUrl, &loop](QString responseUrl) {
//qDebug() << "Received response from slot:" << responseUrl;
downloadUrl = responseUrl; // 更新局部变量
loop.quit(); // 退出事件循环
});
//loop.exec(); // 等待回调执行完成
if (!downloadUrl.isEmpty()) {
qDebug() << "Image available at:" << downloadUrl;
}
text = downloadUrl;
}
else if (currentItem.contains("cmd") && currentItem["cmd"].toString() == "DEL_USER") {
DelUserWindow dialog;
@@ -412,18 +417,22 @@ void ClientHandler::sendBackItem(int itemIndex)
else {
QString text = "";
QJsonObject currentItem = backBoardTest[itemIndex].toObject();
if (currentItem.contains("cmd") && currentItem["cmd"].toString() == "IMG_ENROLL") {
ImageEnrollWindow dialog;
if (dialog.exec() == QDialog::Accepted) {
text = dialog.getFilePath();
QByteArray imageData = dialog.getImageData();
if (!imageData.isEmpty()) {
text = QString::fromUtf8(imageData);
}
if (currentItem.contains("cmd") && currentItem["cmd"].toString() == "CHANGE_THEME") {
QString downloadUrl;
QEventLoop loop;
emit startImageSharing(CHANGE_THEME_W, CHANGE_THEME_H, "theme", [&downloadUrl, &loop](QString responseUrl) {
//qDebug() << "Received response from slot:" << responseUrl;
downloadUrl = responseUrl; // 更新局部变量
loop.quit(); // 退出事件循环
});
//loop.exec(); // 等待回调执行完成
if (!downloadUrl.isEmpty()) {
qDebug() << "Image available at:" << downloadUrl;
}
else {
return;
}
text = downloadUrl;
}
else if (currentItem.contains("cmd") && currentItem["cmd"].toString() == "DEL_USER") {
DelUserWindow dialog;
@@ -485,11 +494,13 @@ void ClientHandler::sendDevInfoItem()
currentJson = backBoardDevInfoJson;
currentJsonItem = currentBackBoardIndex;
if (currentBackBoardIndex < backBoardDevInfoJson.size()) {
isRecvVideoData = false;
sendDevInfoJsonItem(backBoardDevInfoJson[currentBackBoardIndex ++].toObject(), 1);
}
else
isPowerOnSend = false;
else {
isRecvVideoData = true;
isPowerOnSend = false;
}
}
else {
currentJson = frontBoardDevInfoJson;
@@ -688,10 +699,13 @@ void ClientHandler::onDataReceived()
}
}
getCurrentItemLable();
//qDebug() << "------- currentItem.value(timeout):" << currentItem.value("timeout").toInt();
if ((currentItem.contains("timeout")) || (currentFuncItem.contains("timeout"))) {
//qDebug() << "currentItem.contains(timeout):" << currentItem.contains("timeout");
emit startTimeout(0);
}
QJsonObject currentTempItem = currentJson[currentItemIndex].toObject();
//qDebug() << "---Received allData size:" << allData.size();
if (!allData.isEmpty()) {
emit dataReceived(getClientAddress(), allData, 0xFF, currentItemIndex, currentFuncItemIndex, getCurrentItemLable(), "", currentJson, currentJsonItem);
if (!isSingleSend && !isPowerOnSend && (currentTempItem["cmd"] != "GET_IMG")) {
@@ -750,9 +764,12 @@ void ClientHandler::onDataReceived()
if (preVideoClientId == clientId) {
qDebug() << "-----------------" << preVideoClientId << "isRecvVideoData:" << isRecvVideoData;
}
socket->readAll();
//QByteArray data = socket->readAll();
//qDebug() << "--------- socket->readAll()" ;
QByteArray AllData = socket->readAll();
if (isCommandError) {
isCommandError = false;
emit dataReceived(getClientAddress(), AllData, 0xFF, currentItemIndex, currentFuncItemIndex, "", "", currentJson, currentJsonItem);
}
//qDebug() << "--------- AllData.size():" << AllData.size();
}
}