fix: restore the main window geometry across sessions
Core regression / JavaScript syntax (pull_request) Waiting to run
Core regression / Python core, intervention UI and release configuration (push) Successful in 5m28s
Core regression / JavaScript syntax (push) Successful in 6s
Core regression / Python core, intervention UI and release configuration (pull_request) Successful in 5m27s

This commit is contained in:
阿白叔 committed 2026-11-25 09:58:38 +08:00
1 parent 46deb9cec8
commit 650dfd5491
3 files changed
+142 -1

No files matched your search

@@ -0,0 +1,21 @@
# Issue #33 D3 主窗口布局恢复
原来的 `ui-layout.ini` 只保存分栏、表头与排序,`TrialTaskCenterWindow` 每次启动都会重用默认窗口尺寸。复现时,保存进程关闭前的普通窗口为 `(45, 55, 1200, 760)` 且已最大化,重启后普通窗口变为 `(2, 2, 1280, 880)` 且未最大化。
正常接受关闭后,现通过 Qt `saveGeometry()` 持久化普通窗口几何和最大化状态。启动时调用 `restoreGeometry()`。若配置损坏、DPI 改变导致 Qt 拒绝恢复,或普通窗口超出当前可用屏幕,窗口会在当前可用屏幕内重新定位,并保留产品定义的最小尺寸。
## Windows 原生窗口实测
```powershell
$env:QT_QPA_PLATFORM = 'windows'
python -m pytest -q -s tests/v1_1/test_window_geometry.py
```
| 场景 | 结果 |
| --- | --- |
| 正常退出并启动新进程 | 普通窗口几何保持 `(45, 55, 1200, 760)`,最大化状态保持为真 |
| 新进程设 `QT_SCALE_FACTOR=1.5` | 普通窗口回退为 `(8, 36, 1008, 700)`,窗口位于可用屏幕,采用普通状态 |
| 配置值为错误类型或截断的字节 | 窗口仍能打开,普通窗口位置可达 |
| 配置保存位置为 `(50000, 50000)` | 窗口回到可用屏幕 |
测试通过 4 项。屏外场景用坐标模拟显示器移除,DPI 变化由 Qt 环境设置触发。