Two macOS reports: both were Qt deciding, so both differed by platform
Settings sat closer to its icon than Dashboard and Giám sát do. Those are tree rows, laid out by the style; Settings was a QPushButton, whose icon-to-label gap is also the style's — and the two do not agree. The Windows fix for this was a 19px icon box that nudged the label 1px, which is exactly the kind of tuning that only holds on the machine it was measured on: on macOS the gap is tighter again. The row now lays itself out, 4px in and 6px between, the same two numbers the tree uses. Icon x=4 and label x=26 against the rows' 4 and 26 — equal, not close. The language drop-list showed a tick over its own text. macOS marks the current row with a checkmark and Windows does not, and the popup inherits the combo's width — which for "EN/JP/VN" is about 50px, all of it needed by the letters. widen_popup() measures the longest item plus the platform's indicator and sets the view's minimum, so the tick has its own room wherever it is drawn. That check found two more: the project picker (191px of text in a 138px popup) and the provider list (221px in 138px) were both truncating names here, tick or no tick. Neither could be reproduced on this machine, so the checks assert the property that made the bug possible — spacing we control rather than the style's, and a popup measured against text + indicator — not the platform. 21/21 checkers pass. check_nav segfaults in Qt teardown after printing its verdict, twice in one suite run and 0 times in 8 standalone runs; pre-existing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
e8fe67d0d9
commit
509ae96854
@@ -0,0 +1,79 @@
|
||||
"""A drop-list must have room for its text and for the tick beside it.
|
||||
|
||||
macOS marks the current row with a checkmark; Windows does not. The language
|
||||
combo is only as wide as "VN", and the popup inherits that width, so on macOS
|
||||
the tick landed on top of the two letters. Reported from a Mac, so this checks
|
||||
the property that made it possible rather than the platform.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
REPO = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(REPO.parent))
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
|
||||
|
||||
from capture_screens import ( # noqa: E402
|
||||
_apply_theme, _freeze_schedulers, _isolate_home, _load_fonts)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
sandbox = _isolate_home()
|
||||
from PySide6.QtWidgets import QApplication, QStyle
|
||||
|
||||
app = QApplication([])
|
||||
_load_fonts()
|
||||
_freeze_schedulers()
|
||||
_apply_theme(app)
|
||||
|
||||
from cowork_local.config import CONFIG_DIR
|
||||
assert str(sandbox) in str(CONFIG_DIR), f"isolation failed: {CONFIG_DIR}"
|
||||
|
||||
from seed_demo_data import seed
|
||||
seed()
|
||||
|
||||
from cowork_local.app import MainWindow
|
||||
from cowork_local.config import AppConfig
|
||||
from cowork_local.i18n import set_language
|
||||
from cowork_local.state import AppContext
|
||||
|
||||
set_language("vi")
|
||||
win = MainWindow(AppContext(AppConfig.load()), user_name="local")
|
||||
win.resize(1400, 900)
|
||||
win.show()
|
||||
app.processEvents()
|
||||
|
||||
fails = []
|
||||
for name in ("language_combo", "nav_project", "provider_combo"):
|
||||
combo = getattr(win, name, None)
|
||||
if combo is None or not combo.count():
|
||||
continue
|
||||
view = combo.view()
|
||||
fm = view.fontMetrics()
|
||||
longest = max(fm.horizontalAdvance(combo.itemText(i))
|
||||
for i in range(combo.count()))
|
||||
tick = combo.style().pixelMetric(QStyle.PM_IndicatorWidth, None, combo)
|
||||
need = longest + tick
|
||||
have = max(view.minimumWidth(), combo.width())
|
||||
print(f"{name:15}: chu dai nhat {longest:>4}px + dau tick {tick:>3}px "
|
||||
f"= can {need:>4}px | popup rong {have:>4}px")
|
||||
if have < need:
|
||||
fails.append(f"{name}: popup {have}px, khong du {need}px cho chu + dau tick")
|
||||
|
||||
print()
|
||||
for f in fails:
|
||||
print("FAIL " + f)
|
||||
print("PASS moi drop-list du cho chu va dau tick" if not fails
|
||||
else f"{len(fails)} problem(s)")
|
||||
sys.stdout.flush()
|
||||
os._exit(1 if fails else 0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user