Commit 0322d1a2 authored by Steffen Hartleib's avatar Steffen Hartleib Committed by Nate Graham
Browse files

Improved Touch support for Kickoff

Summary:
- enabled touch scrolling in Kickoff
- open the correct category in the application tab
- open the context menu with touch (tapandhold gesture similar to Windows 10)
- start drag action with touch similar to Windows 10

BUG: 406359
BUG: 406361
FIXED-IN: 5.18

Reviewers: #plasma, hein, ngraham

Reviewed By: ngraham

Subscribers: niccolove, khuoman, mart, sbergeron, davidedmundson, ngraham, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D21829
parent b6077552
......@@ -96,87 +96,114 @@ FocusScope {
criteria: ViewSection.FullString
delegate: SectionDelegate {}
}
}
}
MouseArea {
anchors.left: parent.left
MouseArea {
anchors.left: parent.left
width: scrollArea.viewport.width
height: parent.height
width: scrollArea.viewport.width
height: parent.height
id: mouseArea
id: mouseArea
property Item pressed: null
property int pressX: -1
property int pressY: -1
property Item pressed: null
property int pressX: -1
property int pressY: -1
property bool tapAndHold: false
hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.RightButton
hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.RightButton
onPressed: {
var mapped = listView.mapToItem(listView.contentItem, mouse.x, mouse.y);
var item = listView.itemAt(mapped.x, mapped.y);
onPressed: {
var mapped = listView.mapToItem(listView.contentItem, mouse.x, mouse.y);
var item = listView.itemAt(mapped.x, mapped.y);
if (!item) {
return;
}
if (!item) {
return;
}
if (mouse.buttons & Qt.RightButton) {
if (item.hasActionList) {
mapped = listView.contentItem.mapToItem(item, mapped.x, mapped.y);
listView.currentItem.openActionMenu(mapped.x, mapped.y);
if (mouse.buttons & Qt.RightButton) {
if (item.hasActionList) {
mapped = listView.contentItem.mapToItem(item, mapped.x, mapped.y);
listView.currentItem.openActionMenu(mapped.x, mapped.y);
}
} else {
pressed = item;
pressX = mouse.x;
pressY = mouse.y;
}
}
} else {
pressed = item;
pressX = mouse.x;
pressY = mouse.y;
}
}
onReleased: {
var mapped = listView.mapToItem(listView.contentItem, mouse.x, mouse.y);
var item = listView.itemAt(mapped.x, mapped.y);
if (item && pressed === item) {
if (item.appView) {
view.state = "OutgoingLeft";
} else {
item.activate();
onReleased: {
var mapped = listView.mapToItem(listView.contentItem, mouse.x, mouse.y);
var item = listView.itemAt(mapped.x, mapped.y);
if (item && pressed === item && !tapAndHold) {
if (item.appView) {
if (mouse.source == Qt.MouseEventSynthesizedByQt) {
positionChanged(mouse);
}
view.state = "OutgoingLeft";
} else {
item.activate();
}
listView.currentIndex = -1;
}
if (tapAndHold && mouse.source == Qt.MouseEventSynthesizedByQt) {
if (item.hasActionList) {
mapped = listView.contentItem.mapToItem(item, mapped.x, mapped.y);
listView.currentItem.openActionMenu(mapped.x, mapped.y);
}
}
pressed = null;
pressX = -1;
pressY = -1;
tapAndHold = false;
}
listView.currentIndex = -1;
}
pressed = null;
pressX = -1;
pressY = -1;
}
onPositionChanged: {
var mapped = listView.mapToItem(listView.contentItem, mouse.x, mouse.y);
var item = listView.itemAt(mapped.x, mapped.y);
if (item) {
listView.currentIndex = item.itemIndex;
} else {
listView.currentIndex = -1;
}
onPositionChanged: {
var mapped = listView.mapToItem(listView.contentItem, mouse.x, mouse.y);
var item = listView.itemAt(mapped.x, mapped.y);
if (item) {
listView.currentIndex = item.itemIndex;
} else {
listView.currentIndex = -1;
}
if (mouse.source != Qt.MouseEventSynthesizedByQt || tapAndHold) {
if (pressed && pressX != -1 && pressed.url && dragHelper.isDrag(pressX, pressY, mouse.x, mouse.y)) {
kickoff.dragSource = item;
if (mouse.source == Qt.MouseEventSynthesizedByQt) {
dragHelper.dragIconSize = units.iconSizes.huge
dragHelper.startDrag(kickoff, pressed.url, pressed.decoration);
} else {
dragHelper.dragIconSize = units.iconSizes.medium
dragHelper.startDrag(kickoff, pressed.url, pressed.decoration);
}
pressed = null;
pressX = -1;
pressY = -1;
tapAndHold = false;
}
}
}
if (pressed && pressX != -1 && pressed.url && dragHelper.isDrag(pressX, pressY, mouse.x, mouse.y)) {
kickoff.dragSource = item;
dragHelper.startDrag(root, pressed.url, pressed.decoration);
pressed = null;
pressX = -1;
pressY = -1;
}
}
onContainsMouseChanged: {
if (!containsMouse) {
pressed = null;
pressX = -1;
pressY = -1;
tapAndHold = false;
}
}
onContainsMouseChanged: {
if (!containsMouse) {
pressed = null;
pressX = -1;
pressY = -1;
onPressAndHold: {
if (mouse.source == Qt.MouseEventSynthesizedByQt) {
tapAndHold = true;
positionChanged(mouse);
}
}
}
}
}
......
Markdown is supported
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