From 0584101492db3a95f8dba4a857c3d5602be3c768 Mon Sep 17 00:00:00 2001 From: zqq-dora Date: Mon, 19 Oct 2026 17:55:50 +0800 Subject: [PATCH] fix(ArrowListView): keep arrows always visible and grey by scroll position MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The up/down arrow buttons in ArrowListView used `visible: itemsView.interactive`, so they only appeared when the menu was scrollable and vanished otherwise. Because the arrow Loaders also relied on `Layout.preferredHeight: implicitHeight`, the Loader's implicitHeight evaluated to 0 before the ActionButton incubated, so the ColumnLayout gave the arrow 0 height and Qt marked it invisible on first open -- the up arrow only reappeared after the first scroll. ArrowListView.qml - Remove `visible: itemsView.interactive` from both arrow Loaders so the arrows are always present and the menu height no longer jitters when toggling between scrollable and non-scrollable. - Replace `Layout.preferredHeight: implicitHeight` with the fixed `DS.Style.arrowListView.stepButtonSize.height` plus `Layout.minimumHeight` of the same value, so the layout reserves the arrow height from creation rather than collapsing to 0 while the ActionButton incubates. - Add `spacing: 6` between the arrows and the list, and `anchors.topMargin: 6` so the up arrow keeps 6 px from the search-box header. ArrowListViewButton.qml - Set `active: true` so the ActionButton is always loaded, matching the always-visible behavior above. - Keep the existing position-based `enabled` binding (`!view.atYBeginning` / `!view.atYEnd`); disabled arrows grey through ActionButton's native disabled opacity, no custom DCI state needed. - Update copyright year range to 2022 - 2026. Only the Qt6 (qt6/src/qml/) implementation is changed; Qt5 is left unchanged as v25 ships Qt6 only. --- 修复搜索菜单上下箭头:箭头常驻显示并按滚动位置置灰 ArrowListView 的上下箭头之前使用 `visible: itemsView.interactive`, 只有菜单可滚动时才显示,否则消失。同时两个箭头 Loader 使用 `Layout.preferredHeight: implicitHeight`,而 Loader 在 ActionButton 孵化前 implicitHeight 为 0,导致 ColumnLayout 给箭头分配 0 高度、 Qt 判定其不可见——首次打开时上箭头不显示,要等滚动一次后才出现。 ArrowListView.qml - 删除两个箭头 Loader 的 `visible: itemsView.interactive`,箭头常驻, 菜单高度不再因可滚动状态切换而抖动。 - 将 `Layout.preferredHeight: implicitHeight` 替换为固定的 `DS.Style.arrowListView.stepButtonSize.height`,并加同值的 `Layout.minimumHeight`,使布局从创建起就为箭头预留高度,不再在 ActionButton 孵化前塌成 0。 - 新增 `spacing: 6`(箭头与列表间距)和 `anchors.topMargin: 6` (上箭头与搜索框 header 间距 6 px)。 ArrowListViewButton.qml - `active` 改为 `true`,与箭头常驻保持一致。 - 保留原有的按位置判断的 `enabled` 绑定(`!view.atYBeginning` / `!view.atYEnd`),置灰通过 ActionButton 原生 disabled opacity 实现, 无需额外 DCI disabled 状态。 - 更新版权年份范围至 2022 - 2026。 仅修改 Qt6(qt6/src/qml/)实现,Qt5 保持不变,v25 仅使用 Qt6。 --- qt6/src/qml/ArrowListView.qml | 17 +++++++++-------- qt6/src/qml/private/ArrowListViewButton.qml | 3 +-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/qt6/src/qml/ArrowListView.qml b/qt6/src/qml/ArrowListView.qml index eb7c880c2..13498f8b9 100644 --- a/qt6/src/qml/ArrowListView.qml +++ b/qt6/src/qml/ArrowListView.qml @@ -21,22 +21,23 @@ FocusScope { return 0 const item = itemsView.itemAtIndex(0) const measured = itemsView.contentHeight > 0 && item ? (item.height || item.implicitHeight) : 0 - const arrowStrips = itemsView.count > maxVisibleItems - ? 2 * (DS.Style.arrowListView.stepButtonIconSize.height + contentLayout.spacing) : 0 - return Math.min(itemsView.count, maxVisibleItems) * (measured > 0 ? measured : itemHeight) + arrowStrips + const arrowStrips = 2 * (DS.Style.arrowListView.stepButtonSize.height + contentLayout.spacing) + return Math.min(itemsView.count, maxVisibleItems) * (measured > 0 ? measured : itemHeight) + arrowStrips + contentLayout.anchors.topMargin } implicitWidth: Math.max(DS.Style.arrowListView.width, contentLayout.implicitWidth) - implicitHeight: contentLayout.implicitHeight + implicitHeight: contentLayout.implicitHeight + contentLayout.anchors.topMargin ColumnLayout { id: contentLayout anchors.fill: parent + anchors.topMargin: 6 + spacing: 6 P.ArrowListViewButton { - visible: itemsView.interactive Layout.alignment: Qt.AlignHCenter Layout.fillWidth: true - Layout.preferredHeight: DS.Style.arrowListView.stepButtonIconSize.height + Layout.preferredHeight: DS.Style.arrowListView.stepButtonSize.height + Layout.minimumHeight: DS.Style.arrowListView.stepButtonSize.height view: itemsView stepSize: control.itemHeight direction: P.ArrowListViewButton.UpButton @@ -90,10 +91,10 @@ FocusScope { } P.ArrowListViewButton { - visible: itemsView.interactive Layout.alignment: Qt.AlignHCenter Layout.fillWidth: true - Layout.preferredHeight: DS.Style.arrowListView.stepButtonIconSize.height + Layout.preferredHeight: DS.Style.arrowListView.stepButtonSize.height + Layout.minimumHeight: DS.Style.arrowListView.stepButtonSize.height view: itemsView stepSize: control.itemHeight direction: P.ArrowListViewButton.DownButton diff --git a/qt6/src/qml/private/ArrowListViewButton.qml b/qt6/src/qml/private/ArrowListViewButton.qml index 57e19d87e..ea8cb4bbb 100644 --- a/qt6/src/qml/private/ArrowListViewButton.qml +++ b/qt6/src/qml/private/ArrowListViewButton.qml @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: LGPL-3.0-or-later @@ -15,7 +15,6 @@ Loader { required property Item view property int direction property int stepSize: DS.Style.arrowListView.itemHeight - active: view.interactive sourceComponent: ActionButton { palette.windowText: undefined