fix(ui): 坐标轴面板硬编码颜色 token 化(深色模式合规,规范§1/§6.7)

按视觉规范审计修 AxesSettingsPanel 硬编码(深色模式下会失效):
- 应用按钮 #2f6fed/#2a63d4/radius6 → setDefault(true) 走全局 QPushButton:default(accent/primary,随主题)
- 关闭按钮 #888/#2f6fed → token(text/secondary / accent/primary)
- 放大系数标签 + 最小/最大值标签 #888 → token(text/secondary / text/tertiary)
- 面板圆角 10px → 8px(radius/lg,规范§3.2 画布浮窗)

构建:app 链接通过
This commit is contained in:
gaozheng 2026-06-25 22:46:13 +08:00
parent cdd7613d53
commit fb911a9d85
1 changed files with 12 additions and 10 deletions

View File

@ -48,7 +48,7 @@ AxesSettingsPanel::AxesSettingsPanel(QWidget* parent) : QFrame(parent) {
setFrameShape(QFrame::StyledPanel);
applyTokenizedStyleSheet(
this, QStringLiteral("QFrame{background:{{bg/panel}};border:1px solid {{border/default}};"
"border-radius:10px;}"));
"border-radius:8px;}")); // radius/lg=8规范§3.2 画布浮窗)
setFixedWidth(320);
auto* v = new QVBoxLayout(this);
@ -63,9 +63,12 @@ AxesSettingsPanel::AxesSettingsPanel(QWidget* parent) : QFrame(parent) {
close->setFixedSize(24, 24);
close->setCursor(Qt::PointingHandCursor);
// 显式覆盖全局 QPushButton 的 padding(6px 14px)/border——否则 24×24 容不下 padding× 被挤出不可见。
close->setStyleSheet(QStringLiteral(
"QPushButton{border:none;background:transparent;padding:0;margin:0;font-size:16px;color:#888;}"
"QPushButton:hover{color:#2f6fed;}"));
// 颜色走 token避免深色模式失效
applyTokenizedStyleSheet(
close, QStringLiteral(
"QPushButton{border:none;background:transparent;padding:0;margin:0;font-size:16px;"
"color:{{text/secondary}};}"
"QPushButton:hover{color:{{accent/primary}};}"));
connect(close, &QPushButton::clicked, this, &AxesSettingsPanel::closed);
titleRow->addWidget(title);
titleRow->addStretch(1);
@ -100,7 +103,8 @@ AxesSettingsPanel::AxesSettingsPanel(QWidget* parent) : QFrame(parent) {
scaleSlider_->setSingleStep(1);
scaleSlider_->setPageStep(1); // 点击轨道按 1 步移动(默认 pageStep=10 → 点一下直接跳到 10 的 bug
scaleLabel_ = new QLabel(QStringLiteral("1.0×"), this);
scaleLabel_->setStyleSheet(QStringLiteral("border:none;color:#888;min-width:36px;"));
applyTokenizedStyleSheet(scaleLabel_,
QStringLiteral("border:none;color:{{text/secondary}};min-width:36px;"));
connect(scaleSlider_, &QSlider::valueChanged, this,
[this](int v) { scaleLabel_->setText(QStringLiteral("%1.0×").arg(v)); });
scaleRow->addWidget(scaleSlider_, 1);
@ -111,9 +115,7 @@ AxesSettingsPanel::AxesSettingsPanel(QWidget* parent) : QFrame(parent) {
auto* btns = new QHBoxLayout();
auto* cancel = new QPushButton(QStringLiteral("取消"), this);
auto* apply = new QPushButton(QStringLiteral("应用"), this);
apply->setStyleSheet(QStringLiteral(
"QPushButton{background:#2f6fed;color:white;border:none;border-radius:6px;padding:6px 18px;}"
"QPushButton:hover{background:#2a63d4;}"));
apply->setDefault(true); // 主按钮:走全局 QPushButton:default 样式(accent/primary,随主题),不再硬编码蓝
connect(cancel, &QPushButton::clicked, this, &AxesSettingsPanel::closed);
connect(apply, &QPushButton::clicked, this, [this] {
auto rd = [](const Row& r) {
@ -147,7 +149,7 @@ AxesSettingsPanel::Row AxesSettingsPanel::addAxisRow(QVBoxLayout* col, const QSt
auto* range = new QHBoxLayout();
auto* loCol = new QVBoxLayout();
auto* loLbl = new QLabel(QStringLiteral("最小值"), this);
loLbl->setStyleSheet(QStringLiteral("border:none;color:#888;"));
applyTokenizedStyleSheet(loLbl, QStringLiteral("border:none;color:{{text/tertiary}};"));
loCol->addWidget(loLbl);
r.lo = new QDoubleSpinBox(this);
r.lo->setRange(-1e6, 1e6);
@ -156,7 +158,7 @@ AxesSettingsPanel::Row AxesSettingsPanel::addAxisRow(QVBoxLayout* col, const QSt
range->addLayout(loCol);
auto* hiCol = new QVBoxLayout();
auto* hiLbl = new QLabel(QStringLiteral("最大值"), this);
hiLbl->setStyleSheet(QStringLiteral("border:none;color:#888;"));
applyTokenizedStyleSheet(hiLbl, QStringLiteral("border:none;color:{{text/tertiary}};"));
hiCol->addWidget(hiLbl);
r.hi = new QDoubleSpinBox(this);
r.hi->setRange(-1e6, 1e6);