refactor(theme): 全部项目对话框迁移令牌 + 清理委托接管后失效的列表选中/前景死代码

This commit is contained in:
gaozheng 2026-06-10 17:02:03 +08:00
parent b78969471e
commit 2a666663e7
3 changed files with 6 additions and 28 deletions

View File

@ -28,11 +28,11 @@ QString statusText(int s) {
}
// 状态语义色(寻路):未开始=弱化中性、进行中=信息蓝(活动中);未知状态用中性灰。
const char* statusColorHex(int s) {
QColor statusColor(int s) {
switch (s) {
case 1: return "#8A93A3"; // 未开始:弱化
case 2: return semantic::kInfo; // 进行中:活动中
default: return "#5A6B85"; // 未知:中性
case 1: return tokenColor("text/tertiary"); // 未开始:弱化
case 2: return tokenColor("accent/primary"); // 进行中:活动中
default: return tokenColor("text/secondary"); // 未知:中性
}
}
} // namespace
@ -155,12 +155,12 @@ void ProjectListDialog::query() {
set(0, QString::number((pageNo_ - 1) * pageSize_ + i + 1));
auto* nameItem = new QTableWidgetItem(QString::fromStdString(p.name));
nameItem->setData(Qt::UserRole, QString::fromStdString(p.id));
nameItem->setForeground(QColor("#2D6CB5"));
nameItem->setForeground(tokenColor("accent/primary"));
table_->setItem(i, 1, nameItem);
set(2, QString::fromStdString(p.code));
// 状态列语义着色:颜色承载“未开始/进行中”分类,进行中加粗强调(不只靠颜色)。
auto* statusItem = new QTableWidgetItem(statusText(p.status));
statusItem->setForeground(QColor(statusColorHex(p.status)));
statusItem->setForeground(statusColor(p.status));
if (p.status == 2) {
QFont f = statusItem->font();
f.setBold(true);

View File

@ -523,31 +523,12 @@ void buildWorkbench(QMainWindow& window, geopro::data::LocalSampleRepository& re
{{geopro::app::Glyph::Plus, QStringLiteral("新建对象")}}));
auto* leftArea = dockManager->addDockWidget(ads::LeftDockWidgetArea, leftDock);
// 列表选中色:写死的强调蓝(明 #C2D9F2 / 暗 #33527A+ 适配文字,:!active 防失焦变淡;
// 与对象树选中色一致。本地 QSS 覆盖全局弱选中色,随主题重设。
auto applyListSelection = [](QListWidget* lw) {
auto styleIt = [lw]() {
const bool dark = geopro::app::isDarkTheme();
const QString selBg = dark ? QStringLiteral("#33527A") : QStringLiteral("#C2D9F2");
const QString selFg = dark ? QStringLiteral("#E8F1FB") : QStringLiteral("#14385F");
lw->setStyleSheet(QStringLiteral("QListWidget::item:selected{ background:%1; color:%2; }"
"QListWidget::item:selected:!active{ background:%1;"
" color:%2; }")
.arg(selBg, selFg));
};
styleIt();
QObject::connect(&geopro::app::ThemeManager::instance(), &geopro::app::ThemeManager::changed,
lw, [styleIt]() { styleIt(); });
};
// 左下 dock数据真实显示栏(选中测线后列其采集批次=数据集;tab 数据/文件)。
auto* datasetTabs = new QTabWidget();
auto* datasetList = new QListWidget();
applyListSelection(datasetList);
geopro::app::applyDatasetCardDelegate(datasetList);
datasetTabs->addTab(datasetList, QStringLiteral("数据"));
auto* fileList = new QListWidget();
applyListSelection(fileList);
geopro::app::applyDatasetCardDelegate(fileList);
datasetTabs->addTab(fileList, QStringLiteral("文件"));
auto* datasetDock = new ads::CDockWidget(QStringLiteral("数据真实显示栏"));
@ -562,7 +543,6 @@ void buildWorkbench(QMainWindow& window, geopro::data::LocalSampleRepository& re
// 右上 dock异常列表 / 对象属性 合并为带 Tab 表头的面板(对齐原型上半)。
auto* anomalyList = new QListWidget();
applyListSelection(anomalyList);
geopro::app::applyAnomalyCardDelegate(anomalyList);
auto* objAttrLabel = new QLabel(QStringLiteral("(选中对象后显示其属性)"));
objAttrLabel->setWordWrap(true);
@ -899,7 +879,6 @@ void buildWorkbench(QMainWindow& window, geopro::data::LocalSampleRepository& re
auto* m = new QListWidgetItem(QStringLiteral("加载更多(%1/%2").arg(loaded).arg(total), lw);
m->setData(geopro::app::kDsLoadMoreRole, true);
m->setTextAlignment(Qt::AlignCenter);
m->setForeground(QColor("#2D6CB5"));
}
return loaded;
};

View File

@ -125,7 +125,6 @@ void populateFileList(QListWidget* list, const std::vector<geopro::data::DsRow>&
if (!append && rows.empty()) {
auto* hint = new QListWidgetItem(QStringLiteral("(暂无文件)"), list);
hint->setFlags(Qt::NoItemFlags);
hint->setForeground(QColor("#9AA6B6"));
hint->setTextAlignment(Qt::AlignCenter);
return;
}