Repository navigation
fix(Menu): restore spacing between header and list when arrows are hidden - #732
Conversation
…dden PR linuxdeepin#728 made ArrowListView's topMargin conditional on itemsView.interactive to avoid extra space when arrows are absent. However, that topMargin was also the only spacing between a search-box header and the menu items. When a menu had a header but no arrows (item count <= maxVisibleItems), the header and the first item were flush together with zero gap. Menu.qml - Add ids to the header and footer Loaders so their loaded state can be checked. - Add Layout.topMargin/bottomMargin on ArrowListView bound to whether the header/footer Loader actually has an item, so the 6px gap only appears when a header or footer is present, and never when absent. - Keep viewLayout spacing at 0 so menus without header/footer get no extra top/bottom padding. ArrowListView.qml - Set anchors.topMargin to 0 unconditionally; the header/list gap is now handled by Menu.qml's Layout.topMargin so the two do not stack. - Split topMargin out of the arrowStrips term in sizedHeight so it is always counted (it is now always 0 here, but kept for clarity). Only the Qt6 (qt6/src/qml/) implementation is changed; Qt5 is left unchanged as v25 ships Qt6 only. 修复带搜索框菜单在无箭头时搜索框与列表项之间缺少间距 PR linuxdeepin#728 将 ArrowListView 的 topMargin 改为按 itemsView.interactive 条件 绑定,无箭头时归零。但该 topMargin 同时也是搜索框 header 与菜单项之间 唯一的间距来源,导致有 header 但无箭头(项数 <= maxVisibleItems)时, 搜索框与第一条菜单项贴在一起。 Menu.qml - 为 header 和 footer Loader 添加 id,以便检测其是否加载了内容。 - 在 ArrowListView 上添加 Layout.topMargin/bottomMargin,绑定到 header/footer Loader 是否有 item,使 6px 间距仅在 header/footer 存在时出现,不存在时不产生多余间距。 - viewLayout spacing 保持 0,无 header/footer 的菜单上下不会多出间距。 ArrowListView.qml - anchors.topMargin 无条件设为 0,header 与列表的间距改由 Menu.qml 的 Layout.topMargin 统一控制,避免两者叠加。 - sizedHeight 中将 topMargin 从 arrowStrips 项中拆出单独计入。 仅修改 Qt6(qt6/src/qml/)实现,Qt5 保持不变,v25 仅使用 Qt6。
Reviewer's guide (collapsed on small PRs)Reviewer's GuideRestores a 6px gap between loaded menu headers/footers and the item list without adding padding to menus that lack them. Menu.qml now conditionally owns the spacing, while ArrowListView avoids duplicate margins and keeps its implicit-height calculation accurate; only the Qt6 implementation changes. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Hi @zqq-dora. Thanks for your PR. I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="qt6/src/qml/ArrowListView.qml" line_range="37" />
<code_context>
id: contentLayout
anchors.fill: parent
- anchors.topMargin: itemsView.interactive ? 6 : 0
+ anchors.topMargin: 0
spacing: itemsView.interactive ? 6 : 0
P.ArrowListViewButton {
</code_context>
<issue_to_address>
**ComboBox popups lose top spacing**
When a ComboBox has more items than its `maxVisibleItems` limit, `ArrowListView` sets `anchors.topMargin` to 0, and `ComboBox` provides no replacement margin. Its `sizedHeight` omits the former 6px gap, leaving the popup 6px shorter and the up arrow flush with the popup edge.
Preserve the 6px top gap for ComboBox’s interactive list, either in `ArrowListView` or with an equivalent margin at the ComboBox call site.
</issue_to_address>| id: contentLayout | ||
| anchors.fill: parent | ||
| anchors.topMargin: itemsView.interactive ? 6 : 0 | ||
| anchors.topMargin: 0 |
There was a problem hiding this comment.
🟡 Medium · ComboBox popups lose top spacing
When a ComboBox has more items than its maxVisibleItems limit, ArrowListView sets anchors.topMargin to 0, and ComboBox provides no replacement margin. Its sizedHeight omits the former 6px gap, leaving the popup 6px shorter and the up arrow flush with the popup edge.
Preserve the 6px top gap for ComboBox’s interactive list, either in ArrowListView or with an equivalent margin at the ComboBox call site.
Prompt for AI agents
In `qt6/src/qml/ArrowListView.qml` at line 37:
**ComboBox popups lose top spacing**
When a ComboBox has more items than its `maxVisibleItems` limit, `ArrowListView` sets `anchors.topMargin` to 0, and `ComboBox` provides no replacement margin. Its `sizedHeight` omits the former 6px gap, leaving the popup 6px shorter and the up arrow flush with the popup edge.
Preserve the 6px top gap for ComboBox’s interactive list, either in `ArrowListView` or with an equivalent margin at the ComboBox call site.|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, zqq-dora The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Background
PR #728 made ArrowListView's
anchors.topMarginconditional onitemsView.interactiveso that no extra space is reserved when arrows are absent. However, thattopMarginwas also the only spacing between a search-box header and the menu items.When a menu has a header (e.g. a
SearchEdit) but no arrows (item count <=maxVisibleItems), the header and the first menu item are flush together with zero gap. Conversely,viewLayout.spacing: 0inMenu.qmlmeans menus without a header/footer get no extra top/bottom padding, which is correct.Changes
Menu.qml
id: headerLoaderandid: footerLoaderto the header and footer Loaders so their loaded state can be checked.Layout.topMargin: headerLoader.item ? 6 : 0andLayout.bottomMargin: footerLoader.item ? 6 : 0on ArrowListView, so the 6px gap only appears when a header or footer is actually present, and never when absent.viewLayout.spacing: 0so menus without header/footer get no extra top/bottom padding.ArrowListView.qml
anchors.topMarginto0unconditionally; the header/list gap is now handled byMenu.qml'sLayout.topMarginso the two do not stack.topMarginout of thearrowStripsterm insizedHeightso it is always counted independently.Effect
Only the Qt6 (
qt6/src/qml/) implementation is changed; Qt5 is left unchanged as v25 ships Qt6 only.背景
PR #728 将 ArrowListView 的
anchors.topMargin改为按itemsView.interactive条件绑定,无箭头时归零。但该topMargin同时也是搜索框 header 与菜单项之间唯一的间距来源。当菜单有 header(如
SearchEdit搜索框)但无箭头(项数 <=maxVisibleItems)时,搜索框与第一条菜单项贴在一起,间距为零。而Menu.qml中viewLayout.spacing: 0使得没有 header/footer 的菜单不会多出上下间距,这是正确的。改动
Menu.qml
id,以便检测是否加载了内容。Layout.topMargin/Layout.bottomMargin,绑定到 header/footer Loader 是否有 item,使 6px 间距仅在 header/footer 存在时出现。viewLayout.spacing保持0,无 header/footer 的菜单上下不会多出间距。ArrowListView.qml
anchors.topMargin无条件设为0,header 与列表的间距改由Menu.qml的Layout.topMargin统一控制,避免两者叠加。sizedHeight中将topMargin从arrowStrips项中拆出单独计入。效果
仅修改 Qt6(
qt6/src/qml/)实现,Qt5 保持不变,v25 仅使用 Qt6。Summary by Sourcery
Restore conditional spacing around menu content so header and footer layouts remain consistent without adding padding to menus that lack them.
Bug Fixes:
Enhancements: