┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/panels/information/informationpanelcontent.cpp
diff options
context:
space:
mode:
authorSteffen Hartleib <[email protected]>2020-09-13 18:53:32 +0000
committerElvis Angelaccio <[email protected]>2020-09-13 18:53:32 +0000
commitd7b33b76a18b14e9f286e4d8326b00910b9ea02a (patch)
treeade5042c74a0d172172a9327244858825076c333 /src/panels/information/informationpanelcontent.cpp
parentd899c2b401869d29558f62fba3479bf744b0577c (diff)
Improve Touch support
With this patch dolphin now supports the following touch gestures: * Tap gesture to interact/open with directories, files and so on * TapAndHold and release gesture for access to the context menu (main window, panel folder, places and information) * TapAndHold and moving gesture for drag and drop action (main windows, panel folder and places) * pinch gesture for zoom in main window * kinetic scrolling (QScroller) for main window, panel folder, panel places, panel information, setting preview and service * two fingers swipe gesture to left, right and up as shortcut to navigate back, forward and up * two finger tap gesture to toggle item selection, similar to Ctrl and left mouse click FEATURE: 385066 FIXED-IN: 20.11.80 You are currently rebasing branch 'touch' on '85241a924'.
Diffstat (limited to 'src/panels/information/informationpanelcontent.cpp')
-rw-r--r--src/panels/information/informationpanelcontent.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/panels/information/informationpanelcontent.cpp b/src/panels/information/informationpanelcontent.cpp
index d632cfcd1..ded88bd96 100644
--- a/src/panels/information/informationpanelcontent.cpp
+++ b/src/panels/information/informationpanelcontent.cpp
@@ -33,11 +33,13 @@
#include <QTextLayout>
#include <QTimer>
#include <QVBoxLayout>
+#include <QScroller>
#include <QStyle>
#include <QPainter>
#include <QBitmap>
#include <QLinearGradient>
#include <QPolygon>
+#include <QGesture>
#include "dolphin_informationpanelsettings.h"
#include "phononwidget.h"
@@ -134,6 +136,7 @@ InformationPanelContent::InformationPanelContent(QWidget* parent) :
m_metaDataArea->setFrameShape(QFrame::NoFrame);
QWidget* viewport = m_metaDataArea->viewport();
+ QScroller::grabGesture(viewport, QScroller::TouchGesture);
viewport->installEventFilter(this);
layout->addWidget(m_preview);
@@ -144,6 +147,8 @@ InformationPanelContent::InformationPanelContent(QWidget* parent) :
layout->addWidget(m_metaDataArea);
layout->addWidget(m_configureButtons);
+ grabGesture(Qt::TapAndHoldGesture);
+
m_placesItemModel = new PlacesItemModel(this);
}
@@ -338,6 +343,33 @@ bool InformationPanelContent::eventFilter(QObject* obj, QEvent* event)
return QWidget::eventFilter(obj, event);
}
+bool InformationPanelContent::event(QEvent* event)
+{
+ if (event->type() == QEvent::Gesture) {
+ gestureEvent(static_cast<QGestureEvent*>(event));
+ return true;
+ }
+ return QWidget::event(event);
+}
+
+bool InformationPanelContent::gestureEvent(QGestureEvent* event)
+{
+ if (!underMouse()) {
+ return false;
+ }
+
+ QTapAndHoldGesture* tap = static_cast<QTapAndHoldGesture*>(event->gesture(Qt::TapAndHoldGesture));
+
+ if (tap) {
+ if (tap->state() == Qt::GestureFinished) {
+ emit contextMenuRequested(tap->position().toPoint());
+ }
+ event->accept();
+ return true;
+ }
+ return false;
+}
+
void InformationPanelContent::showIcon(const KFileItem& item)
{
m_outdatedPreviewTimer->stop();