From 4d4347e50e919e5a0be71b31be23a793323e80a7 Mon Sep 17 00:00:00 2001 From: ila Date: Sat, 4 Jul 2026 17:59:25 +0800 Subject: [PATCH] feat: color ai outfit detail statuses --- src/app/widgets/ai_outfit_panel.py | 17 +++++++++++++++-- tasks.md | 25 +++++++++++++++++++++++++ tests/test_ai_outfit_panel.py | 19 +++++++++++++++++++ 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/src/app/widgets/ai_outfit_panel.py b/src/app/widgets/ai_outfit_panel.py index e6f16fe..02ea2d7 100644 --- a/src/app/widgets/ai_outfit_panel.py +++ b/src/app/widgets/ai_outfit_panel.py @@ -10,7 +10,7 @@ import logging import time from PySide6.QtCore import QObject, QSize, Qt, QThread, QTimer, QUrl, Signal -from PySide6.QtGui import QDesktopServices, QIcon, QPixmap +from PySide6.QtGui import QBrush, QColor, QDesktopServices, QIcon, QPixmap from PySide6.QtWidgets import ( QAbstractItemView, QCheckBox, @@ -61,6 +61,14 @@ _TITLE_WAIT_COLORS = { "success": "#107c10", "error": "#c42b1c", } +_DETAIL_STATUS_COLORS = { + "待处理": "#666666", + "生成中": "#0078d4", + "完成": "#107c10", + "失败": "#c42b1c", + "跳过": "#8a8a8a", + "停止": "#8a8a8a", +} # --------------------------------------------------------------------------- # Background worker @@ -1417,7 +1425,12 @@ class AiOutfitPanel(QWidget): max(0, done), max(0, failed), max(0, pending))) def _set_cell(self, row, col, text): - self._table.setItem(row, col, QTableWidgetItem(str(text))) + item = QTableWidgetItem(str(text)) + if col == 4: + color = _DETAIL_STATUS_COLORS.get(str(text)) + if color: + item.setForeground(QBrush(QColor(color))) + self._table.setItem(row, col, item) def statusBar_message(self, text): win = self.window() diff --git a/tasks.md b/tasks.md index 0477a70..4fd84f2 100644 --- a/tasks.md +++ b/tasks.md @@ -1725,3 +1725,28 @@ - [x] 文档明确异步任务、表格状态、低对比、配置错误可用状态色 - [x] 文档明确颜色不能作为唯一信息来源,必须配合文字状态 - [x] 文档检查:`rg -n "状态色|处理明细状态|标题生成等待计时|10.1" docs/07-ui-design.md docs/11-ai-outfit.md tasks.md`、`git diff --check -- docs/07-ui-design.md docs/11-ai-outfit.md tasks.md` + +### 19.37 AI 穿搭处理明细表状态色 — docs/07 §10.1 / docs/11 §10 + +前置阅读: + +- `docs/07-ui-design.md`(§10.1 状态色使用规则) +- `docs/11-ai-outfit.md`(§10 状态色应用) +- `src/app/widgets/ai_outfit_panel.py`(处理明细表 `_set_cell`) +- `tests/test_ai_outfit_panel.py`(AI 穿搭面板离屏测试) + +背景: + +§19.36 已明确 AI 穿搭页只给状态、风险和结果上色。标题等待计时已实现颜色,但处理中间的明细表「状态」列仍是默认黑色;生成多行标题或图片时,用户需要更快区分待处理、完成、失败和停止类状态。 + +任务: + +- [x] `ai_outfit_panel.py`:新增处理明细表状态色映射,沿用 `docs/07` §10.1 的灰 / 蓝 / 绿 / 红规则 +- [x] `ai_outfit_panel.py`:只在处理明细表「状态」列应用颜色,不给普通列、label、按钮、输入框装饰性上色 +- [x] `tests/test_ai_outfit_panel.py`:离屏断言 `待处理`、`生成中`、`完成`、`失败`、`跳过`、`停止` 使用对应颜色 + +验收: + +- [x] 明细表状态列可用颜色快速区分状态,同时保留文字作为主要信息 +- [x] 普通 UI 文本仍保持黑灰体系,不扩大颜色使用范围 +- [x] 验证:`python -m py_compile src/app/widgets/ai_outfit_panel.py tests/test_ai_outfit_panel.py`、`python tests/test_ai_outfit_panel.py` diff --git a/tests/test_ai_outfit_panel.py b/tests/test_ai_outfit_panel.py index a483520..8e55a15 100644 --- a/tests/test_ai_outfit_panel.py +++ b/tests/test_ai_outfit_panel.py @@ -91,6 +91,25 @@ class TestAiOutfitPanelDefaults(unittest.TestCase): self.assertLessEqual(panel._table.columnWidth(3), 90) self.assertLessEqual(panel._table.columnWidth(5), 130) + def test_detail_status_column_uses_semantic_colors(self): + from core.models import OutfitTask + + panel = self._panel() + task = OutfitTask(row_index=2, title="标题", product_id="SKU", garment_path="a.png") + panel._populate_table([task]) + + expected = { + "待处理": "#666666", + "生成中": "#0078d4", + "完成": "#107c10", + "失败": "#c42b1c", + "跳过": "#8a8a8a", + "停止": "#8a8a8a", + } + for status, color in expected.items(): + panel._set_cell(0, 4, status) + self.assertEqual(panel._table.item(0, 4).foreground().color().name(), color) + def test_title_group_present_no_dropdown_preview_removed(self): """标题生成组存在;无标题模型下拉(配置定名 §17.3);预览块已移除。""" from PySide6.QtWidgets import QLabel