fix: adjust outfit detail table widths

This commit is contained in:
2026-06-23 16:58:16 +08:00
parent 7313c8a443
commit 04bc587538
3 changed files with 50 additions and 4 deletions
+17 -3
View File
@@ -591,12 +591,26 @@ class AiOutfitPanel(QWidget):
self._table.setEditTriggers(QAbstractItemView.NoEditTriggers) self._table.setEditTriggers(QAbstractItemView.NoEditTriggers)
self._table.setSelectionBehavior(QAbstractItemView.SelectRows) self._table.setSelectionBehavior(QAbstractItemView.SelectRows)
self._table.verticalHeader().setVisible(False) self._table.verticalHeader().setVisible(False)
header = self._table.horizontalHeader() self._configure_detail_table_columns()
header.setSectionResizeMode(1, QHeaderView.Stretch)
header.setSectionResizeMode(5, QHeaderView.Stretch)
col.addWidget(self._table, stretch=1) col.addWidget(self._table, stretch=1)
return wrap return wrap
def _configure_detail_table_columns(self):
"""Give title most table space; keep short fields compact."""
header = self._table.horizontalHeader()
header.setStretchLastSection(False)
widths = {
0: 46, # 行
2: 88, # 货号
3: 150, # 衣服图
4: 76, # 状态
5: 220, # 结果 / 原因
}
for col, width in widths.items():
header.setSectionResizeMode(col, QHeaderView.Fixed if col in (0, 2, 4) else QHeaderView.Interactive)
self._table.setColumnWidth(col, width)
header.setSectionResizeMode(1, QHeaderView.Stretch)
def _build_right(self): def _build_right(self):
wrap = QWidget() wrap = QWidget()
wrap.setMinimumWidth(360) wrap.setMinimumWidth(360)
+19 -1
View File
@@ -1438,4 +1438,22 @@
- [x] `core/ai_outfit.py`:`generate_outfit_image(..., should_stop=None)` 透传;`_generate_directory_outfit` 改**有界提交**——始终最多 `image_concurrency` 张在飞,每张完成后、提交下一张前检查 `should_stop()`,已停止则停止提交剩余、让在飞收尾返回;结果 error 注明「已停止,N 张未生成」,`output_paths` 带已生成的;单文件行进入前检查一次 `should_stop()`(已停止→跳过结果) - [x] `core/ai_outfit.py`:`generate_outfit_image(..., should_stop=None)` 透传;`_generate_directory_outfit` 改**有界提交**——始终最多 `image_concurrency` 张在飞,每张完成后、提交下一张前检查 `should_stop()`,已停止则停止提交剩余、让在飞收尾返回;结果 error 注明「已停止,N 张未生成」,`output_paths` 带已生成的;单文件行进入前检查一次 `should_stop()`(已停止→跳过结果)
- [x] `ai_outfit_panel.py`:`_OutfitWorker.gen(task, should_stop)` 闭包接新参并透传 `generate_outfit_image`;`_stop()` 把 `停止生成` 文案改「停止中…」(保持禁用);`_set_running(False)` 复位文案为「停止生成」 - [x] `ai_outfit_panel.py`:`_OutfitWorker.gen(task, should_stop)` 闭包接新参并透传 `generate_outfit_image`;`_stop()` 把 `停止生成` 文案改「停止中…」(保持禁用);`_set_running(False)` 复位文案为「停止生成」
- [x] 测试:`test_ai_outfit.py` —— 目录行设 `should_stop` 在第 k 张后置真 → 之后不再新增生成、返回「已停止」结果且已生成的在 `output_paths`;`test_outfit_batch.py` —— 停止后不起新行、当前行提前返回、`finished` 及时;既有用例保持绿(注意 `generate_func` 新签名向后兼容/同步改 mock) - [x] 测试:`test_ai_outfit.py` —— 目录行设 `should_stop` 在第 k 张后置真 → 之后不再新增生成、返回「已停止」结果且已生成的在 `output_paths`;`test_outfit_batch.py` —— 停止后不起新行、当前行提前返回、`finished` 及时;既有用例保持绿(注意 `generate_func` 新签名向后兼容/同步改 mock)
- [x] 验证:相关单测 + 全套 py37 通过;离屏冒烟:mock 计数/慢 `generate`,开跑后置 stop → 总调用被 `should_stop` 截断、`finished` 及时、`_set_running(False)` 恢复「开始生成」、停止按钮文案回「停止生成」 - [x] 验证:相关单测 + 全套 py37 通过;离屏冒烟:mock 计数/慢 `generate`,开跑后置 stop → 总调用被 `should_stop` 截断、`finished` 及时、`_set_running(False)` 恢复「开始生成」、停止按钮文案回「停止生成」
### 19.25 AI 穿搭处理明细表列宽微调 — docs/11 §10
前置阅读:
- `docs/11-ai-outfit.md`(§10 界面)
- `docs/07-ui-design.md`(表格与工具型布局原则)
- `src/app/widgets/ai_outfit_panel.py`(`_build_center` / 处理明细表)
背景:
处理明细表中「行」「货号」「状态」等字段内容短,却占用过多横向空间;「标题」字段更长、更需要可读宽度。应缩小短字段列,把主要剩余宽度给「标题」。
任务:
- [x] `ai_outfit_panel.py`:新增处理明细表列宽配置;「行」「货号」「状态」固定窄列,「衣服图」「结果 / 原因」给可拖动默认宽度,「标题」使用 Stretch 占用剩余空间
- [x] `test_ai_outfit_panel.py`:补离屏测试,断言短字段列固定、标题列 Stretch
- [~] 验证:`python -m py_compile src/app/widgets/ai_outfit_panel.py`、`python tests/test_ai_outfit_panel.py`、离屏启动主窗口通过;全套 `python -m unittest discover -s tests` 当前被工作区未提交的 `packaging/default_config/ai_models.json` 改动阻塞(模型顺序/额外条目与出厂模板规范不一致),待清理该文件后重跑
+14
View File
@@ -73,6 +73,20 @@ class TestAiOutfitPanelDefaults(unittest.TestCase):
self.assertIn("图片并发数", labels) self.assertIn("图片并发数", labels)
def test_detail_table_compacts_short_columns_and_stretches_title(self):
from PySide6.QtWidgets import QHeaderView
panel = self._panel()
header = panel._table.horizontalHeader()
self.assertEqual(header.sectionResizeMode(0), QHeaderView.Fixed)
self.assertEqual(header.sectionResizeMode(2), QHeaderView.Fixed)
self.assertEqual(header.sectionResizeMode(4), QHeaderView.Fixed)
self.assertEqual(header.sectionResizeMode(1), QHeaderView.Stretch)
self.assertLessEqual(panel._table.columnWidth(0), 56)
self.assertLessEqual(panel._table.columnWidth(2), 100)
self.assertLessEqual(panel._table.columnWidth(4), 90)
def test_title_group_present_no_dropdown_preview_removed(self): def test_title_group_present_no_dropdown_preview_removed(self):
"""标题生成组存在;无标题模型下拉(配置定名 §17.3);预览块已移除。""" """标题生成组存在;无标题模型下拉(配置定名 §17.3);预览块已移除。"""
from PySide6.QtWidgets import QLabel from PySide6.QtWidgets import QLabel