diff --git a/tools/check_design_parity.py b/tools/check_design_parity.py index 37ef0d8..ab33a6a 100644 --- a/tools/check_design_parity.py +++ b/tools/check_design_parity.py @@ -17,7 +17,7 @@ from __future__ import annotations import os import sys -sys.stdout.reconfigure(encoding="utf-8", errors="replace") +sys.stdout.reconfigure(encoding="utf-8", errors="replace") from pathlib import Path REPO = Path(__file__).resolve().parent.parent @@ -59,7 +59,7 @@ def build(): _load_fonts() _freeze_schedulers() - _apply_theme(app) # measure the styled window, not a bare one + _apply_theme(app) # measure the styled window, not a bare one from cowork_local.config import AppConfig, CONFIG_DIR assert str(sandbox) in str(CONFIG_DIR), f"isolation failed: {CONFIG_DIR}" @@ -295,9 +295,18 @@ def main() -> int: add("overlay-help-panel", "Rê chuột mới hiện chữ 'AI Assistant'", tr("help_agent.badge") in dock.launcher.text(), dock.launcher.text().strip()) dock.launcher._set_open(False) - items = [a.text() for a in dock.more_btn.menu().actions()] - add("overlay-help-panel", "'Ẩn trợ lý' dời vào menu ⋯", - tr("help_agent.hide_tooltip") in items, str(items)) + # The page asks for "'Ẩn trợ lý' dời vào menu ⋯". The user then asked for + # that menu to go: its two entries were "thu nhỏ", which the − button next + # to it already does, and "ẩn". Recorded as a deliberate deviation rather + # than quietly scored as done — the action itself moved to a right-click on + # the dot and on the panel header, so nothing became unreachable. + from PySide6.QtCore import Qt + + has_menu = hasattr(dock, "more_btn") + by_right_click = dock.launcher.contextMenuPolicy() == Qt.CustomContextMenu + add("overlay-help-panel", "'Ẩn trợ lý' — menu ⋯ bỏ theo yêu cầu, nay chuột phải", + (not has_menu) and by_right_click, + "menu ⋯ đã bỏ theo yêu cầu — 'Ẩn' nay là chuột phải trên chấm/tiêu đề") add("overlay-help-panel", "2 trạng thái thường ngày", True, "đóng ↔ mở, ẩn hẳn là tuỳ chọn") dock._hide_to_edge() app.processEvents() diff --git a/tools/check_help_dock.py b/tools/check_help_dock.py index 150b881..ed3bd7f 100644 --- a/tools/check_help_dock.py +++ b/tools/check_help_dock.py @@ -100,12 +100,27 @@ def main() -> int: fails.append(f"tab mep {dock.width()}px, van duoi 24px") dock._show_launcher() - # Nothing removed: "hide to the edge" is in the ⋯ menu now. - items = [a.text() for a in dock.more_btn.menu().actions()] - print(f"menu ⋯ : {items}") - for key in ("help_agent.collapse_tooltip", "help_agent.hide_tooltip"): - if tr(key) not in items: - fails.append(f"menu thieu muc {tr(key)}") + # The ⋯ menu is gone (user's call — its two entries were "collapse", which + # the − button beside it already did, and "hide"). Nothing was lost with it: + # collapse is the − button and the dot, hide is a right-click on either the + # dot or the open panel's header. Check the routes, not the menu. + from PySide6.QtCore import Qt as _Qt + + if hasattr(dock, "more_btn"): + fails.append("menu ⋯ van con tren panel") + dock._collapse() + app.processEvents() + if dock._state != "launcher": + fails.append("nut − khong thu nho duoc ve cham") + if dock.launcher.contextMenuPolicy() != _Qt.CustomContextMenu: + fails.append("cham khong co menu chuot phai de an") + dock._hide_to_edge() + app.processEvents() + if dock._state != "hidden": + fails.append("khong an duoc vao canh phai") + print(f"thu nho + an : ca hai duong deu chay (trang thai cuoi={dock._state!r})") + dock._show_launcher() + app.processEvents() print(f"nut thu nho : {dock.min_btn.toolTip()!r}") print(f"nut gui / o nhap: {dock.send_btn is not None} / {dock.input is not None}") @@ -113,9 +128,11 @@ def main() -> int: for lang in ("vi", "en", "ja"): set_language(lang) dock.retranslate() + # more_tooltip went with the ⋯ menu; dot_hint replaces it as the + # string that tells you the right-click is there. vals = [dock.launcher.toolTip(), tr("help_agent.badge"), - tr("help_agent.more_tooltip")] - print(f" {lang}: badge={vals[1]!r} more={vals[2]!r}") + tr("help_agent.dot_hint")] + print(f" {lang}: badge={vals[1]!r} goi y chuot phai={vals[2]!r}") if any(not v or v.startswith("help_agent.") for v in vals): fails.append(f"thieu ban dich cho {lang}") set_language("vi") diff --git a/ui/help_agent_widget.py b/ui/help_agent_widget.py index d250c27..3551592 100644 --- a/ui/help_agent_widget.py +++ b/ui/help_agent_widget.py @@ -255,27 +255,17 @@ class HelpAgentWidget(QWidget): self.min_btn.setToolTip(tr("help_agent.collapse_tooltip")) self.min_btn.clicked.connect(self._collapse) hb.addWidget(self.min_btn) - # "Hide to the right edge" lives here now, next to "minimise", instead of - # as a permanent 18px chevron on every screen. Same action, offered where - # the user is already interacting with the assistant. - self.more_btn = QPushButton("⋯", header) - self.more_btn.setObjectName("helpMinBtn") - self.more_btn.setFixedSize(24, 24) - self.more_btn.setCursor(Qt.PointingHandCursor) - self.more_btn.setToolTip(tr("help_agent.more_tooltip")) - menu = QMenu(self.more_btn) - self.act_collapse = menu.addAction(tr("help_agent.collapse_tooltip")) - self.act_collapse.triggered.connect(self._collapse) - self.act_hide = menu.addAction(tr("help_agent.hide_tooltip")) - self.act_hide.triggered.connect(self._hide_to_edge) - # The old build put a chevron button beside the dot that hid the - # assistant in one click. The drawing has no such button — the dot is - # 26px, no text, no chevron — so the same reach comes back as a right- - # click on the dot rather than as pixels next to it. - self.launcher.setContextMenuPolicy(Qt.CustomContextMenu) - self.launcher.customContextMenuRequested.connect(self._dot_menu) - self.more_btn.setMenu(menu) - hb.addWidget(self.more_btn) + # No ⋯ menu. The audit page put "Ẩn trợ lý" in one, but its two entries + # were "thu nhỏ" — which the − button beside it already does — and + # "ẩn vào cạnh phải". A drop-list to reach one action that duplicates + # its neighbour is chrome; removed at the user's request. + # + # Hiding stays reachable by right-click, on the header while the panel + # is open and on the dot while it is shut, so no route is lost. + for target in (header, self.launcher): + target.setContextMenuPolicy(Qt.CustomContextMenu) + target.customContextMenuRequested.connect( + lambda pos, w=target: self._hide_menu(w, pos)) v.addWidget(header) # Conversation log @@ -316,15 +306,18 @@ class HelpAgentWidget(QWidget): self._state = _LAUNCHER_ST self._apply_state() - def _dot_menu(self, pos) -> None: - """Right-click on the dot: hide to the edge, the one action that means - anything while the panel is shut ("collapse to dot" already happened).""" + def _hide_menu(self, widget, pos) -> None: + """Right-click, on the dot or the open panel's header: hide to the edge. + + The only action worth offering here — collapsing is what the − button + and the dot itself already are. + """ from PySide6.QtWidgets import QMenu - menu = QMenu(self.launcher) + menu = QMenu(widget) act = menu.addAction(tr("help_agent.hide_tooltip")) act.triggered.connect(self._hide_to_edge) - menu.exec(self.launcher.mapToGlobal(pos)) + menu.exec(widget.mapToGlobal(pos)) def _hide_to_edge(self) -> None: self._state = _HIDDEN @@ -483,7 +476,4 @@ class HelpAgentWidget(QWidget): self.launcher.setText(f" {tr('help_agent.badge')}") self._layout_launcher() self.min_btn.setToolTip(tr("help_agent.collapse_tooltip")) - self.more_btn.setToolTip(tr("help_agent.more_tooltip")) - self.act_collapse.setText(tr("help_agent.collapse_tooltip")) - self.act_hide.setText(tr("help_agent.hide_tooltip")) self.edge_tab.setToolTip(tr("help_agent.show_tooltip"))