1.新增服务端UI界面,显示服务基础信息。2.修改设备显示配置。3.监控页面储能系统显示储能模式,模式设置新增'手动'

This commit is contained in:
lixiaoyuan
2025-09-25 19:20:25 +08:00
parent d7888c2be4
commit 8aba56f47d
39 changed files with 2954 additions and 408 deletions

View File

@@ -1,10 +1,9 @@
#include <QMainWindow>
#include <QLabel>
#include <QPushButton>
#include <QHBoxLayout>
#include <QTableWidget>
#include <QTimer>
#include <QTextEdit>
#include <string>
using namespace std;
@@ -14,73 +13,8 @@ using namespace std;
#include <QTextEdit>
#include <mutex>
class QtTextSink : public QObject, public spdlog::sinks::base_sink<std::mutex>
{
Q_OBJECT
public:
// 构造函数接收一个 QTextEdit*,但用 QPointer 来包装它
explicit QtTextSink(QTextEdit* textEdit, QObject* parent = nullptr)
: QObject(parent), textEdit(textEdit) {
}
#include "widgets/QWHome.h"
signals:
// 定义一个信号,用于在主线程中追加文本
void appendText(const QString& message);
protected:
// 重写 sink_it_ 方法,处理每条日志
void sink_it_(const spdlog::details::log_msg& msg) override {
if (textEdit.isNull()) {
// 如果 QTextEdit 已经被删除,则忽略这条日志
return;
}
spdlog::memory_buf_t formatted;
formatter_->format(msg, formatted);
QString logMessage = QString::fromStdString(fmt::to_string(formatted));
// 发射信号通过Qt的事件循环在主线程中安全地更新UI
emit appendText(logMessage);
}
void flush_() override {}
private:
QPointer<QTextEdit> textEdit; // 关键:使用 QPointer
};
class LabelPair
{
public:
LabelPair(QWidget* parent, int x, int y, int w, int h)
{
title.setParent(parent);
value.setParent(&title);
title.setGeometry(x, y, w, h);
value.setGeometry(80, 0, w-80, h);
title.show();
value.show();
}
void setTitle(std::string text)
{
title.setText(text.c_str());
}
void setValue(std::string text)
{
value.setText(text.c_str());
}
QLabel title;
QLabel value;
};
class MyWorkspace;
class MainApp : public QWidget
{
@@ -97,7 +31,7 @@ private slots:
public:
struct {
std::shared_ptr<LabelPair> weburl {};
std::shared_ptr<MyWorkspace> workspace;
std::shared_ptr<MyWidget> wigetHome;
} ui;
struct {