refactor/pure-qt-ui #3

Merged
gaozheng merged 56 commits from refactor/pure-qt-ui into main 2026-06-10 18:41:53 +08:00
2 changed files with 32 additions and 25 deletions
Showing only changes of commit 5f02d494dc - Show all commits

View File

@ -1,5 +1,7 @@
#include "Theme.hpp" #include "Theme.hpp"
#include "Glyphs.hpp"
#include <QApplication> #include <QApplication>
#include <QColor> #include <QColor>
#include <QFont> #include <QFont>
@ -155,6 +157,11 @@ QTreeView::item:selected, QListView::item:selected {
background: {{bg/selected}}; background: {{bg/selected}};
color: {{text/primary}}; color: {{text/primary}};
} }
QTreeWidget::item:selected:!active, QListWidget::item:selected:!active,
QTreeView::item:selected:!active, QListView::item:selected:!active {
background: {{bg/selected}};
color: {{text/primary}};
}
/* 注意:不要给 QTreeView::branch 设 background——一旦改写 branchQt 会停止绘制 /* 注意:不要给 QTreeView::branch 设 background——一旦改写 branchQt 会停止绘制
/ indicator */ / indicator */
@ -449,10 +456,34 @@ ads--CDockWidgetTab[activeTab="true"] QLabel {
} }
)QSS"; )QSS";
// 全局复选指示器:用 writeCheckboxIcon 生成清晰复选框 PNG未选=明显边框空心框,
// 选中=强调色填充+白勾),统一作用于 QCheckBox 与 树/列表的勾选指示器。规避 Fusion
// 原生复选框在浅底下边框过淡看不清的问题——全 UI 一套,避免逐控件打补丁。
QString indicatorQss(bool dark)
{
const QColor border = QColor(tokenHex("border/strong", dark));
const QColor boxBg = QColor(tokenHex("bg/panel", dark));
const QColor accent = QColor(tokenHex("accent/primary", dark));
const QString tag = dark ? QStringLiteral("gd") : QStringLiteral("gl"); // 全局缓存标签
const QString off = geopro::app::writeCheckboxIcon(false, border, boxBg, Qt::white, tag);
const QString on = geopro::app::writeCheckboxIcon(true, accent, accent, Qt::white, tag);
return QStringLiteral(
"QCheckBox::indicator, QTreeView::indicator, QListView::indicator,"
"QTreeWidget::indicator, QListWidget::indicator { width:16px; height:16px; }"
"QCheckBox::indicator:unchecked, QTreeView::indicator:unchecked,"
"QListView::indicator:unchecked, QTreeWidget::indicator:unchecked,"
"QListWidget::indicator:unchecked { image:url(%1); }"
"QCheckBox::indicator:checked, QTreeView::indicator:checked,"
"QListView::indicator:checked, QTreeWidget::indicator:checked,"
"QListWidget::indicator:checked { image:url(%2); }")
.arg(off, on);
}
// 当前模式的全局 QSS。 // 当前模式的全局 QSS。
QString styleSheetForMode(bool /*dark*/) QString styleSheetForMode(bool /*dark*/)
{ {
return fillTokens(QString::fromUtf8(kStyleSheet)); const bool dark = isDarkTheme();
return fillTokens(QString::fromUtf8(kStyleSheet)) + indicatorQss(dark);
} }
// 调色板同样取自 ElaTheme让无 QSS 覆盖处的标准控件也与外壳一致。 // 调色板同样取自 ElaTheme让无 QSS 覆盖处的标准控件也与外壳一致。

View File

@ -40,30 +40,6 @@ ObjectTreePanel::ObjectTreePanel(QWidget* parent) : QWidget(parent) {
tree_->setHeaderHidden(true); tree_->setHeaderHidden(true);
tree_->setIndentation(14); // 收紧缩进 tree_->setIndentation(14); // 收紧缩进
// 清晰复选框:自绘 PNG未选=明显边框空心框,选中=强调色底+白勾),明暗各一套、切换重绘。
// 规避 Fusion 原生复选框在浅底下边框过淡、看不清的问题。
auto applyCheckboxStyle = [this]() {
const bool dark = geopro::app::isDarkTheme();
const QColor border = geopro::app::tokenColor("border/strong"); // 未选复选框描边规范§6.12
const QColor boxBg = geopro::app::tokenColor("bg/panel");
const QColor accent = geopro::app::tokenColor("accent/primary"); // 选中填充
const QString tag = dark ? QStringLiteral("d") : QStringLiteral("l");
const QString off = geopro::app::writeCheckboxIcon(false, border, boxBg, Qt::white, tag);
const QString on = geopro::app::writeCheckboxIcon(true, accent, accent, Qt::white, tag);
// 选中底/字取语义令牌,与全局树/列表选中一致规范§6.1/§10
const QString selBg = geopro::app::token("bg/selected");
const QString selFg = geopro::app::token("text/primary");
tree_->setStyleSheet(QStringLiteral("QTreeView::indicator{ width:16px; height:16px; }"
"QTreeView::indicator:unchecked{ image:url(%1); }"
"QTreeView::indicator:checked{ image:url(%2); }"
"QTreeView::item:selected{ background:%3; color:%4; }"
"QTreeView::item:selected:!active{ background:%3; color:%4; }")
.arg(off, on, selBg, selFg));
};
applyCheckboxStyle();
QObject::connect(&ThemeManager::instance(), &ThemeManager::changed, tree_,
[applyCheckboxStyle]() { applyCheckboxStyle(); });
lay->addWidget(tree_, 1); lay->addWidget(tree_, 1);
hint_ = new QLabel(QStringLiteral("正在加载对象…"), this); hint_ = new QLabel(QStringLiteral("正在加载对象…"), this);