增加通讯协议

This commit is contained in:
xu
2026-10-14 09:59:42 +08:00
parent 32878a9a80
commit 950e9e6c9e
102 changed files with 5538 additions and 2679 deletions
+25 -8
View File
@@ -11,14 +11,14 @@ DataCard::DataCard(const QString& title, QWidget* parent)
setProperty("card", true);
QVBoxLayout* lay = new QVBoxLayout(this);
lay->setContentsMargins(16, 0, 16, 14);
lay->setSpacing(8);
lay->setContentsMargins(24, 0, 24, 20);
lay->setSpacing(16);
// 标题栏(高 44px)
// 标题栏
m_title = new QLabel(title, this);
m_title->setFixedHeight(44);
m_title->setFixedHeight(60);
m_title->setProperty("cardTitle", true);
m_title->setStyleSheet(QString("color:%1;font-size:24px;font-weight:700;border-bottom:1px solid %2;")
m_title->setStyleSheet(QString("color:%1;font-size:42px;font-weight:700;border-bottom:1px solid %2;")
.arg(C::TEXT, C::BORDER));
lay->addWidget(m_title);
@@ -36,15 +36,15 @@ int DataCard::addField(const QString& label, const QString& value, bool big)
int index = m_values.size();
QHBoxLayout* row = new QHBoxLayout();
row->setSpacing(8);
row->setSpacing(16);
QLabel* lab = new QLabel(label + ":", this);
lab->setProperty("sub", true);
lab->setStyleSheet(QString("color:%1;font-size:22px;").arg(C::TEXT_SUB));
lab->setStyleSheet(QString("color:%1;font-size:32px;").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;"));
big ? "font-size:50px;font-weight:700;" : "font-size:42px;font-weight:700;"));
row->addWidget(lab);
row->addWidget(val, 1);
@@ -89,3 +89,20 @@ void DataCard::setHighlight(bool on)
else
setStyleSheet(QString());
}
// 字段行文字从左缘缩进到「中间偏左」:行首弹性 2 : 数值行尾弹性 3
void DataCard::indentRows()
{
QVBoxLayout* lay = qobject_cast<QVBoxLayout*>(layout());
if (!lay)
return;
for (int i = 0; i < lay->count(); ++i) {
QHBoxLayout* row = qobject_cast<QHBoxLayout*>(lay->itemAt(i)->layout());
if (!row || row->count() != 2) // 字段行是 [标签][数值];标题与末尾 stretch 不是子布局
continue;
if (row->itemAt(0)->spacerItem()) // 已缩进过,避免重复插入
continue;
row->insertStretch(0, 2);
row->setStretch(2, 3); // 插入后 [0]=行首弹性 [1]=标签 [2]=数值
}
}