Commit 66507b5d authored by Noah Davis's avatar Noah Davis 🌵
Browse files

Disable Drag and Drop for touch, fix drag and drop icons

Drag and drop conflicted with drag/flick scrolling and drag and drop was
deemed less important than scrolling or opening the context menu for
touch. Maybe in the future we can have a way to at least rearrange
favorites with touch input.

Drag and drop icons seem to have been broken by commit
0868a5ae and are now fixed.

BUG: 450448
parent d78da3c3
Pipeline #218501 passed with stage
in 3 minutes and 17 seconds
......@@ -53,6 +53,8 @@ T.ItemDelegate {
property bool descriptionTruncated: false
property bool descriptionVisible: true
property Item dragIconItem: null
function openActionMenu(x = undefined, y = undefined) {
if (!hasActionList) { return; }
// fill actionList only when needed to prevent slowness when changing app categories rapidly.
......@@ -133,6 +135,7 @@ T.ItemDelegate {
MouseArea {
id: mouseArea
property bool dragEnabled: false
parent: root
anchors.fill: parent
anchors.margins: 1
......@@ -148,7 +151,7 @@ T.ItemDelegate {
acceptedButtons: Qt.LeftButton | Qt.RightButton
drag {
axis: Drag.XAndYAxis
target: root.dragEnabled ? dragItem : undefined
target: root.dragEnabled && mouseArea.dragEnabled ? dragItem : undefined
}
// Using this Item fixes drag and drop causing delegates
// to reset to a 0 X position and overlapping each other.
......@@ -172,11 +175,18 @@ T.ItemDelegate {
// Select and focus on press to improve responsiveness and touch feedback
view.currentIndex = index
root.forceActiveFocus(Qt.MouseFocusReason)
// Only enable drag and drop with a mouse.
// We don't have a good way to handle it and drag scrolling with touch.
mouseArea.dragEnabled = mouse.source === Qt.MouseEventNotSynthesized
// We normally try to open right click menus on press like Qt Widgets
if (mouse.button === Qt.RightButton) {
root.openActionMenu(mouseX, mouseY)
} else if (mouse.button === Qt.LeftButton && root.dragEnabled && root.Drag.imageSource == "") {
iconItem.grabToImage(result => {
} else if (mouseArea.dragEnabled && mouse.button === Qt.LeftButton
&& root.dragEnabled && root.dragIconItem && root.Drag.imageSource == ""
) {
root.dragIconItem.grabToImage(result => {
root.Drag.imageSource = result.url
})
}
......@@ -184,16 +194,9 @@ T.ItemDelegate {
onClicked: if (mouse.button === Qt.LeftButton) {
root.action.trigger()
}
// MouseEvents for pressAndHold use Qt.MouseEventSynthesizedByQt for mouse.source,
// which makes checking mouse.source for whether or not touch input is used useless.
onPressAndHold: if (mouse.button === Qt.LeftButton) {
/* TODO: make press and hold to open menu exclusive to touch.
* I (ndavis) tried `if (lastDeviceType & ~(PointerDevice.Mouse | PointerDevice.TouchPad))`
* with a TapHandler. lastDeviceType was gotten from the EventPoint argument of the
* grabChanged() signal. ngraham said it wouldn't work because it was preventing single
* taps on touch. I didn't have a touch screen to test it with.
*
* TODO: find a good way to expose the context menu to touch input that doesn't conflict with
* flick to scroll or drag to reorder act like right click on press and hold (with touch).
*/
root.openActionMenu(mouseX, mouseY)
}
}
......
......@@ -41,10 +41,13 @@ AbstractKickoffItemDelegate {
labelTruncated: label.truncated
descriptionVisible: false
dragIconItem: iconItem
contentItem: ColumnLayout {
spacing: root.spacing
PlasmaCore.IconItem {
id: iconItem
implicitWidth: root.icon.width
implicitHeight: root.icon.height
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
......
......@@ -48,6 +48,8 @@ AbstractKickoffItemDelegate {
descriptionTruncated: descriptionLabel.truncated
descriptionVisible: descriptionLabel.visible
dragIconItem: icon
contentItem: RowLayout {
id: row
spacing: KickoffSingleton.listItemMetrics.margins.left * 2
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment