From b9d7daca0f035758acd8612633c55dcfee5ff20c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E7=99=BD=E5=8F=94?= <11794527+absfan@user.noreply.gitee.com> Date: Mon, 12 Oct 2026 19:22:29 +0800 Subject: [PATCH] ui: refine toolbar toggle and expanded panel --- docs/testing/toolbar-acceptance-20261011.md | 2 ++ docs/user/一叶知秋_重构版_更新说明.md | 1 + src/dx_productivity/ui/floating_toolbar.py | 10 +++++--- src/dx_productivity/ui/main_window.py | 11 ++++++++- src/dx_productivity/ui/theme.py | 14 ++++++++++- tests/ui/test_horizontal_toolbar.py | 27 +++++++++++++++++++++ 6 files changed, 59 insertions(+), 6 deletions(-) diff --git a/docs/testing/toolbar-acceptance-20261011.md b/docs/testing/toolbar-acceptance-20261011.md index b890f6a..5293bc7 100644 --- a/docs/testing/toolbar-acceptance-20261011.md +++ b/docs/testing/toolbar-acceptance-20261011.md @@ -4,6 +4,8 @@ 横向工具栏、九个功能面板及本轮实机验收已完成。正式包已通过真实 Start 注册到 DxDesigner 持久启动菜单,普通重启后自动加载。用户当前宿主 PID 44008 保留,已从其原生菜单打开最终工具并确认桥接已连接;面板收起,仅保留一排工具栏。该宿主的工程没有写回或关闭。 +2026-10-12 界面修订:尾部切换入口改为明确的“展开 ▾ / 收起 ▴”文字箭头按钮;展开页改为无标题栏、置顶的紧凑工具卡片。独立验收副本实际打开最终包验证通过,记录见 `%LOCALAPPDATA%/DxProductivity/acceptance/toolbar-20261012-ui-polish`。 + - 正式包:`release/一叶知秋_重构版_横向工具栏版`。 - 发布 ZIP:`release/一叶知秋_重构版_横向工具栏版_Win11_x64.zip`。 - ZIP SHA-256:`5ced1cc2a57888898c02eacb9c486a8e14463ddda59ccddc5c7d13f29ea87cd6`。 diff --git a/docs/user/一叶知秋_重构版_更新说明.md b/docs/user/一叶知秋_重构版_更新说明.md index f442472..6785c53 100644 --- a/docs/user/一叶知秋_重构版_更新说明.md +++ b/docs/user/一叶知秋_重构版_更新说明.md @@ -4,6 +4,7 @@ - 工具以一排置顶工具栏常驻,提供 Start、位号、属性、显示、检查、网络、BOM 和 PDF;历史、设置、刷新、主题及退出放在“更多”中。 - 点击功能展开对应面板,再点同一功能或“收起面板”收起。面板关闭和最小化也会收起;退出整个工具使用“更多 → 退出工具”。 +- 工具栏末尾使用明确的“展开 ▾ / 收起 ▴”按钮;展开内容以无标题栏卡片贴在工具栏下方,不再显示独立应用窗口的标题框。 - 收起后工具栏继续显示选择与任务状态;悬停可查看完整位号、工程、图页和状态信息。拖动左侧手柄移动,位置与各页面大小会保存。 - 页面移除固定左导航、重复标题与说明,操作按钮移到对应页面。低频设置折叠为高级选项,并显示当前有效参数摘要。 - PDF 保留三种范围、输出目录、打开目录和保存后自动导出;配色、文字处理与引擎设置可在高级选项中调整。 diff --git a/src/dx_productivity/ui/floating_toolbar.py b/src/dx_productivity/ui/floating_toolbar.py index 7f24cff..621335c 100644 --- a/src/dx_productivity/ui/floating_toolbar.py +++ b/src/dx_productivity/ui/floating_toolbar.py @@ -124,8 +124,10 @@ class FloatingToolbar(QWidget): action.triggered.connect(signal) setattr(self, attribute, action) layout.addWidget(self.more_button) - self.toggle_button = QPushButton() - self.toggle_button.setFixedWidth(32) + self.toggle_button = QToolButton() + self.toggle_button.setObjectName('panelToggle') + self.toggle_button.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon) + self.toggle_button.setFixedWidth(66) self.toggle_button.clicked.connect(self.toggle_panel_requested) layout.addWidget(self.toggle_button) self.set_panel_state(0, False) @@ -136,8 +138,9 @@ class FloatingToolbar(QWidget): button.setChecked(i == index and visible) for i, action in self.page_actions.items(): action.setChecked(i == index and visible) - self.toggle_button.setIcon(themed_icon('fa6s.chevron-up' if visible else 'fa6s.chevron-down', self._theme)) name = '收起面板' if visible else '展开面板' + self.toggle_button.setText('收起' if visible else '展开') + self.toggle_button.setArrowType(Qt.ArrowType.UpArrow if visible else Qt.ArrowType.DownArrow) self.toggle_button.setAccessibleName(name) self.toggle_button.setToolTip(name) self.toggle_action.setText(name) @@ -238,7 +241,6 @@ class FloatingToolbar(QWidget): def refresh_theme(self, theme): self._theme = theme self.drag_handle.setPixmap(themed_icon('fa6s.grip-vertical', theme).pixmap(14, 20)) - self.toggle_button.setIcon(themed_icon('fa6s.chevron-up' if self.toggle_button.accessibleName() == '收起面板' else 'fa6s.chevron-down', theme)) self.start_button.setIcon(themed_icon('fa6s.play', theme)) for index, button in self.page_buttons.items(): button.setIcon(themed_icon(NAVIGATION[index][1], theme)) diff --git a/src/dx_productivity/ui/main_window.py b/src/dx_productivity/ui/main_window.py index d7af14c..bec1a50 100644 --- a/src/dx_productivity/ui/main_window.py +++ b/src/dx_productivity/ui/main_window.py @@ -1,7 +1,7 @@ """Shared compact feature panel coordinated with a persistent toolbar.""" from __future__ import annotations -from PySide6.QtCore import QEvent, QPoint, QSize, QTimer, Signal +from PySide6.QtCore import QEvent, QPoint, QSize, QTimer, Qt, Signal from PySide6.QtWidgets import QApplication, QFrame, QHBoxLayout, QLabel, QMainWindow, QPushButton, QSizePolicy, QStackedWidget, QVBoxLayout, QWidget from dx_productivity.ui.floating_toolbar import FloatingToolbar, NAVIGATION @@ -19,6 +19,15 @@ class MainWindow(QMainWindow): def __init__(self, *, theme: Theme = Theme.LIGHT, layout_path=None) -> None: super().__init__() + # The expanded view is an attached tool card below the toolbar. Keep + # the shared page window out of the taskbar and remove the native app + # title bar so it reads as one floating tool surface. + self.setWindowFlags( + Qt.WindowType.Tool + | Qt.WindowType.FramelessWindowHint + | Qt.WindowType.WindowStaysOnTopHint + ) + self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground) self._closing = False self._placing = False self._effective_page_size = None diff --git a/src/dx_productivity/ui/theme.py b/src/dx_productivity/ui/theme.py index eab170c..f39aa40 100644 --- a/src/dx_productivity/ui/theme.py +++ b/src/dx_productivity/ui/theme.py @@ -124,9 +124,15 @@ def _stylesheet(tokens: ThemeTokens) -> str: font-size: 10pt; letter-spacing: 0px; }} - QMainWindow, QWidget#appRoot {{ + QMainWindow {{ + background: transparent; + border: none; + }} + QWidget#appRoot {{ background: {tokens.canvas}; color: {tokens.text_primary}; + border: 1px solid {tokens.border}; + border-radius: 10px; }} QWidget#floatingToolbar {{ background: {tokens.surface}; @@ -307,6 +313,12 @@ def _stylesheet(tokens: ThemeTokens) -> str: max-width: 30px; padding: 0; }} + QToolButton#panelToggle {{ + min-width: 66px; + max-width: 66px; + padding: 0 7px; + text-align: center; + }} QFrame#statusStrip {{ background: {tokens.surface}; border-top: 1px solid {tokens.border}; diff --git a/tests/ui/test_horizontal_toolbar.py b/tests/ui/test_horizontal_toolbar.py index cf4eefb..7ec2112 100644 --- a/tests/ui/test_horizontal_toolbar.py +++ b/tests/ui/test_horizontal_toolbar.py @@ -1,4 +1,5 @@ from PySide6.QtCore import Qt +from PySide6.QtWidgets import QToolButton from dx_productivity.ui.main_window import MainWindow @@ -48,6 +49,32 @@ def test_status_setters_update_hidden_toolbar_without_showing_panel(qtbot, tmp_p assert not window.isVisible() +def test_panel_toggle_has_explicit_direction_and_text(qtbot): + window = MainWindow() + qtbot.addWidget(window) + + toggle = window.toolbar.toggle_button + assert isinstance(toggle, QToolButton) + assert toggle.text() == '展开' + assert toggle.arrowType() == Qt.ArrowType.DownArrow + assert toggle.accessibleName() == '展开面板' + + window.show_panel(0) + assert toggle.text() == '收起' + assert toggle.arrowType() == Qt.ArrowType.UpArrow + assert toggle.accessibleName() == '收起面板' + + +def test_expanded_panel_is_a_frameless_tool_card(qtbot): + window = MainWindow() + qtbot.addWidget(window) + + flags = window.windowFlags() + assert flags & Qt.WindowType.FramelessWindowHint + assert flags & Qt.WindowType.Tool + assert window.centralWidget().objectName() == 'appRoot' + + def test_passive_status_keeps_host_focus_and_tracks_background_task(qtbot, qapp, tmp_path, monkeypatch): from types import SimpleNamespace from PySide6.QtWidgets import QWidget