fix(ui): address PR review controls and material lifecycle

This commit is contained in:
阿白叔 committed 2026-10-31 14:22:04 +08:00
1 parent a41c6cf928
commit 6f9f820f85
14 files changed
+295 -32

No files matched your search

@@ -0,0 +1,27 @@
{
"cad_started": false,
"sample_data_only": true,
"ownership_checked": true,
"os_build": 26200,
"native_enabled": true,
"sidebar_backdrop_difference": 21.82010089789873,
"opaque_table_backdrop_difference": 0.0,
"right_header_backdrop_difference": 9.299740913465097,
"right_execution_backdrop_difference": 12.328983050847457,
"visible_search_feedback": true,
"empty_search_feedback": true,
"solid_sidebar_mean": [
233.0,
238.0,
244.0
],
"solid_fallback": true,
"compact_size": [
980,
700
],
"compact_table_height": 197,
"force_stop_direct": true,
"force_stop_available_while_pausing": true,
"options_exposed": true
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 659 KiB

@@ -0,0 +1,33 @@
# PR #10 审查修复(2026-10-31)
对应 [审查评论 #110](https://git.simgreek.com/Skyworth_Digital_Hardware/dxdesigner-part-replacement/pulls/10#issuecomment-110)。本次在独立检出中处理,主工作区未提交的 DSH 生命周期文件未带入提交或测试环境。
## 范围和基线
原 PR 标题/说明只覆盖 UI,但相对 main 的差异实际还包含 DSH 助手核心、Harness 集成、异常诊断、受控重试、工单上报及对应打包配置。现采用评论允许的“完整声明范围”方案:更新 PR 标题和说明,列出子系统、安全边界、安装依赖、验收命令和部署限制。PR #11 基于本分支继续扩展监管闭环;其新增能力与审查问题不作为本次完成项。
最新 main `2cf526e` 已通过合并提交 `a41c6cf` 进入本分支。这样无需改写已发布历史及下游 PR 的基线。唯一冲突位于 `main_window.py` 的执行门禁:保留 main 的 `ResourceStatus` 异步检查、未知资源状态阻断及清理按钮条件,同时保留 UI 的活动单元格 dirty 检查。`batch_runtime.py`、`supervisor_evidence.py` 和 `ui/resource_status.py` 与该 main 一致,主线的身份、快照、active_task 落盘和诊断保留修复没有被覆盖。
## 逐项处理
| 审查项 | 处理 |
| --- | --- |
| P1 范围声明不完整 | 完整声明 DSH 核心与 Acrylic UI 的实际范围和边界 |
| P1 落后 main 且冲突 | 合入 main,联合保留资源状态与单元格门禁,在独立检出重跑回归 |
| P2 强制结束入口隐藏 | 执行期间直接显示在主按钮行;安全暂停请求后仍可使用;确认和核验保护不变 |
| P3 原生材质接口依赖 | 在用户文档中明确未文档化 accent API、Win11 DWM 实验结果、支持矩阵及未覆盖环境 |
| P3 回退色硬编码 | `theme.py` 与 QSS 共用默认色;系统高对比度下停用自定义样式并使用系统调色板,退出后恢复原样式 |
| P3 两秒策略轮询 | 降至 30 秒;显示、激活与系统调色板事件仍触发检查,隐藏窗口不轮询策略 |
| P3 菜单注册时清除 hidden | 保留注册前明确设置的隐藏状态,首次同步前动作也不可见,触发时继续核对状态 |
独立复核另发现高对比度通用 QSS 被 `#taskSearch` 等规则覆盖,导致浅底浅字;已改为高对比度期间撤下整套样式,补测聚焦搜索框、工程标题及任务文字的实际颜色。完整测试还发现窗口销毁后排队的材质回调访问已删除 HWND;已绑定 `QTimer.singleShot` 的 QObject context,并增加 `isValid` 检查和销毁回归。
## 验证范围
- 审查点名的 `test_safe_user_stop.py`、`test_batch_runtime.py`、`test_missing_uid_inventory.py`、`test_supervisor_evidence.py`:80 项通过。
- 材质、菜单、强制结束与安全暂停专项:26 项通过。
- 完整合并后回归:`python -m pytest -q tests/v1_1 tests/ui tests/dsh tests/packaging --junitxml=build/pr10-review-tests.xml`,**1086 passed**,无忽略项,1 条已有 pywinauto COM 模式警告;见[结果摘要](pr10-review-tests.json)。
- 原生验收:`python tools/accept_acrylic_ui.py --output build/pr10-review-controls-final`。临时示例数据,无 CAD/真实模型/远端工单调用。通过原生 Acrylic、实色表格、透明度回退、搜索、980×700 与执行/暂停控制入口验证;见 [JSON](pr10-review-acceptance.json)。执行按钮截图只预览 UI 状态,未派发执行 worker。
- 本轮未重新构建 EXE,也未重新做真实模型、真实工单或 CAD 写入验收;DSH 真实集成的历史证据位于 `docs/testing/2026-10-30-dsh-*.md`。
![980×700 执行控制预览](pr10-review-executing.png)
@@ -0,0 +1,14 @@
{
"command": "python -m pytest -q tests/v1_1 tests/ui tests/dsh tests/packaging --junitxml=build/pr10-review-tests.xml",
"tests": 1086,
"failures": 0,
"errors": 0,
"skipped": 0,
"seconds": 193.561,
"main_base": "2cf526e1769f354cd7e57861c4b0df9f165565dd",
"isolated_checkout": true,
"test_exclusions": [],
"warnings": [
"pywinauto: Revert to STA COM threading mode"
]
}
+16 -1
View File
@@ -10,6 +10,21 @@
本机验证环境为 Windows 11 build 26200、125% 缩放。Windows 10、其他显卡/驱动、多显示器、远程会话和打包后的原生效果仍需要相应环境验收,不能只根据系统接口返回成功判断视觉效果。
任务侧栏顶部提供新建,底部 **任务管理** 菜单提供编辑、恢复、顺序调整与删除。排序从任务数量旁的图标菜单选择。位号工具栏合并搜索、BOM 导入与采集;保存计划位于表格底部。执行区右上角的更多菜单保留诊断、资源清理、轮次证据、布局与强制结束入口,动作仍受原有状态检查与确认控制。
任务侧栏顶部提供新建,底部 **任务管理** 菜单提供编辑、恢复、顺序调整与删除。排序从任务数量旁的图标菜单选择。位号工具栏合并搜索、BOM 导入与采集;保存计划位于表格底部。执行区右上角的更多菜单保留诊断、资源清理、轮次证据与布局入口。执行期间,**完成当前项后暂停** 和 **强制结束…** 直接显示在主按钮行;请求安全暂停后,强制结束入口仍保留。强制结束继续要求确认并保留中断核验保护。
搜索使用 `Ctrl+F`,`F3` 跳至下一条,`Ctrl+S` 保存位号计划。搜索会显示匹配数量,清空后恢复全部行;过滤不改变真实执行范围。蓝色行选中用于批量填写,替换复选框才决定计划中的替换项。保存前会提交正在编辑的单元格,按 `Esc` 可取消当前单元格编辑。
## 材质接口与支持矩阵
当前原生模糊使用未文档化的 `SetWindowCompositionAttribute` / `WCA_ACCENT_POLICY=19`(Accent state 4)。这是一项 Windows 兼容性依赖,系统接口返回成功并不能保证每种驱动/窗口状态都有相同外观。Win11 的 `DwmSetWindowAttribute(SYSTEMBACKDROP_TYPE)` 在早期隔离 Qt 对照实验中没有产生预期背景模糊,因此当前没有自动切换到该路径;实验和开源参考见 `docs/reviews/2026-10-30-ui/github-material-research.md`。
| 环境 | 当前行为与验证范围 |
| --- | --- |
| Windows 11 build 26200,125% 缩放,普通窗口 | 已验证原生背景变化、实色表格、减少透明度和 980×700 布局 |
| Windows 10 build 17763 及以上、其他 Windows 11 build/驱动 | 满足策略条件时尝试 Acrylic;原生 API 失败时使用实色;仍需对应设备视觉验收 |
| 最大化、跨显示器、不同 DPI、显卡驱动切换 | 不承诺上述单机验证结果;如出现黑边或模糊异常,可使用“减少透明度”切回实色 |
| 远程会话、系统关闭透明效果 | 禁用 Acrylic,使用实色 |
| Windows 高对比度 | 禁用 Acrylic;窗口回退绘制与基础控件表面使用 Qt 系统调色板 |
| 非 Windows、旧版 Windows、不支持原生 API | 使用实色,不尝试窗口模糊 |
显示、重新激活窗口和系统调色板事件会重新检查策略;窗口可见时另每 30 秒检查一次,隐藏时不读取注册表/SPI。默认实色背景由 `ui/theme.py` 与 QSS 共用,避免窗口绘制和控件背景色分离。当前没有提供独立的深色主题。
@@ -1,4 +1,5 @@
"""Menu presentation for existing buttons, preserving their live business gates."""
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QMenu,QWidget
@@ -12,10 +13,15 @@ class CommandMenu(QMenu):
self.aboutToShow.connect(self.sync)
def add_button(self,button):
explicitly_hidden = (button.isHidden() and
button.testAttribute(Qt.WidgetAttribute.WA_WState_ExplicitShowHide))
button.setParent(self.storage)
# Only the parent is hidden. Explicit visibility remains the state gate.
button.show()
# Reparenting hides even new, unshown buttons. Preserve an explicit
# business hide, while allowing ordinary newly constructed commands.
button.setVisible(not explicitly_hidden)
action=self.addAction(button.text())
action.setEnabled(button.isEnabled())
action.setVisible(not button.isHidden())
def invoke():
if button.isEnabled() and not button.isHidden():
button.click()
@@ -10,8 +10,10 @@ from ctypes import wintypes
import sys
from PySide6.QtCore import QEvent, QObject, QTimer, Qt
from PySide6.QtGui import QColor, QGuiApplication, QPainter
from PySide6.QtGui import QColor, QGuiApplication, QPainter, QPalette
from PySide6.QtWidgets import QMainWindow
from shiboken6 import isValid
from .theme import WINDOW_BACKGROUND
class MaterialMainWindow(QMainWindow):
@@ -19,7 +21,9 @@ class MaterialMainWindow(QMainWindow):
def paintEvent(self, event):
if not self.property('acrylicEnabled'):
painter = QPainter(self)
painter.fillRect(event.rect(), QColor('#edf1f5'))
color = (self.palette().color(QPalette.ColorRole.Window)
if self.property('highContrastFallback') else QColor(WINDOW_BACKGROUND))
painter.fillRect(event.rect(), color)
painter.end()
super().paintEvent(event)
@@ -30,6 +34,19 @@ class WindowsAcrylic:
if sys.platform == 'win32':
self._user = ctypes.WinDLL('user32', use_last_error=True)
def high_contrast(self) -> bool:
if self._user is None:
return False
class HighContrast(ctypes.Structure):
_fields_ = [('size', wintypes.UINT), ('flags', wintypes.DWORD),
('scheme', wintypes.LPWSTR)]
contrast = HighContrast()
contrast.size = ctypes.sizeof(contrast)
if not self._user.SystemParametersInfoW(0x0042, contrast.size,
ctypes.byref(contrast), 0):
raise OSError('Cannot read Windows high-contrast policy')
return bool(contrast.flags & 1)
def available(self) -> bool:
if self._user is None or QGuiApplication.platformName() != 'windows':
return False
@@ -37,15 +54,7 @@ class WindowsAcrylic:
return False
try:
import winreg
class HighContrast(ctypes.Structure):
_fields_ = [('size', wintypes.UINT), ('flags', wintypes.DWORD),
('scheme', wintypes.LPWSTR)]
contrast = HighContrast()
contrast.size = ctypes.sizeof(contrast)
if not self._user.SystemParametersInfoW(0x0042, contrast.size,
ctypes.byref(contrast), 0):
return False
if contrast.flags & 1 or self._user.GetSystemMetrics(0x1000):
if self.high_contrast() or self._user.GetSystemMetrics(0x1000):
return False
try:
with winreg.OpenKey(winreg.HKEY_CURRENT_USER,
@@ -92,18 +101,20 @@ class AcrylicController(QObject):
self._enabled = False
self._handle = None
self._signature = None
self._normal_stylesheet = None
window.setProperty('acrylicEnabled', False)
window.setProperty('highContrastFallback', False)
# Set up an alpha surface before creating HWND; keep the native frame.
if QGuiApplication.platformName() == 'windows':
window.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
window.installEventFilter(self)
self._timer = QTimer(self)
self._timer.setInterval(2000)
self._timer.setInterval(30000)
self._timer.timeout.connect(self._poll)
self._timer.start()
def _poll(self):
if self.window.isVisible():
if isValid(self.window) and self.window.isVisible():
self.refresh()
def set_reduced_transparency(self, reduced: bool):
@@ -113,18 +124,31 @@ class AcrylicController(QObject):
def _surface(self, enabled, *, repaint=True):
self._enabled = bool(enabled)
self.window.setProperty('acrylicEnabled', bool(enabled))
# Dynamic ancestor selectors affect chrome children as well as the root.
self.window.setStyleSheet(self.window.styleSheet())
# Named/focused controls override generic palette selectors. Removing
# the custom sheet lets Qt honor the system palette for every control.
if self.window.property('highContrastFallback'):
if self._normal_stylesheet is None:
self._normal_stylesheet = self.window.styleSheet()
self.window.setStyleSheet('')
else:
stylesheet = (self._normal_stylesheet if self._normal_stylesheet is not None
else self.window.styleSheet())
self._normal_stylesheet = None
self.window.setStyleSheet(stylesheet)
if repaint:
self.window.update()
def refresh(self):
if not isValid(self) or not isValid(self.window):
return
try:
allowed = not self.reduced and self.backend.available()
high_contrast = bool(getattr(self.backend, 'high_contrast', lambda: False)())
allowed = not self.reduced and not high_contrast and self.backend.available()
except (OSError, AttributeError):
high_contrast = True # An unreadable policy must keep a solid surface.
allowed = False
handle = int(self.window.winId()) if allowed else self._handle
signature = (handle, allowed)
signature = (handle, allowed, high_contrast)
if signature == self._signature:
return
self._signature = signature
@@ -134,6 +158,8 @@ class AcrylicController(QObject):
updates_enabled = self.window.updatesEnabled()
self.window.setUpdatesEnabled(False)
try:
contrast_changed = self.window.property('highContrastFallback') != high_contrast
self.window.setProperty('highContrastFallback', high_contrast)
if self._enabled:
# Paint opaque before removing native blur; avoids an unreadable alpha surface.
self._surface(False, repaint=False)
@@ -143,6 +169,8 @@ class AcrylicController(QObject):
pass
self._handle = handle
if not allowed:
if contrast_changed:
self._surface(False, repaint=False)
return
try:
enabled = self.backend.enable(handle)
@@ -161,6 +189,6 @@ class AcrylicController(QObject):
def eventFilter(self, watched, event):
if event.type() in (QEvent.Type.Show, QEvent.Type.WinIdChange,
QEvent.Type.WindowActivate):
QTimer.singleShot(0, self.refresh)
QEvent.Type.WindowActivate, QEvent.Type.ApplicationPaletteChange):
QTimer.singleShot(0, self, self.refresh)
return super().eventFilter(watched, event)
@@ -49,11 +49,9 @@ class RunPanel(QWidget):
self.more_menu=CommandMenu(self)
for button in (self.diagnostics_button,self.cleanup_resources_button,self.history_button,self.reset_layout_button):
self.more_menu.add_button(button)
self.more_menu.addSeparator()
self.more_menu.add_button(self.force_stop_button)
self.more_button=QToolButton(objectName='executionMoreMenu')
self.more_button.setText('更多操作')
self.more_button.setToolTip('诊断、轮次证据、布局与异常操作')
self.more_button.setToolTip('诊断、资源清理、轮次证据与布局')
self.more_button.setIcon(icon('more'))
self.more_button.setMenu(self.more_menu)
self.more_button.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup)
@@ -65,7 +63,7 @@ class RunPanel(QWidget):
heading.addWidget(self.more_button)
buttons=QHBoxLayout()
buttons.addWidget(self.operator_band,1)
for button in (self.retry_button,self.recover_button,self.new_round_button,self.stop_queue_button,self.quick_run_button):
for button in (self.retry_button,self.recover_button,self.new_round_button,self.stop_queue_button,self.force_stop_button,self.quick_run_button):
buttons.addWidget(button)
layout = QVBoxLayout(self)
layout.setContentsMargins(12,8,12,9)
@@ -1,8 +1,9 @@
"""Frosted window chrome and opaque, readable engineering data surfaces."""
from .theme import WINDOW_BACKGROUND
APP_STYLESHEET = """
QWidget { background: transparent; color: #344359; font-family: "Segoe UI", "Microsoft YaHei UI"; font-size: 13px; }
QMainWindow { background: #edf1f5; }
QMainWindow { background: @WINDOW_BACKGROUND@; }
QMainWindow[acrylicEnabled="true"] { background: transparent; }
QDialog, QMessageBox, QMenu { background: #f8fafc; }
QToolTip { background: #ffffff; color: #344359; border: 1px solid #ccd6e2; padding: 5px; }
@@ -108,4 +109,4 @@ QTableView { outline: none; }
QTableView::item:selected { background: #e6eef8; color: #294969; }
QTableView::item:focus { border: 1px solid #9bb3d0; }
QToolButton[appearance="quiet"]:checked { background: rgba(255,255,255,155); border-color: rgba(255,255,255,220); color: #3f638e; }
"""
""".replace('@WINDOW_BACKGROUND@', WINDOW_BACKGROUND)
@@ -7,7 +7,7 @@ import re
from typing import Iterable
from PySide6.QtCore import Qt, QSignalBlocker, Signal, QSize, QRect
from PySide6.QtGui import QColor,QFont,QIcon
from PySide6.QtGui import QColor,QFont,QIcon,QPalette
from PySide6.QtWidgets import (QComboBox,QHBoxLayout,QLabel,QLineEdit,QListWidget,
QListWidgetItem,QPushButton,QVBoxLayout,QWidget,QToolButton,QMenu,
QStyledItemDelegate,QStyleOptionViewItem,QStyle,QApplication)
@@ -34,19 +34,23 @@ class TaskItemDelegate(QStyledItemDelegate):
style=option.widget.style()if option.widget else QApplication.style()
style.drawControl(QStyle.ControlElement.CE_ItemViewItem,opt,painter,option.widget)
painter.save()
high_contrast=bool(option.widget and option.widget.window().property('highContrastFallback'))
system_text=opt.palette.color(QPalette.ColorRole.HighlightedText
if option.state&QStyle.StateFlag.State_Selected else QPalette.ColorRole.Text)
rect=option.rect.adjusted(12,11,-12,-10)
picture.paint(painter,QRect(rect.left(),rect.top()+7,20,20))
left=rect.left()+31;available=rect.right()-left-(24 if order else 0)
font=QFont(option.font);font.setWeight(QFont.Weight.DemiBold);painter.setFont(font)
painter.setPen(QColor('#35577d')if option.state&QStyle.StateFlag.State_Selected else QColor('#526983'))
painter.setPen(system_text if high_contrast else
QColor('#35577d')if option.state&QStyle.StateFlag.State_Selected else QColor('#526983'))
label=painter.fontMetrics().elidedText(name,Qt.TextElideMode.ElideRight,available)
painter.drawText(QRect(left,rect.top(),available,23),Qt.AlignmentFlag.AlignVCenter,label)
font.setWeight(QFont.Weight.Normal);font.setPointSizeF(max(8,option.font.pointSizeF()-1));painter.setFont(font)
colors={'执行中':'#8a744d','失败':'#a15f59','已完成':'#638775','待执行':'#6b8ba8'}
painter.setPen(QColor(colors.get(status,'#8999ac')))
painter.setPen(system_text if high_contrast else QColor(colors.get(status,'#8999ac')))
painter.drawText(QRect(left,rect.top()+27,available,19),Qt.AlignmentFlag.AlignVCenter,status)
if order:
painter.setPen(QColor('#94a4b8'))
painter.setPen(system_text if high_contrast else QColor('#94a4b8'))
painter.drawText(QRect(rect.right()-20,rect.top()+2,20,19),Qt.AlignmentFlag.AlignRight,order)
painter.restore()
@@ -0,0 +1,3 @@
"""Shared colors for Qt styling and native-window fallback painting."""
WINDOW_BACKGROUND = '#edf1f5'
+82
View File
@@ -93,6 +93,19 @@ def test_repeated_refresh_does_not_reconfigure_composition(qtbot):
assert len(backend.calls)==1
def test_deferred_material_refresh_never_uses_a_destroyed_window(qtbot,qapp):
from PySide6.QtCore import QCoreApplication,QEvent
window=QWidget() # This test owns destruction rather than pytest-qt teardown.
backend=Backend()
controller=AcrylicController(window,backend=backend)
controller.eventFilter(window,QEvent(QEvent.Type.WindowActivate))
window.deleteLater()
QCoreApplication.sendPostedEvents(None,QEvent.Type.DeferredDelete)
controller.refresh()
qapp.processEvents()
assert not backend.calls
def test_backend_exception_uses_solid_surface(qtbot):
window=QWidget();qtbot.addWidget(window)
class Broken(Backend):
@@ -158,3 +171,72 @@ def test_real_window_has_svg_controls_and_persistent_material_preference(ui):
image=window.plan_panel.table.viewport().grab().toImage()
color=image.pixelColor(image.width()-8,image.height()-8)
assert color.alpha()==255 and min(color.red(),color.green(),color.blue())>=245
@pytest.mark.parametrize('reduced',[False,True])
def test_high_contrast_fallback_uses_window_palette_and_tracks_policy_change(qtbot,qapp,request,reduced):
from PySide6.QtGui import QColor,QPalette
from PySide6.QtWidgets import QLabel,QLineEdit
from dx_productivity.trial_task_center.ui.material import MaterialMainWindow
from dx_productivity.trial_task_center.ui.styles import APP_STYLESHEET
original_palette=qapp.palette()
request.addfinalizer(lambda:qapp.setPalette(original_palette))
palette=QPalette(original_palette)
palette.setColor(QPalette.ColorRole.Window,QColor('#181818'))
palette.setColor(QPalette.ColorRole.WindowText,QColor('#fafafa'))
palette.setColor(QPalette.ColorRole.Base,QColor('#181818'))
palette.setColor(QPalette.ColorRole.Text,QColor('#fafafa'))
qapp.setPalette(palette)
window=MaterialMainWindow();qtbot.addWidget(window)
window.setStyleSheet(APP_STYLESHEET)
search=QLineEdit('Readable query',window,objectName='taskSearch')
search.setGeometry(30,30,180,30)
title=QLabel('Project name',window,objectName='projectTitle')
class ContrastBackend(Backend):
contrast=True
def high_contrast(self):return self.contrast
def available(self):return not self.contrast
backend=ContrastBackend()
controller=AcrylicController(window,backend=backend)
controller.set_reduced_transparency(reduced)
controller.refresh()
window.resize(240,160);window.show()
assert window.property('highContrastFallback')
assert not window.property('acrylicEnabled')
color=window.grab().toImage().pixelColor(10,10)
assert color==QColor('#181818')
search.setFocus()
assert search.palette().color(QPalette.ColorRole.Base)==QColor('#181818')
assert search.palette().color(QPalette.ColorRole.Text)==QColor('#fafafa')
assert title.palette().color(QPalette.ColorRole.WindowText)==QColor('#fafafa')
backend.contrast=False
controller.refresh()
assert not window.property('highContrastFallback')
assert window.property('acrylicEnabled') is not reduced
assert window.styleSheet()==APP_STYLESHEET
@pytest.mark.parametrize('selected',[False,True])
def test_high_contrast_task_titles_render_with_system_text_colors(qtbot,selected):
from PySide6.QtCore import QRect,Qt
from PySide6.QtGui import QColor,QImage,QPainter,QPalette,QStandardItem,QStandardItemModel
from PySide6.QtWidgets import QListWidget,QStyle,QStyleOptionViewItem
from dx_productivity.trial_task_center.ui.task_list import TaskItemDelegate
window=QWidget();qtbot.addWidget(window)
window.setProperty('highContrastFallback',True)
listing=QListWidget(window)
model=QStandardItemModel();model.appendRow(QStandardItem('01. Board Name\nReady'))
option=QStyleOptionViewItem();option.widget=listing
option.rect=QRect(0,0,220,76);option.font=listing.font()
option.state=QStyle.StateFlag.State_Enabled
palette=QPalette(listing.palette())
palette.setColor(QPalette.ColorRole.Text,QColor('#ffff00'))
palette.setColor(QPalette.ColorRole.HighlightedText,QColor('#00ff00'))
option.palette=palette
if selected:option.state|=QStyle.StateFlag.State_Selected
picture=QImage(220,76,QImage.Format.Format_ARGB32);picture.fill(QColor('#000000'))
painter=QPainter(picture)
TaskItemDelegate(listing).paint(painter,option,model.index(0,0));painter.end()
expected=QColor('#00ff00'if selected else'#ffff00')
# Check actual painted title glyphs, not only the widget's palette property.
assert sum(picture.pixelColor(x,y)==expected for x in range(43,190)for y in range(11,34))>5
+38
View File
@@ -59,3 +59,41 @@ def test_redesign_small_window_keeps_save_and_execute_visible(ui,qtbot):
for button in [window.plan_panel.save_button,window.run_panel.quick_run_button,window.task_list.new_button]:
rect=button.rect();point=button.mapTo(window,rect.bottomRight())
assert point.x()<window.width()and point.y()<window.height()
def test_menu_keeps_command_hidden_before_registration(qtbot):
from dx_productivity.trial_task_center.ui.command_menu import CommandMenu
owner=QWidget();qtbot.addWidget(owner)
button=QPushButton('Hidden command',owner)
button.hide()
called=[];button.clicked.connect(lambda:called.append(True))
menu=CommandMenu(owner)
action=menu.add_button(button)
assert button.isHidden()
assert not action.isVisible()
menu.sync();action.trigger()
assert not called
button.show();menu.sync();action.trigger()
assert action.isVisible() and called==[True]
def test_force_stop_is_directly_visible_during_execution_at_minimum_size(ui,qtbot):
window=ui.window
window._begin_run(ui.tasks[0].task_id)
window._update_gates()
try:
window.resize(980,700);qtbot.wait(30)
run=window.run_panel
assert run.force_stop_button.parent() is run
assert run.force_stop_button.isVisible()
assert run.force_stop_button.isEnabled()
assert run.stop_queue_button.isVisible()
for button in (run.force_stop_button,run.stop_queue_button):
point=button.mapTo(window,button.rect().bottomRight())
assert 0<=point.x()<window.width() and 0<=point.y()<window.height()
window._pause_queue()
assert run.force_stop_button.isVisible() and run.force_stop_button.isEnabled()
finally:
window._finish_run()
window._update_gates()
assert not window.run_panel.force_stop_button.isVisible()
+14
View File
@@ -142,6 +142,20 @@ def main():
report['compact_table_height']=window.plan_panel.table.viewport().height()
assert report['compact_size']==[980,700]
assert report['compact_table_height']>=100
# Preview UI gates with an owned StopControl; never dispatch a worker.
window._begin_run(tasks[0].task_id);window._update_gates();settle(.2)
report['force_stop_direct']=window.run_panel.force_stop_button.isVisible()
assert report['force_stop_direct']
assert window.run_panel.force_stop_button.parent() is window.run_panel
for button in (window.run_panel.stop_queue_button,window.run_panel.force_stop_button):
point=button.mapTo(window,button.rect().bottomRight())
assert 0<=point.x()<window.width() and 0<=point.y()<window.height()
capture('native-app-executing-controls')
window._pause_queue();settle(.2)
report['force_stop_available_while_pausing']=window.run_panel.force_stop_button.isEnabled()
assert report['force_stop_available_while_pausing']
capture('native-app-pausing-controls')
window._finish_run();window._update_gates()
window.project_options_button.setChecked(True);settle(.2)
report['options_exposed']=window.run_panel.copy_value_check.isVisible()
window.plan_panel.discard_all();window.close();settle(.3);store.close();logging.shutdown()