[0913] 版本弹窗长文本自动换行并自适应高度 - #4349
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
\n)换行的基础上,单行文字超过弹窗宽度时自动换行,弹窗高度随内容自适应。Why
翻译问题排查结论:用户看到的英文弹窗来自 [0414](0b26a8c05,2026/06/05)到 [2080](fc8c1f398,2026/08/03)之间的构建:0414/0415 引入「联网自动获取最新版本号」后,消息改为英文模板先
replace代入版本号、再交给旧 widget 弹窗show-message,而旧弹窗的自动翻译(make-menu-text→translate)作用在代入版本号之后的字符串上,撞不上字典 key(key 含%1/%2/%3占位符),整段回退英文;0414 之前是硬编码中文。[2080] QML 重构已把translate挪到replace之前(先译模板再代入版本号),问题随之修复。本 PR 在最新 main 上实测确认弹窗标题、正文、按钮均为中文。自动换行:
Version.qml消息行原为wrapMode: Text.NoWrap,长行(如英文提示)会超出 560 宽弹窗被裁掉。How
Version.qml消息行wrapMode改为Text.Wrap(优先词边界折行,超长词/URL 断开;中文无空格也可在字符间断开),\n分行结构不变。implicitHeight绑定为max(220 * scaleFactor, body.implicitHeight + 2 * Theme.margin)。文本宽度绑定到新增的contentW(定宽弹窗的正文内容宽560 * scaleFactor - 2 * implicitMargins)而非实际父宽——C++ 在 show 之前就要读implicitHeight定高,此刻布局宽度尚未就位(隐藏状态下 QQuickWidget 不向 root 同步尺寸),绑实际宽度会量出错误的换行结果。run_qml_dialog新增autofit_height参数:true 时走新增的lock_autofit_height——先按逻辑宽锁定视图宽度,再读根对象implicitHeight(QML 像素,已含 scaleFactor,故不再过DpiUtils::scaled)锁定高度,logic_h仅作回退。cpp_version_dialog传true。ai-docs/qml/qml-dialog.html的 Version 面板 legend 同步补换行/自适应说明。Tests
gf fmt --changed-since=main:0 实际改动xmake b qml_load_test && xmake r qml_load_test:12 passed / 0 failed(新增test_version_long_line_wraps:400 字符单行 → 换行后行高成倍、implicitHeight超过最小高度 220)xmake b stem && xmake r 2080:2 correct / 0 failedorigin/main(7bba28489)rebase,rebase 后重跑上述验证通过手动 GUI 验证(已完成,截屏确认)
\n分段含长行):长行按词边界折行,弹窗 560x220 撑高到 560x284。