Skip to content

Commit c56e04e

Browse files
committed
feat: change scroll trigger from click to hover
Changed ArrowListView button behavior from click-based to hover-based scrolling 1. Replaced Button with ActionButton component for better hover handling 2. Added timer-based auto-scrolling with initial 300ms delay and 100ms repeat interval 3. Implemented state machine to manage hover detection and scroll execution 4. Modified layout properties to use Layout.fillWidth for better button sizing 5. Removed onClicked handler and replaced with unified performScroll function feat: 将滚动触发方式从点击改为悬停 将 ArrowListView 按钮行为从基于点击改为基于悬停的滚动 1. 将 Button 替换为 ActionButton 组件以更好地处理悬停 2. 添加基于计时器的自动滚动,具有 300 毫秒初始延迟和 100 毫秒重复间隔 3. 实现状态机来管理悬停检测和滚动执行 4. 修改布局属性使用 Layout.fillWidth 以获得更好的按钮尺寸 5. 移除 onClicked 处理程序并替换为统一的 performScroll 函数 PMS: BUG-314007 BUG-278225
1 parent e9f15d2 commit c56e04e

2 files changed

Lines changed: 39 additions & 6 deletions

File tree

qt6/src/qml/ArrowListView.qml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ FocusScope {
2424
P.ArrowListViewButton {
2525
visible: itemsView.interactive
2626
Layout.alignment: Qt.AlignHCenter
27-
Layout.preferredWidth: width
27+
Layout.fillWidth: true
2828
Layout.preferredHeight: height
2929
view: itemsView
3030
direction: P.ArrowListViewButton.UpButton
@@ -79,7 +79,7 @@ FocusScope {
7979
P.ArrowListViewButton {
8080
visible: itemsView.interactive
8181
Layout.alignment: Qt.AlignHCenter
82-
Layout.preferredWidth: width
82+
Layout.fillWidth: true
8383
Layout.preferredHeight: height
8484
view: itemsView
8585
direction: P.ArrowListViewButton.DownButton

qt6/src/qml/private/ArrowListViewButton.qml

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,49 @@ Loader {
1616
property int direction
1717
active: view.interactive
1818

19-
sourceComponent: Button {
20-
flat: true
19+
sourceComponent: ActionButton {
20+
palette.windowText: undefined
2121
enabled: direction === ArrowListViewButton.UpButton ? !view.atYBeginning : !view.atYEnd
2222
width: DS.Style.arrowListView.stepButtonSize.width
2323
height: DS.Style.arrowListView.stepButtonSize.height
2424
icon.name: direction === ArrowListViewButton.UpButton ? DS.Style.arrowListView.upButtonIconName
2525
: DS.Style.arrowListView.downButtonIconName
2626
icon.width: DS.Style.arrowListView.stepButtonIconSize.width
2727
icon.height: DS.Style.arrowListView.stepButtonIconSize.height
28-
onClicked: direction === ArrowListViewButton.UpButton ? view.decrementCurrentIndex()
29-
: view.incrementCurrentIndex()
28+
29+
// Unified scroll operation function
30+
function performScroll() {
31+
direction === ArrowListViewButton.UpButton ? view.decrementCurrentIndex()
32+
: view.incrementCurrentIndex()
33+
}
34+
35+
// Auto-scroll control properties using state machine approach
36+
property bool shouldAutoScroll: hovered && enabled
37+
property bool delayCompleted: false
38+
39+
// Timer for initial delay before starting hover scroll
40+
Timer {
41+
id: initialDelayTimer
42+
interval: 300
43+
repeat: false
44+
running: shouldAutoScroll && !delayCompleted
45+
onTriggered: delayCompleted = true
46+
}
47+
48+
// Timer for continuous hover scrolling
49+
Timer {
50+
id: hoverScrollTimer
51+
interval: 100
52+
repeat: true
53+
running: shouldAutoScroll && delayCompleted
54+
onTriggered: performScroll()
55+
}
56+
57+
// Reset state when auto-scroll should stop
58+
onShouldAutoScrollChanged: {
59+
if (!shouldAutoScroll) {
60+
delayCompleted = false
61+
}
62+
}
3063
}
3164
}

0 commit comments

Comments
 (0)