Compare commits
3
Commits
v1.2.1
..
ba1d50cdfc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba1d50cdfc | ||
|
|
e9454cf01f | ||
|
|
dba01d42d0 |
No files matched your search
@@ -0,0 +1,18 @@
|
||||
# Issue #16: Acrylic after returning from the browser workspace
|
||||
|
||||
Scope: UI rendering only. Provider/model configuration, runtime protocol, tools and task operations are unchanged.
|
||||
|
||||
The browser workspace previously shared its native composition parent with the Acrylic main window. Showing a real QWebEngineView made the parent surface opaque; hiding the browser did not restore the live backdrop. The alpha-buffer size, transparency attribute and Acrylic property still reported enabled. Reapplying Windows composition alone did not fix the rendering.
|
||||
|
||||
The browser workspace now uses `WA_NativeWindow` so Chromium composes into its own child native surface. This keeps its opaque browser background separate from the task-center backdrop and retains the existing stacked-page navigation.
|
||||
|
||||
Validation on Windows 11 build 26200, 125% scaling:
|
||||
|
||||
- Regression test uses a real QWebEngineView and checks its native composition parent. It failed before the fix and passed afterward.
|
||||
- `python -m pytest -q tests/ui --tb=short --junitxml=build/issue16-ui-tests.xml`: **172 passed**.
|
||||
- `python tools/accept_acrylic_ui.py --output build/issue16-final --webengine-roundtrip`: passed. The test uses sample projects and an owned changing backdrop. It displays a local HTML page in real Chromium, without launching the Harness server, model requests or CAD.
|
||||
- Before the fix, changing the background after returning produced a sidebar pixel difference of **0.0**. After the fix, two consecutive round trips each produced **20.79** (threshold > 2); the solid table difference stayed **0.0** (threshold < 1.5).
|
||||
- With reduced transparency enabled, the same navigation produced a sidebar difference of **0.0** as expected. Search, empty results, solid fallback, 980×700 layout and visible stop controls also passed.
|
||||
- An initial focused run reported one existing Qt fixture teardown race (`TrialTaskCenterWindow already deleted`); the subsequent complete UI run passed without errors.
|
||||
|
||||
Screenshots and machine-readable results are local artifacts under `build/issue16-final/`. No release package was built. PR #15 is synchronized with main `3cec9ad`; unrelated main-workspace changes were left untouched.
|
||||
@@ -5,7 +5,7 @@ import json
|
||||
import codecs
|
||||
from pathlib import Path
|
||||
|
||||
from PySide6.QtCore import QProcess, QProcessEnvironment, QTimer, QUrl, Signal
|
||||
from PySide6.QtCore import QProcess, QProcessEnvironment, QTimer, QUrl, Signal, Qt
|
||||
from PySide6.QtWebEngineCore import QWebEnginePage, QWebEngineProfile, QWebEngineSettings
|
||||
from PySide6.QtWebEngineWidgets import QWebEngineView
|
||||
from PySide6.QtWidgets import QLabel, QPushButton, QVBoxLayout, QWidget
|
||||
@@ -37,6 +37,10 @@ class NativeHarnessView(QWidget):
|
||||
|
||||
def __init__(self, data_root: Path, parent=None):
|
||||
super().__init__(parent)
|
||||
# Give Chromium its own native composition boundary. Otherwise its
|
||||
# texture compositor turns the shared Acrylic top-level surface opaque,
|
||||
# even after this workspace is hidden again.
|
||||
self.setAttribute(Qt.WidgetAttribute.WA_NativeWindow)
|
||||
self.setObjectName('dshNativeWorkspace')
|
||||
self.setStyleSheet('QWidget#dshNativeWorkspace {background:white;}')
|
||||
self.data_root = Path(data_root)
|
||||
|
||||
@@ -30,6 +30,7 @@ def icon(name: str, primary: bool = False) -> QIcon:
|
||||
BUTTON_ICONS = {
|
||||
'task_center_navigation': 'grid', 'dsh_navigation': 'chat',
|
||||
'newTaskButton': 'plus', 'editTaskButton': 'sliders', 'deleteTaskButton': 'trash',
|
||||
'selectAllTasks': 'check', 'clearTaskSelection': 'close',
|
||||
'restoreTaskButton': 'refresh', 'taskRecycleBin': 'trash',
|
||||
'moveTaskUp': 'arrow-up', 'moveTaskDown': 'sort', 'executeProjectTasks': 'play',
|
||||
'addMappingButton': 'plus', 'editMappingButton': 'sliders', 'deleteMappingButton': 'trash',
|
||||
|
||||
@@ -370,7 +370,18 @@ class TrialTaskCenterWindow(MaterialMainWindow):
|
||||
if deleted else self.service.tasks(read_control=control), received, self._show_error, cancellable=True)
|
||||
|
||||
def open_task(self, task_id):
|
||||
if not task_id or (self._workers and self._batch_stop is None):
|
||||
if not task_id:
|
||||
if self._workers and self._batch_stop is None:
|
||||
return
|
||||
self._task_id = None
|
||||
self.plan_panel.bind_task(None)
|
||||
self.project_summary.populate(None)
|
||||
self.mapping_table.populate(())
|
||||
self._message = ''
|
||||
self._log_presenter.bind(None)
|
||||
self._load_task_data()
|
||||
return
|
||||
if self._workers and self._batch_stop is None:
|
||||
return
|
||||
if self._task_id != task_id:
|
||||
self.plan_panel.bind_task(None)
|
||||
@@ -476,6 +487,8 @@ class TrialTaskCenterWindow(MaterialMainWindow):
|
||||
self.task_list.filter.setEnabled(not self._workers or self._batch_stop is not None)
|
||||
self.task_list.search.setEnabled(not self._workers or self._batch_stop is not None)
|
||||
self.task_list.recycle_button.setEnabled(not busy)
|
||||
self.task_list.select_all_button.setEnabled(not busy and bool(self.task_list.list.count()))
|
||||
self.task_list.clear_selection_button.setEnabled(not busy)
|
||||
self.task_list.sort.setEnabled(not self._workers or self._batch_stop is not None)
|
||||
self.task_list.new_button.setEnabled(not busy)
|
||||
exists = bool(context)
|
||||
|
||||
@@ -8,7 +8,7 @@ from typing import Iterable
|
||||
|
||||
from PySide6.QtCore import Qt, QSignalBlocker, Signal, QSize, QRect
|
||||
from PySide6.QtGui import QColor,QFont,QIcon,QPalette
|
||||
from PySide6.QtWidgets import (QComboBox,QHBoxLayout,QLabel,QLineEdit,QListWidget,
|
||||
from PySide6.QtWidgets import (QAbstractItemView,QComboBox,QHBoxLayout,QLabel,QLineEdit,QListWidget,
|
||||
QListWidgetItem,QPushButton,QVBoxLayout,QWidget,QToolButton,QMenu,
|
||||
QStyledItemDelegate,QStyleOptionViewItem,QStyle,QApplication)
|
||||
from .command_menu import CommandMenu
|
||||
@@ -62,6 +62,7 @@ class TaskList(QWidget):
|
||||
super().__init__()
|
||||
self.setObjectName("taskNavigation")
|
||||
self.setAttribute(Qt.WidgetAttribute.WA_StyledBackground, True)
|
||||
self._on_open = on_open
|
||||
self._tasks = ()
|
||||
self._selected_task_id = None
|
||||
from .icons import icon
|
||||
@@ -83,9 +84,12 @@ class TaskList(QWidget):
|
||||
self.filter.setMaximumHeight(0)
|
||||
self.list = QListWidget(objectName="taskList")
|
||||
self.list.setItemDelegate(TaskItemDelegate(self.list))
|
||||
self.list.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
|
||||
self.list.setTextElideMode(Qt.TextElideMode.ElideRight)
|
||||
self.list.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
|
||||
self.new_button = QPushButton("新建", objectName="newTaskButton")
|
||||
self.select_all_button = QPushButton('全选', objectName='selectAllTasks')
|
||||
self.clear_selection_button = QPushButton('清空选择', objectName='clearTaskSelection')
|
||||
self.edit_button = QPushButton("编辑", objectName="editTaskButton")
|
||||
self.delete_button = QPushButton("删除", objectName="deleteTaskButton")
|
||||
self.restore_button = QPushButton("恢复", objectName="restoreTaskButton")
|
||||
@@ -96,6 +100,8 @@ class TaskList(QWidget):
|
||||
self.new_button.setProperty('appearance','quiet')
|
||||
self.new_button.setText('新建任务')
|
||||
self.new_button.setToolTip('从目录创建工程任务')
|
||||
for button in (self.select_all_button, self.clear_selection_button):
|
||||
button.setProperty('appearance', 'quiet')
|
||||
self.manage_menu=CommandMenu(self)
|
||||
for button in (self.edit_button,self.restore_button,self.up_button,self.down_button):
|
||||
self.manage_menu.add_button(button)
|
||||
@@ -121,6 +127,8 @@ class TaskList(QWidget):
|
||||
sort_button.setProperty('appearance','quiet')
|
||||
heading=QHBoxLayout();heading.addWidget(QLabel('工程任务',objectName='taskSectionTitle'));heading.addStretch();heading.addWidget(self.new_button)
|
||||
batch=QHBoxLayout();batch.addWidget(self.count,1);batch.addWidget(sort_button)
|
||||
selection=QHBoxLayout();selection.setSpacing(3)
|
||||
selection.addWidget(self.select_all_button);selection.addWidget(self.clear_selection_button);selection.addStretch()
|
||||
footer=QHBoxLayout();footer.addWidget(self.recycle_button);footer.addStretch();footer.addWidget(self.manage_button)
|
||||
self.recycle_button.setProperty('appearance','quiet')
|
||||
self.queue_button.setProperty('appearance','batch')
|
||||
@@ -130,13 +138,19 @@ class TaskList(QWidget):
|
||||
layout.addLayout(heading)
|
||||
layout.addWidget(self.search)
|
||||
layout.addLayout(batch)
|
||||
layout.addLayout(selection)
|
||||
layout.addWidget(self.list, 1)
|
||||
layout.addWidget(self.queue_button)
|
||||
layout.addLayout(footer)
|
||||
def selected():
|
||||
self._selected_task_id = self.current_task_id()
|
||||
on_open(self._selected_task_id or '')
|
||||
task_id = self.current_task_id()
|
||||
if task_id != self._selected_task_id:
|
||||
self._selected_task_id = task_id
|
||||
self._on_open(task_id or '')
|
||||
self.list.itemSelectionChanged.connect(selected)
|
||||
self.list.itemSelectionChanged.connect(self._update_selection_state)
|
||||
self.select_all_button.clicked.connect(self.select_all_tasks)
|
||||
self.clear_selection_button.clicked.connect(self.clear_task_selection)
|
||||
self.search.textChanged.connect(self._render)
|
||||
self.sort.currentIndexChanged.connect(self._render)
|
||||
|
||||
@@ -154,6 +168,35 @@ class TaskList(QWidget):
|
||||
self._selected_task_id = task_id
|
||||
self._render()
|
||||
|
||||
def select_all_tasks(self) -> None:
|
||||
if not self.list.count():
|
||||
return
|
||||
self.list.selectAll()
|
||||
if self.list.currentItem() is None:
|
||||
self.list.setCurrentRow(0)
|
||||
self._update_selection_state()
|
||||
|
||||
def clear_task_selection(self) -> None:
|
||||
with QSignalBlocker(self.list):
|
||||
self.list.clearSelection()
|
||||
self.list.setCurrentItem(None)
|
||||
for row in range(self.list.count()):
|
||||
self.list.item(row).setSelected(False)
|
||||
self._selected_task_id = None
|
||||
self._on_open('')
|
||||
self._update_selection_state()
|
||||
self.view_changed.emit()
|
||||
|
||||
def _update_selection_state(self) -> None:
|
||||
selected = len(self.list.selectedItems())
|
||||
total = self.list.count()
|
||||
suffix = f' · 已选 {selected}' if selected else ''
|
||||
current = self.count.text()
|
||||
if ' · 已选 ' in current:
|
||||
current = current.split(' · 已选 ', 1)[0]
|
||||
if current:
|
||||
self.count.setText(current + suffix)
|
||||
|
||||
def _render(self):
|
||||
selected = self._selected_task_id
|
||||
query = self.search.text().strip().casefold().replace('\\', '/')
|
||||
@@ -190,4 +233,5 @@ class TaskList(QWidget):
|
||||
self.list.setCurrentItem(item)
|
||||
hidden = selected and self.current_task_id() is None
|
||||
self.count.setText(f'{len(tasks)} / {len(self._tasks)} 个任务' + (' · 当前任务已隐藏' if hidden else ''))
|
||||
self._update_selection_state()
|
||||
self.view_changed.emit()
|
||||
@@ -93,6 +93,19 @@ def test_repeated_refresh_does_not_reconfigure_composition(qtbot):
|
||||
assert len(backend.calls)==1
|
||||
|
||||
|
||||
def test_webengine_has_its_own_native_composition_parent(qtbot, tmp_path):
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtWidgets import QVBoxLayout
|
||||
from dx_productivity.trial_task_center.ui.dsh_native import NativeHarnessView
|
||||
window=QWidget();qtbot.addWidget(window)
|
||||
window.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||
view=NativeHarnessView(tmp_path,window)
|
||||
QVBoxLayout(window).addWidget(view)
|
||||
window.show()
|
||||
# The browser must compose into its child HWND, not the Acrylic HWND.
|
||||
assert view.web.nativeParentWidget() is view
|
||||
|
||||
|
||||
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.
|
||||
|
||||
@@ -31,6 +31,27 @@ def test_task_management_is_a_menu_and_new_task_is_at_the_top(ui):
|
||||
assert panel.list.itemDelegate().__class__.__name__=='TaskItemDelegate'
|
||||
|
||||
|
||||
def test_task_list_has_explicit_select_all_clear_and_new_task_controls(ui):
|
||||
panel=ui.window.task_list
|
||||
assert panel.list.selectionMode().name=='ExtendedSelection'
|
||||
assert panel.select_all_button.isVisible()
|
||||
assert panel.clear_selection_button.isVisible()
|
||||
assert panel.new_button.isVisible()
|
||||
assert panel.select_all_button.isEnabled()
|
||||
assert panel.clear_selection_button.isEnabled()
|
||||
assert panel.list.count()>1
|
||||
|
||||
panel.select_all_button.click()
|
||||
assert len(panel.list.selectedItems())==panel.list.count()
|
||||
assert '已选' in panel.count.text()
|
||||
|
||||
panel.clear_selection_button.click()
|
||||
assert panel.list.selectedItems()==[]
|
||||
assert panel.current_task_id() is None
|
||||
assert ui.window._task_id is None
|
||||
assert panel.count.text().endswith('个任务')
|
||||
|
||||
|
||||
def test_plan_search_shares_toolbar_and_save_is_below_table(ui):
|
||||
window=ui.window;window.mapping_tabs.setCurrentIndex(1)
|
||||
plan=window.plan_panel
|
||||
|
||||
@@ -16,8 +16,8 @@ import time
|
||||
|
||||
os.environ.pop('QT_QPA_PLATFORM',None)
|
||||
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'src'))
|
||||
from PySide6.QtCore import Qt,QRectF
|
||||
from PySide6.QtGui import QColor,QFont,QPainter,QLinearGradient,QPen
|
||||
from PySide6.QtCore import Qt,QRectF,QPoint
|
||||
from PySide6.QtGui import QColor,QFont,QPainter,QLinearGradient,QPen,QCursor
|
||||
from PySide6.QtWidgets import QApplication,QWidget,QToolTip
|
||||
from PIL import ImageGrab,ImageChops,ImageStat
|
||||
from dx_productivity.trial_task_center.store import TaskStore
|
||||
@@ -29,6 +29,7 @@ from dx_productivity.trial_task_center.target_plan import ComponentTarget,Target
|
||||
def main():
|
||||
parser=argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--output',type=Path,default=Path('build/acrylic-acceptance'))
|
||||
parser.add_argument('--webengine-roundtrip',action='store_true')
|
||||
args=parser.parse_args();out=args.output.resolve();out.mkdir(parents=True,exist_ok=True)
|
||||
app=QApplication([]);app.setFont(QFont('Microsoft YaHei UI',9))
|
||||
def settle(seconds=.2):
|
||||
@@ -80,6 +81,7 @@ def main():
|
||||
assert window.property('acrylicEnabled'),'Native Acrylic not available under current system policy'
|
||||
report['native_enabled']=True
|
||||
def capture(name):
|
||||
QCursor.setPos(window.mapToGlobal(QPoint(12,12)))
|
||||
settle(.7)
|
||||
QToolTip.hideText();settle(.12)
|
||||
geo=window.geometry();scale=screen.devicePixelRatio()
|
||||
@@ -121,6 +123,31 @@ def main():
|
||||
assert report['right_header_backdrop_difference']>2,report
|
||||
assert report['right_execution_backdrop_difference']>2,report
|
||||
assert report['opaque_table_backdrop_difference']<1.5,report
|
||||
if args.webengine_roundtrip:
|
||||
from dx_productivity.trial_task_center.ui.dsh_native import NativeHarnessView
|
||||
report['before_webengine_surface']={'alpha':window.windowHandle().format().alphaBufferSize(),
|
||||
'translucent':window.testAttribute(Qt.WidgetAttribute.WA_TranslucentBackground),
|
||||
'acrylic':window.property('acrylicEnabled'),'contrast':window.property('highContrastFallback')}
|
||||
def create_view():
|
||||
view=NativeHarnessView(root/'dsh',window)
|
||||
view.start=lambda:None # Real Chromium surface; no server, model or CAD.
|
||||
view.web.setHtml('<html><body>Owned DSH WebEngine surface</body></html>')
|
||||
return view
|
||||
window._create_dsh_view=create_view
|
||||
for index in range(2):
|
||||
window.dsh_action.trigger();settle(2)
|
||||
window.task_center_action.trigger();settle(1)
|
||||
report['after_webengine_surface']={'alpha':window.windowHandle().format().alphaBufferSize(),
|
||||
'translucent':window.testAttribute(Qt.WidgetAttribute.WA_TranslucentBackground),
|
||||
'acrylic':window.property('acrylicEnabled'),'contrast':window.property('highContrastFallback')}
|
||||
background.phase=0;background.update();capture(f'roundtrip-{index}-a')
|
||||
background.phase=1;background.update();capture(f'roundtrip-{index}-b')
|
||||
delta=ImageChops.difference(captures[f'roundtrip-{index}-a'],captures[f'roundtrip-{index}-b'])
|
||||
report[f'roundtrip_{index}_sidebar_difference']=mean(delta.crop(sidebar))
|
||||
report[f'roundtrip_{index}_table_difference']=mean(delta.crop(table))
|
||||
(out/'roundtrip-probe.json').write_text(json.dumps(report,indent=2),encoding='utf8')
|
||||
assert report[f'roundtrip_{index}_sidebar_difference']>2,report
|
||||
assert report[f'roundtrip_{index}_table_difference']<1.5,report
|
||||
window.plan_panel.find_text.setText('RV');window.plan_panel.find()
|
||||
report['visible_search_feedback']=window.plan_panel.find_result.isVisible()
|
||||
assert '2 / 6'in window.plan_panel.find_result.text()
|
||||
@@ -136,6 +163,15 @@ def main():
|
||||
report['solid_sidebar_mean']=ImageStat.Stat(solid.crop(sidebar)).mean
|
||||
assert min(report['solid_sidebar_mean'])>200,report
|
||||
report['solid_fallback']=True
|
||||
if args.webengine_roundtrip:
|
||||
window.dsh_action.trigger();settle(.3)
|
||||
window.task_center_action.trigger();settle(.3)
|
||||
assert not window.property('acrylicEnabled')
|
||||
background.phase=0;background.update();capture('roundtrip-solid-a')
|
||||
background.phase=1;background.update();capture('roundtrip-solid-b')
|
||||
delta=ImageChops.difference(captures['roundtrip-solid-a'],captures['roundtrip-solid-b'])
|
||||
report['roundtrip_reduced_sidebar_difference']=mean(delta.crop(sidebar))
|
||||
assert report['roundtrip_reduced_sidebar_difference']<1.5,report
|
||||
window.reduced_transparency_button.setChecked(False);settle(.3)
|
||||
window.resize(980,700);capture('native-app-compact')
|
||||
report['compact_size']=[window.width(),window.height()]
|
||||
|
||||
Reference in new issue
Block a user