From b728631477886f05bc56ca9ccfba999b44b3638f Mon Sep 17 00:00:00 2001 From: gaozheng Date: Wed, 10 Jun 2026 16:21:49 +0800 Subject: [PATCH] =?UTF-8?q?refactor(theme):=20TopBar/PanelHeader=20?= =?UTF-8?q?=E5=86=85=E8=81=94=E6=A0=B7=E5=BC=8F=E8=BF=81=E7=A7=BB=E5=88=B0?= =?UTF-8?q?=E8=AF=AD=E4=B9=89=E4=BB=A4=E7=89=8C=EF=BC=88=E8=A7=84=E8=8C=83?= =?UTF-8?q?=C2=A74.3/=C2=A75=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/PanelHeader.cpp | 36 +++++++++++++++++------------------- src/app/TopBar.cpp | 20 ++++++++++---------- 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/app/PanelHeader.cpp b/src/app/PanelHeader.cpp index ec20fc5..e45939f 100644 --- a/src/app/PanelHeader.cpp +++ b/src/app/PanelHeader.cpp @@ -31,25 +31,23 @@ constexpr int kTabIcon = 19; // Tab 图标 QString headerQss() { return QStringLiteral( - "#panelHeader { background:#FFFFFF; border-bottom:1px solid #E6EAF1; }" - "#panelTitle { color:#1F2A3D; font-size:%1px; font-weight:%3; }" - "#panelBadge { background:#EAEEF5; color:#5A6B85; border-radius:9px;" + "#panelHeader { background:{{bg/panel}}; border-bottom:1px solid {{divider}}; }" + "#panelTitle { color:{{text/primary}}; font-size:%1px; font-weight:%3; }" + "#panelBadge { background:{{bg/hover}}; color:{{text/secondary}}; border-radius:9px;" " padding:1px 7px; font-size:%2px; font-weight:%3; }" - "#panelBadgeWarn { background:%4; color:%5; border-radius:9px;" + "#panelBadgeWarn { background:{{status/warning-bg}}; color:{{status/warning}}; border-radius:9px;" " padding:1px 7px; font-size:%2px; font-weight:%3; }" "QToolButton#panelAction { border:none; border-radius:7px; padding:5px; }" - "QToolButton#panelAction:hover { background:#EEF3FB; }" - "QToolButton#tabBtn { border:none; border-bottom:2px solid transparent; color:#5A6B85;" - " padding:8px 6px; font-size:%6px; }" - "QToolButton#tabBtn:hover { color:#1F2A3D; }" - "QToolButton#tabBtn:checked { color:#2D6CB5; font-weight:%3;" - " border-bottom:2px solid #2D6CB5; }") - .arg(scaledPx(type::kTitle)) - .arg(scaledPx(type::kCaption)) - .arg(type::kWeightSemibold) - .arg(QString::fromUtf8(semantic::kWarningFill)) - .arg(QString::fromUtf8(semantic::kWarning)) - .arg(scaledPx(type::kBody)); + "QToolButton#panelAction:hover { background:{{bg/hover}}; }" + "QToolButton#tabBtn { border:none; border-bottom:2px solid transparent; color:{{text/secondary}};" + " padding:8px 6px; font-size:%4px; }" + "QToolButton#tabBtn:hover { color:{{text/primary}}; }" + "QToolButton#tabBtn:checked { color:{{accent/primary}}; font-weight:%3;" + " border-bottom:2px solid {{accent/primary}}; }") + .arg(scaledPx(type::kTitle)) // %1 标题字号 + .arg(scaledPx(type::kCaption)) // %2 徽标字号 + .arg(type::kWeightSemibold) // %3 字重(多处) + .arg(scaledPx(type::kBody)); // %4 页签字号 } // 数量徽标(默认隐藏,调用方 setText+setVisible 显示)。 @@ -83,7 +81,7 @@ QWidget* buildPanelHeader(Glyph icon, const QString& title, const QVector
setObjectName(QStringLiteral("panelHeader")); header->setFixedHeight(kHeaderHeight); - geopro::app::applyThemedStyleSheet(header, headerQss()); + geopro::app::applyTokenizedStyleSheet(header, headerQss()); auto* lay = new QHBoxLayout(header); lay->setContentsMargins(12, 0, 8, 0); @@ -116,7 +114,7 @@ TabbedPanel buildTabbedPanel(const QVector& tabs, const QVector
setObjectName(QStringLiteral("panelHeader")); header->setFixedHeight(kHeaderHeight); - geopro::app::applyThemedStyleSheet(header, headerQss()); + geopro::app::applyTokenizedStyleSheet(header, headerQss()); auto* hlay = new QHBoxLayout(header); hlay->setContentsMargins(10, 0, 8, 0); hlay->setSpacing(2); @@ -171,7 +169,7 @@ SegmentedHeader buildSegmentedHeader(const QVector& segments, auto* header = new QWidget(); header->setObjectName(QStringLiteral("panelHeader")); header->setFixedHeight(kHeaderHeight); - geopro::app::applyThemedStyleSheet(header, headerQss()); + geopro::app::applyTokenizedStyleSheet(header, headerQss()); auto* hlay = new QHBoxLayout(header); hlay->setContentsMargins(10, 0, 8, 0); diff --git a/src/app/TopBar.cpp b/src/app/TopBar.cpp index 5599dd4..218de0e 100644 --- a/src/app/TopBar.cpp +++ b/src/app/TopBar.cpp @@ -131,21 +131,21 @@ TopBar::TopBar(QWidget* parent) : QWidget(parent) { // 字号引用 Theme 排版令牌:工作空间切换器=title(15)、头像/用户名=body·label(13)、 // 角色名=caption(12)。原 11px 角色名上调到 12,去掉只差 1px 的糊层级。 // 切换器(ElaToolButton)/图标(ElaIconButton) 自绘 Fluent,不再写它们的 QSS。 - // 仅保留:工具条底/分隔线、头像(圆形自定义)、用户名/角色。头像白字用 white 关键字(恒白)。 - geopro::app::applyThemedStyleSheet( + // 仅保留:工具条底/分隔线、头像(圆形自定义)、用户名/角色。头像白字用 {{text/on-primary}} 令牌。 + geopro::app::applyTokenizedStyleSheet( this, QStringLiteral( - "#appToolBar { background:#FFFFFF; border-bottom:1px solid #E1E6EE; }" - "#topDivider { color:#E1E6EE; }" + "#appToolBar { background:{{bg/header}}; border-bottom:1px solid {{divider}}; }" + "#topDivider { color:{{divider}}; }" "QToolButton::menu-indicator { image:none; }" - "#wsSwitcher { color:#1F2A3D; border:none; border-radius:8px; padding:8px 12px;" + "#wsSwitcher { color:{{text/primary}}; border:none; border-radius:8px; padding:8px 12px;" " font-size:%6px; font-weight:%4; }" - "#wsSwitcher:hover { background:#EEF3FB; }" + "#wsSwitcher:hover { background:{{bg/hover}}; }" "QToolButton#iconBtn { border:none; border-radius:8px; padding:8px; }" - "QToolButton#iconBtn:hover { background:#EEF3FB; }" - "#avatar { background:#2D6CB5; color:white; border-radius:17px; font-weight:%2;" + "QToolButton#iconBtn:hover { background:{{bg/hover}}; }" + "#avatar { background:{{accent/primary}}; color:{{text/on-primary}}; border-radius:17px; font-weight:%2;" " font-size:%1px; }" - "#userName { color:#1F2A3D; font-size:%3px; font-weight:%4; }" - "#userRole { color:#8A93A3; font-size:%5px; }") + "#userName { color:{{text/primary}}; font-size:%3px; font-weight:%4; }" + "#userRole { color:{{text/tertiary}}; font-size:%5px; }") .arg(scaledPx(type::kBody)) .arg(type::kWeightBold) .arg(scaledPx(type::kLabel))