Skip to content

Commit

Permalink
fix: two apps started when click in folder
Browse files Browse the repository at this point in the history
Click event is passed to lower layer item and processed by handler
of another app. Make TapHandler of left button do exclusive grab and
move all TapHandler above to content item in case that toolbutton
grab the event.

Influence: onClicked(unnecessary) slot of ToolButton might never trigger
Log: fix two apps started when click in folder
Issue: linuxdeepin/developer-center#8462
  • Loading branch information
asterwyx committed May 9, 2024
1 parent 4ed4ca1 commit 9be25a1
Showing 1 changed file with 29 additions and 30 deletions.
59 changes: 29 additions & 30 deletions qml/IconItemDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,12 @@ Control {
id: iconLoader
anchors.fill: parent
sourceComponent: root.icons !== undefined ? folderComponent : imageComponent
TapHandler {
acceptedButtons: Qt.LeftButton
onPressedChanged: {
if (pressed) {
root.Drag.hotSpot = point.pressPosition
iconLoader.grabToImage(function(result) {
root.Drag.imageSource = result.url;
})
}
}
}
DragHandler {
id: dragHandler
target: root
acceptedButtons: Qt.LeftButton
enabled: root.dndEnabled
dragThreshold: 1
onActiveChanged: {
if (active) {
// We switch to use the `dndItem` to handle Drag event since that one will always exists.
Expand Down Expand Up @@ -161,6 +151,34 @@ Control {
elide: Text.ElideRight
maximumLineCount: singleRow ? 1 : 2
}

TapHandler {
acceptedButtons: Qt.RightButton
gesturePolicy: TapHandler.WithinBounds
onTapped: {
root.menuTriggered()
}
}

TapHandler {
acceptedButtons: Qt.LeftButton
gesturePolicy: TapHandler.WithinBounds
onPressedChanged: {
if (pressed) {
root.Drag.hotSpot = mapToItem(iconLoader, point.pressPosition)
iconLoader.grabToImage(function(result) {
root.Drag.imageSource = result.url;
})
}
}
onTapped: {
if (model.itemType === ItemArrangementProxyModel.FolderItemType) {
root.folderClicked()
} else {
root.itemClicked()
}
}
}
}
ToolTip.text: root.text
ToolTip.delay: 1000
Expand Down Expand Up @@ -188,25 +206,6 @@ Control {
color1: isWindowedMode ? background : DS.Style.button.background1
color2: isWindowedMode ? background : DS.Style.button.background2
}

TapHandler {
acceptedButtons: Qt.LeftButton
onTapped: {
if (model.itemType === ItemArrangementProxyModel.FolderItemType) {
root.folderClicked()
} else {
root.itemClicked()
}
}
}

TapHandler {
acceptedButtons: Qt.RightButton
gesturePolicy: TapHandler.WithinBounds
onTapped: {
root.menuTriggered()
}
}
}
background: DebugBounding { }

Expand Down

0 comments on commit 9be25a1

Please sign in to comment.