Commit 81cf9f03 authored by Steffen Hartleib's avatar Steffen Hartleib Committed by Elvis Angelaccio

Allow interaction with folder/files with the stylus again

This Patch works for Wayland and X.

BUG: 426582
parent b02046c5
......@@ -37,6 +37,7 @@ KItemListController::KItemListController(KItemModelBase* model, KItemListView* v
m_scrollerIsScrolling(false),
m_pinchGestureInProgress(false),
m_mousePress(false),
m_isTouchEvent(false),
m_selectionBehavior(NoSelection),
m_autoActivationBehavior(ActivationAndExpansion),
m_mouseDoubleClickAction(ActivateItemOnly),
......@@ -49,7 +50,6 @@ KItemListController::KItemListController(KItemModelBase* model, KItemListView* v
m_autoActivationTimer(nullptr),
m_swipeGesture(Qt::CustomGesture),
m_twoFingerTapGesture(Qt::CustomGesture),
m_lastSource(Qt::MouseEventNotSynthesized),
m_oldSelection(),
m_keyboardAnchorIndex(-1),
m_keyboardAnchorPos(0)
......@@ -537,9 +537,8 @@ bool KItemListController::inputMethodEvent(QInputMethodEvent* event)
bool KItemListController::mousePressEvent(QGraphicsSceneMouseEvent* event, const QTransform& transform)
{
m_mousePress = true;
m_lastSource = event->source();
if (event->source() == Qt::MouseEventSynthesizedByQt) {
if (event->source() == Qt::MouseEventSynthesizedByQt && m_isTouchEvent) {
return false;
}
......@@ -576,7 +575,7 @@ bool KItemListController::mouseMoveEvent(QGraphicsSceneMouseEvent* event, const
m_view->m_tapAndHoldIndicator->setActive(false);
}
if (event->source() == Qt::MouseEventSynthesizedByQt && !m_dragActionOrRightClick) {
if (event->source() == Qt::MouseEventSynthesizedByQt && !m_dragActionOrRightClick && m_isTouchEvent) {
return false;
}
......@@ -633,6 +632,7 @@ bool KItemListController::mouseMoveEvent(QGraphicsSceneMouseEvent* event, const
bool KItemListController::mouseReleaseEvent(QGraphicsSceneMouseEvent* event, const QTransform& transform)
{
m_mousePress = false;
m_isTouchEvent = false;
if (!m_view) {
return false;
......@@ -643,7 +643,7 @@ bool KItemListController::mouseReleaseEvent(QGraphicsSceneMouseEvent* event, con
}
KItemListRubberBand* rubberBand = m_view->rubberBand();
if (event->source() == Qt::MouseEventSynthesizedByQt && !rubberBand->isActive()) {
if (event->source() == Qt::MouseEventSynthesizedByQt && !rubberBand->isActive() && m_isTouchEvent) {
return false;
}
......@@ -863,6 +863,7 @@ bool KItemListController::hoverLeaveEvent(QGraphicsSceneHoverEvent* event, const
Q_UNUSED(transform)
m_mousePress = false;
m_isTouchEvent = false;
if (!m_model || !m_view) {
return false;
......@@ -935,6 +936,15 @@ bool KItemListController::gestureEvent(QGestureEvent* event, const QTransform& t
return accepted;
}
bool KItemListController::touchBeginEvent(QGestureEvent* event, const QTransform& transform)
{
Q_UNUSED(event)
Q_UNUSED(transform)
m_isTouchEvent = true;
return false;
}
void KItemListController::tapTriggered(QTapGesture* tap, const QTransform& transform)
{
static bool scrollerWasActive = false;
......@@ -943,7 +953,6 @@ void KItemListController::tapTriggered(QTapGesture* tap, const QTransform& trans
m_dragActionOrRightClick = false;
m_isSwipeGesture = false;
m_pinchGestureInProgress = false;
m_lastSource = Qt::MouseEventSynthesizedByQt;
scrollerWasActive = m_scrollerIsScrolling;
}
......@@ -972,6 +981,7 @@ void KItemListController::tapTriggered(QTapGesture* tap, const QTransform& trans
onPress(tap->hotSpot().toPoint(), tap->position().toPoint(), Qt::NoModifier, Qt::LeftButton);
onRelease(transform.map(tap->position()), Qt::NoModifier, Qt::LeftButton, true);
}
m_isTouchEvent = false;
}
}
......@@ -979,7 +989,7 @@ void KItemListController::tapAndHoldTriggered(QGestureEvent* event, const QTrans
{
//the Qt TabAndHold gesture is triggerable with a mouse click, we don't want this
if (m_lastSource == Qt::MouseEventNotSynthesized) {
if (!m_isTouchEvent) {
return;
}
......@@ -1126,6 +1136,8 @@ bool KItemListController::processEvent(QEvent* event, const QTransform& transfor
return resizeEvent(static_cast<QGraphicsSceneResizeEvent*>(event), transform);
case QEvent::Gesture:
return gestureEvent(static_cast<QGestureEvent*>(event), transform);
case QEvent::TouchBegin:
return touchBeginEvent();
default:
break;
}
......
......@@ -301,6 +301,7 @@ private:
bool wheelEvent(QGraphicsSceneWheelEvent* event, const QTransform& transform);
bool resizeEvent(QGraphicsSceneResizeEvent* event, const QTransform& transform);
bool gestureEvent(QGestureEvent* event, const QTransform& transform);
bool touchBeginEvent(QGestureEvent* event, const QTransform& transform);
void tapTriggered(QTapGesture* tap, const QTransform& transform);
void tapAndHoldTriggered(QGestureEvent* event, const QTransform& transform);
void pinchTriggered(QGestureEvent* event, const QTransform& transform);
......@@ -319,6 +320,7 @@ private:
bool m_scrollerIsScrolling;
bool m_pinchGestureInProgress;
bool m_mousePress;
bool m_isTouchEvent;
SelectionBehavior m_selectionBehavior;
AutoActivationBehavior m_autoActivationBehavior;
MouseDoubleClickAction m_mouseDoubleClickAction;
......@@ -333,7 +335,6 @@ private:
Qt::GestureType m_swipeGesture;
Qt::GestureType m_twoFingerTapGesture;
Qt::MouseEventSource m_lastSource;
/**
* When starting a rubberband selection during a Shift- or Control-key has been
......
......@@ -91,6 +91,7 @@ KItemListView::KItemListView(QGraphicsWidget* parent) :
m_dropIndicator()
{
setAcceptHoverEvents(true);
setAcceptTouchEvents(true);
m_sizeHintResolver = new KItemListSizeHintResolver(this);
......
......@@ -10,6 +10,7 @@
// Qt
#include <QTouchEvent>
#include <QApplication>
#include <QGraphicsWidget>
KTwoFingerTapRecognizer::KTwoFingerTapRecognizer() :
QGestureRecognizer(),
......@@ -28,7 +29,9 @@ QGesture* KTwoFingerTapRecognizer::create(QObject*)
QGestureRecognizer::Result KTwoFingerTapRecognizer::recognize(QGesture* gesture, QObject* watched, QEvent* event)
{
Q_UNUSED(watched)
if (qobject_cast<QGraphicsWidget*>(watched)) {
return Ignore;
}
KTwoFingerTap* const kTwoFingerTap = static_cast<KTwoFingerTap*>(gesture);
const QTouchEvent* touchEvent = static_cast<const QTouchEvent*>(event);
......
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