feat:初始化wuhan_QT界面代码

This commit is contained in:
xu
2026-09-09 17:00:37 +08:00
commit 40473ad10b
537 changed files with 23934 additions and 0 deletions
+91
View File
@@ -0,0 +1,91 @@
#include "datacard.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include "global.h"
#include <QStyle>
DataCard::DataCard(const QString& title, QWidget* parent)
: QWidget(parent)
{
setProperty("card", true);
QVBoxLayout* lay = new QVBoxLayout(this);
lay->setContentsMargins(16, 0, 16, 14);
lay->setSpacing(8);
// 标题栏(高 44px)
m_title = new QLabel(title, this);
m_title->setFixedHeight(44);
m_title->setProperty("cardTitle", true);
m_title->setStyleSheet(QString("color:%1;font-size:24px;font-weight:700;border-bottom:1px solid %2;")
.arg(C::TEXT, C::BORDER));
lay->addWidget(m_title);
// 字段行容器
lay->addStretch(1);
}
void DataCard::setTitle(const QString& t)
{
m_title->setText(t);
}
int DataCard::addField(const QString& label, const QString& value, bool big)
{
int index = m_values.size();
QHBoxLayout* row = new QHBoxLayout();
row->setSpacing(8);
QLabel* lab = new QLabel(label + ":", this);
lab->setProperty("sub", true);
lab->setStyleSheet(QString("color:%1;font-size:22px;").arg(C::TEXT_SUB));
QLabel* val = new QLabel(value, this);
val->setStyleSheet(QString("color:%1;%2").arg(C::TEXT,
big ? "font-size:64px;font-weight:700;" : "font-size:30px;font-weight:700;"));
row->addWidget(lab);
row->addWidget(val, 1);
// 插入到标题栏之后(stretch 之前)
QVBoxLayout* lay = qobject_cast<QVBoxLayout*>(layout());
lay->insertLayout(lay->count() - 1, row);
m_values.append(val);
m_labels.append(label);
return index;
}
void DataCard::setField(int index, const QString& value)
{
if (index < 0 || index >= m_values.size())
return;
m_values[index]->setText(value);
}
void DataCard::setAlarm(int index, bool on)
{
if (index < 0 || index >= m_values.size())
return;
QLabel* val = m_values[index];
if (on) {
val->setProperty("alert", true);
startBlink(val, "blink");
} else {
stopBlink(val, "blink");
val->setProperty("alert", false);
val->style()->unpolish(val);
val->style()->polish(val);
}
}
void DataCard::setHighlight(bool on)
{
if (on)
setStyleSheet(QString("QWidget[card=\"true\"]{background-color:%1;border:3px solid %2;border-radius:12px;}")
.arg(C::PANEL, C::PRIMARY));
else
setStyleSheet(QString());
}