排障窗口增加数值监控。

在窗口数量大于4时启用窗口扩大按钮。
日志去除多余功能。
This commit is contained in:
2025-10-14 20:43:33 +08:00
parent 64ba329946
commit fcc512fd61
9 changed files with 237 additions and 58 deletions
+68 -11
View File
@@ -2,6 +2,50 @@
#include <global.h>
#include <nlohmannJson.hpp>
#include <qlayout.h>
class plcValueViewer :public QWidget{
public:
QPalette palette;
QFont font1 = QFont("微软雅黑", 12, QFont::Bold);
QFont font2 = QFont("微软雅黑", 10, QFont::Bold);
QFont font3 = QFont("微软雅黑", 6, QFont::Bold);
plcValueViewer(const QString& groupNameIN,
const std::vector<std::pair<QString, int>>& viewerNameAndAddress,
QMap<int, std::vector<QLabel*>>& plcViwerLineedits)
:groupName(groupNameIN){
palette.setColor(QPalette::WindowText, Qt::white);
QLabel* groupNameLabel = new QLabel(groupNameIN);
groupNameLabel->setFont(font1);
groupNameLabel->setPalette(palette);
layout->addWidget(groupNameLabel);
for (auto& data : viewerNameAndAddress) {
plcViwerLineedits[data.second].push_back(addViewer(data.first));
}
widget->setMaximumHeight(100);
}
QLabel* addViewer(const QString& viewerName) {
map.insert(groupName + viewerName ,new QLabel("*"));
auto label = map[groupName + viewerName];
label->setFont(font2);
label->setPalette(palette);
auto textLabel = new QLabel(viewerName);
textLabel->setFont(font3);
textLabel->setPalette(palette);
QVBoxLayout* viewerLayout = new QVBoxLayout();
viewerLayout->addWidget(label,Qt::AlignCenter);
viewerLayout->addWidget(textLabel, Qt::AlignCenter);
layout->addLayout(viewerLayout);
return label;
}
QString groupName = "";
QWidget* widget = new QWidget();
QHBoxLayout* layout = new QHBoxLayout(widget);
QMap<QString, QLabel*> map;
};
class runCommandWidget : public QDialog {
Q_OBJECT
@@ -9,17 +53,20 @@ public:
explicit runCommandWidget(QWidget* parent = nullptr)
: QDialog(parent) {
this->setWindowTitle("执行命令");
this->resize(400, 800);
//setWindowFlags(this->windowFlags() | Qt::FramelessWindowHint); // 去掉边框 //现在、、
//setAttribute(Qt::WA_TranslucentBackground); // 背景透明
this->setObjectName("JsonParamTableEditor");
this->setStyleSheet(QString("QDialog#JsonParamTableEditor {background-color: rgb(%1);border: 2px solid #000000;border-radius: 6px;}").arg(sColor_Blue));
this->setObjectName("runCommandWidget");
this->setStyleSheet(QString("QDialog#runCommandWidget {background-color: rgb(%1);border: 2px solid #000000;border-radius: 6px;}").arg(sColor_Blue));
btnWidgets = new QListWidget(this);
btnWidgets->setStyleSheet("background: transparent;");
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(btnWidgets);
this->setFixedSize(sizeX, sizeY);
plcValueViewerLayout = new QVBoxLayout();
//plcValueViewerLayout->setStyleSheet("background: transparent;");
QGridLayout* layout = new QGridLayout(this);
layout->addWidget(btnWidgets, 0, 0);
layout->addLayout(plcValueViewerLayout, 0, 1);
this->setFixedWidth(sizeX);
}
signals:
@@ -28,9 +75,8 @@ signals:
public slots:
void addBtn(const QString& btnName, const QString& tip, const QString& uuid) {
QListWidgetItem* item = new QListWidgetItem(btnWidgets);
item->setSizeHint(QSize(sizeX - 30, 30));
btnWidgets->addItem(item);
fancyButtonText* funcBtn = new fancyButtonText(btnName, sizeX - 30, 30, tip);
fancyButtonText* funcBtn = new fancyButtonText(btnName,0,0, tip);
btnWidgets->setItemWidget(item, funcBtn);
connect(funcBtn, &fancyButtonText::clicked, this, [this, uuid]() {
QMessageBox::StandardButton reply;
@@ -45,8 +91,19 @@ public slots:
}
});
}
void addPlcValueViewer(const QString& groupName,std::vector<std::pair<QString, int>> viewerNameAndAddress) {
auto widget = new plcValueViewer(groupName, viewerNameAndAddress, plcViwerLineedits);
plcValueViewerLayout->addWidget(widget->widget,Qt::AlignTop);
}
void refreshPlcValueViewer(int address, int value) {
for (auto& lineedit : plcViwerLineedits[address]) {
lineedit->setText(QString::number(value));
}
}
private:
int sizeX = 300, sizeY = 500;
int sizeX = 1000, sizeY = 500;
QListWidget* btnWidgets;
QVBoxLayout* plcValueViewerLayout;
QMap<int, std::vector<QLabel*>>plcViwerLineedits;
};
#pragma once