Skip to content

Commit 0303a68

Browse files
committed
fix: correct mouse event handling area for icon items
The MouseArea was incorrectly placed inside the icon's contentItem, causing mouse events to only be captured within the icon image area rather than the entire delegate item. This led to poor user experience where drag-and-drop and click operations only worked when clicking directly on the icon image, not the surrounding area. Moved the MouseArea from inside the icon's contentItem to be a direct child of the Control's background. This ensures the MouseArea covers the entire delegate area, making drag-and-drop and click operations work consistently across the whole item surface. Log: Fixed issue where drag-and-drop and click operations only worked when clicking directly on app icons Influence: 1. Test drag-and-drop functionality by clicking and dragging from any area within app icon items 2. Verify click operations work consistently across entire icon item surface 3. Test both normal clicks and drag operations to ensure they don't interfere 4. Verify hover states and visual feedback work correctly 5. Test with various icon sizes and delegate configurations fix: 修复图标项鼠标事件处理区域错误 MouseArea 原本错误地放置在图标 contentItem 内部,导致鼠标事件只能在图标 图像区域内被捕获,而不是在整个委托项区域内。这导致了糟糕的用户体验,拖放 和点击操作只有在直接点击图标图像时才有效,而不是在周围区域。 将 MouseArea 从图标的 contentItem 内部移动到 Control 背景的直接子元素。 这确保了 MouseArea 覆盖整个委托区域,使拖放和点击操作在整个项目表面上都 能一致工作。 Log: 修复了拖放和点击操作仅在直接点击应用图标时才有效的问题 Influence: 1. 通过从应用图标项的任何区域点击和拖动来测试拖放功能 2. 验证点击操作在整个图标项表面上都能一致工作 3. 测试正常点击和拖动操作,确保它们不会相互干扰 4. 验证悬停状态和视觉反馈正常工作 5. 使用各种图标大小和委托配置进行测试
1 parent dae9abf commit 0303a68

1 file changed

Lines changed: 20 additions & 21 deletions

File tree

qml/windowed/IconItemDelegate.qml

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,26 @@ Control {
4545
ColorSelector.pressed: false
4646
ColorSelector.family: Palette.CrystalColor
4747
flat: true
48+
MouseArea {
49+
id: mouseArea
50+
anchors.fill: parent
51+
hoverEnabled: false
52+
acceptedButtons: Qt.LeftButton
53+
enabled: root.dndEnabled
54+
drag.target: root
55+
onPressed: function (mouse) {
56+
if (mouse.button === Qt.LeftButton && root.dndEnabled) {
57+
appIcon.grabToImage(function(result) {
58+
root.Drag.imageSource = result.url;
59+
})
60+
}
61+
}
62+
onClicked: {
63+
if (!drag.active) {
64+
root.itemClicked()
65+
}
66+
}
67+
}
4868
contentItem: Column {
4969
anchors.fill: parent
5070

@@ -73,27 +93,6 @@ Control {
7393
palette: DTK.makeIconPalette(root.palette)
7494
theme: ApplicationHelper.DarkType
7595
}
76-
77-
MouseArea {
78-
id: mouseArea
79-
anchors.fill: parent
80-
hoverEnabled: false
81-
acceptedButtons: Qt.LeftButton
82-
enabled: root.dndEnabled
83-
drag.target: root
84-
onPressed: function (mouse) {
85-
if (mouse.button === Qt.LeftButton && root.dndEnabled) {
86-
appIcon.grabToImage(function(result) {
87-
root.Drag.imageSource = result.url;
88-
})
89-
}
90-
}
91-
onClicked: {
92-
if (!drag.active) {
93-
root.itemClicked()
94-
}
95-
}
96-
}
9796
}
9897

9998
// as topMargin

0 commit comments

Comments
 (0)