diff --git a/applets/kicker/plugin/draghelper.h b/applets/kicker/plugin/draghelper.h --- a/applets/kicker/plugin/draghelper.h +++ b/applets/kicker/plugin/draghelper.h @@ -40,16 +40,16 @@ Q_INVOKABLE bool isDrag(int oldX, int oldY, int newX, int newY) const; Q_INVOKABLE void startDrag(QQuickItem* item, const QUrl &url = QUrl(), const QIcon &icon = QIcon(), - const QString &extraMimeType = QString(), const QString &extraMimeData = QString()); + const QString &extraMimeType = QString(), const QString &extraMimeData = QString(), const bool touch = false); Q_SIGNALS: void dragIconSizeChanged() const; void dropped() const; private: int m_dragIconSize; Q_INVOKABLE void doDrag(QQuickItem* item, const QUrl &url = QUrl(), const QIcon &icon = QIcon(), - const QString &extraMimeType = QString(), const QString &extraMimeData = QString()) const; + const QString &extraMimeType = QString(), const QString &extraMimeData = QString(), const bool touch = false) const; }; #endif diff --git a/applets/kicker/plugin/draghelper.cpp b/applets/kicker/plugin/draghelper.cpp --- a/applets/kicker/plugin/draghelper.cpp +++ b/applets/kicker/plugin/draghelper.cpp @@ -54,19 +54,19 @@ } void DragHelper::startDrag(QQuickItem *item, const QUrl &url, const QIcon &icon, - const QString &extraMimeType, const QString &extraMimeData) + const QString &extraMimeType, const QString &extraMimeData, const bool touch) { // This allows the caller to return, making sure we don't crash if // the caller is destroyed mid-drag (as can happen due to a sycoca // change). QMetaObject::invokeMethod(this, "doDrag", Qt::QueuedConnection, Q_ARG(QQuickItem*, item), Q_ARG(QUrl, url), Q_ARG(QIcon, icon), - Q_ARG(QString, extraMimeType), Q_ARG(QString, extraMimeData)); + Q_ARG(QString, extraMimeType), Q_ARG(QString, extraMimeData), Q_ARG(bool, touch)); } void DragHelper::doDrag(QQuickItem *item, const QUrl &url, const QIcon &icon, - const QString &extraMimeType, const QString &extraMimeData) const + const QString &extraMimeType, const QString &extraMimeData, const bool touch) const { if (item && item->window() && item->window()->mouseGrabberItem()) { item->window()->mouseGrabberItem()->ungrabMouse(); @@ -88,6 +88,9 @@ if (!icon.isNull()) { drag->setPixmap(icon.pixmap(m_dragIconSize, m_dragIconSize)); + if (touch) { + drag->setHotSpot(QPoint(m_dragIconSize*0.5,m_dragIconSize*0.95)); + } } drag->exec(); diff --git a/applets/kickoff/package/contents/ui/KickoffListView.qml b/applets/kickoff/package/contents/ui/KickoffListView.qml --- a/applets/kickoff/package/contents/ui/KickoffListView.qml +++ b/applets/kickoff/package/contents/ui/KickoffListView.qml @@ -96,87 +96,115 @@ 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,"","", true); + } 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); + } + } } } }