diff --git a/components/mobileshell/components/swipearea.cpp b/components/mobileshell/components/swipearea.cpp index c59c5aa9..879cfcb7 100644 --- a/components/mobileshell/components/swipearea.cpp +++ b/components/mobileshell/components/swipearea.cpp @@ -22,6 +22,17 @@ SwipeArea::SwipeArea(QQuickItem *parent) setFiltersChildMouseEvents(true); } +SwipeArea::Mode SwipeArea::mode() +{ + return m_mode; +} + +void SwipeArea::setMode(Mode mode) +{ + m_mode = mode; + Q_EMIT modeChanged(); +} + bool SwipeArea::interactive() { return m_interactive; @@ -251,7 +262,11 @@ void SwipeArea::handleMoveEvent(QPointerEvent *event, QPointF point) if (!m_stealMouse) { // if we haven't reached the swipe registering threshold yet, don't start the swipe - if (qAbs(point.manhattanLength() - m_pressPos.manhattanLength()) < SWIPE_REGISTER_THRESHOLD) { + if (m_mode == Mode::VerticalOnly && qAbs(point.y() - m_pressPos.y()) < SWIPE_REGISTER_THRESHOLD) { + return; + } else if (m_mode == Mode::HorizontalOnly && qAbs(point.x() - m_pressPos.x()) < SWIPE_REGISTER_THRESHOLD) { + return; + } else if (m_mode == Mode::BothAxis && qAbs(point.manhattanLength() - m_pressPos.manhattanLength()) < SWIPE_REGISTER_THRESHOLD) { return; } diff --git a/components/mobileshell/components/swipearea.h b/components/mobileshell/components/swipearea.h index 16674179..1e89b7be 100644 --- a/components/mobileshell/components/swipearea.h +++ b/components/mobileshell/components/swipearea.h @@ -22,6 +22,7 @@ class SwipeArea : public QQuickItem { Q_OBJECT + Q_PROPERTY(SwipeArea::Mode mode READ mode WRITE setMode NOTIFY modeChanged) Q_PROPERTY(bool interactive READ interactive NOTIFY interactiveChanged) Q_PROPERTY(bool moving READ moving NOTIFY movingChanged) Q_PROPERTY(bool pressed READ pressed NOTIFY pressedChanged) @@ -31,11 +32,18 @@ class SwipeArea : public QQuickItem public: SwipeArea(QQuickItem *parent = nullptr); + enum Mode { BothAxis = 0, VerticalOnly, HorizontalOnly }; + Q_ENUM(Mode) + + Mode mode(); + void setMode(Mode mode); + bool interactive(); bool moving(); bool pressed(); Q_SIGNALS: + void modeChanged(); void interactiveChanged(); void movingChanged(); void pressedChanged(); @@ -69,6 +77,7 @@ private: void resetSwipe(); + Mode m_mode = Mode::BothAxis; bool m_interactive = true; bool m_pressed = false; diff --git a/components/mobileshell/qml/actiondrawer/ActionDrawer.qml b/components/mobileshell/qml/actiondrawer/ActionDrawer.qml index 14033175..cc775288 100644 --- a/components/mobileshell/qml/actiondrawer/ActionDrawer.qml +++ b/components/mobileshell/qml/actiondrawer/ActionDrawer.qml @@ -231,6 +231,7 @@ Item { MobileShell.SwipeArea { id: swipeArea + mode: MobileShell.SwipeArea.VerticalOnly anchors.fill: parent onSwipeStarted: { diff --git a/components/mobileshell/qml/actiondrawer/ActionDrawerOpenSurface.qml b/components/mobileshell/qml/actiondrawer/ActionDrawerOpenSurface.qml index f44abc0f..e5e8810f 100644 --- a/components/mobileshell/qml/actiondrawer/ActionDrawerOpenSurface.qml +++ b/components/mobileshell/qml/actiondrawer/ActionDrawerOpenSurface.qml @@ -14,6 +14,7 @@ import org.kde.plasma.private.mobileshell as MobileShell */ MobileShell.SwipeArea { id: root + mode: MobileShell.SwipeArea.VerticalOnly required property ActionDrawer actionDrawer diff --git a/lookandfeel/contents/lockscreen/FlickContainer.qml b/lookandfeel/contents/lockscreen/FlickContainer.qml index a58d6432..a844dc19 100644 --- a/lookandfeel/contents/lockscreen/FlickContainer.qml +++ b/lookandfeel/contents/lockscreen/FlickContainer.qml @@ -9,6 +9,7 @@ import org.kde.plasma.private.mobileshell as MobileShell MobileShell.SwipeArea { id: root + mode: MobileShell.SwipeArea.VerticalOnly property int position: 0