From 10b8379824b76add05f1e064b68b840a8e279177 Mon Sep 17 00:00:00 2001 From: minhanhpkpro Date: Fri, 18 Sep 2026 00:19:26 +0900 Subject: [PATCH] =?UTF-8?q?fix(settings):=20gi=E1=BB=AF=20t=C3=AAn=20n?= =?UTF-8?q?=C3=BAt=20ch=E1=BA=B7n=20m=E1=BA=A1ng=20c=C5=A9=20v=C3=A0=20n?= =?UTF-8?q?=E1=BB=9Bi=20c=E1=BB=99t=20m=E1=BB=A5c=20l=E1=BB=A5c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Trả nhãn công tắc về "Block network for agent-run commands" (vi/ja như cũ). - Cột mục lục bên trái tính độ rộng theo kiểu chữ của mục đang chọn (in đậm + lề 10px), trước đây "Sandbox Security Layer" bị cắt. Co-Authored-By: Claude Opus 5 (1M context) --- i18n/settings_dialog.py | 6 +++--- presentation/shared/list_sizing.py | 27 +++++++++++++++++++++++++++ ui/widgets.py | 5 +++-- 3 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 presentation/shared/list_sizing.py diff --git a/i18n/settings_dialog.py b/i18n/settings_dialog.py index 6ffb9d3..723aa40 100644 --- a/i18n/settings_dialog.py +++ b/i18n/settings_dialog.py @@ -10,9 +10,9 @@ from typing import Dict STRINGS: Dict[str, Dict[str, str]] = { "settings.sandbox_block_network": { - "en": "Block network (AI provider still allowed)", - "ja": "ネットワークをブロック(AIプロバイダーのみ許可)", - "vi": "Chặn mạng (vẫn cho gọi nhà cung cấp AI)"}, + "en": "Block network for agent-run commands", + "ja": "エージェントが実行するコマンドのネットワークをブロック", + "vi": "Chặn mạng cho lệnh do agent chạy"}, "settings.allow_url_fetch": { "en": "Allow the agent to fetch URLs (web pages, SharePoint / OneDrive links)", "ja": "エージェントによるURL取得を許可(Webページ、SharePoint / OneDriveリンク)", diff --git a/presentation/shared/list_sizing.py b/presentation/shared/list_sizing.py new file mode 100644 index 0000000..7989d91 --- /dev/null +++ b/presentation/shared/list_sizing.py @@ -0,0 +1,27 @@ +"""Width of a navigation list whose current row is drawn bold. + +The theme draws the selected ``sectionIndex`` row with ``font-weight: 600`` +and 10px padding each side (``theme/qss.py``). Sizing the list from the plain +font left the selected label too wide for its row, so "Sandbox Security +Layer" was cut off in Settings as soon as it was picked. +""" +from __future__ import annotations + +from typing import Iterable + +from PySide6.QtGui import QFont, QFontMetrics + +#: Item padding (10px x 2) + item radius + list frame, with a little slack. +ROW_CHROME_PX = 48 + + +def selected_label_width(widget, labels: Iterable[str]) -> int: + """Pixels needed to show the widest of ``labels`` in the bold selected style.""" + widget.ensurePolished() + bold = QFont(widget.font()) + bold.setWeight(QFont.Weight.DemiBold) + metrics = QFontMetrics(bold) + return max((metrics.horizontalAdvance(label) for label in labels), default=0) + ROW_CHROME_PX + + +__all__ = ["ROW_CHROME_PX", "selected_label_width"] diff --git a/ui/widgets.py b/ui/widgets.py index 36ce64e..ae681aa 100644 --- a/ui/widgets.py +++ b/ui/widgets.py @@ -490,8 +490,9 @@ def section_panels(sections, width: int = 260): index.currentRowChanged.connect(stack.setCurrentIndex) index.setCurrentRow(0) - natural = max(index.fontMetrics().horizontalAdvance(lab) for lab, _w in sections) + 36 - index.setFixedWidth(max(120, min(width, natural))) + # Sized for the SELECTED look (bold + padding), or the picked label is cut. + from ..presentation.shared.list_sizing import selected_label_width + index.setFixedWidth(max(120, min(width, selected_label_width(index, [lab for lab, _w in sections])))) return index, stack