From: Daniel Albers Date: Sun, 3 Jul 2016 18:45:30 +0000 (+0200) Subject: Merge pull request #226 - Fix touch pads being handled as touch screens X-Git-Tag: travis-deploy-test~469 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=ec474657f6af9f598a9b936f56c6ef7b863a77c9;hp=5b164bbc62960cea62a31287f679197b623ad7ac Merge pull request #226 - Fix touch pads being handled as touch screens Fix a bug with (multi) touch pad usage (e. g. on MacBooks) introduced with basic touch support (GH-187). Closes GH-226. --- diff --git a/src/qtui/chatview.cpp b/src/qtui/chatview.cpp index 7da0847b..cb9d740e 100644 --- a/src/qtui/chatview.cpp +++ b/src/qtui/chatview.cpp @@ -109,7 +109,11 @@ bool ChatView::event(QEvent *event) } } - if (event->type() == QEvent::TouchBegin) { +#if QT_VERSION >= 0x050000 + if (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->device()->type()==QTouchDevice::TouchScreen) { +#else + if (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->deviceType()==QTouchEvent::TouchScreen) { +#endif // Enable scrolling by draging, disable selecting/clicking content setDragMode(QGraphicsView::ScrollHandDrag); setInteractive(false); @@ -145,8 +149,11 @@ bool ChatView::event(QEvent *event) } // Applying the movement happens automatically by the drag-mode } - - if (event->type() == QEvent::Wheel || event->type() == QEvent::TouchBegin || event->type() == QEvent::TouchUpdate) { +#if QT_VERSION >= 0x050000 + if (event->type() == QEvent::Wheel || (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->device()->type()==QTouchDevice::TouchScreen) || event->type() == QEvent::TouchUpdate) { +#else + if (event->type() == QEvent::Wheel || (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->deviceType()==QTouchEvent::TouchScreen) || event->type() == QEvent::TouchUpdate) { +#endif if (!verticalScrollBar()->isVisible()) { scene()->requestBacklog(); return true; diff --git a/src/uisupport/treeviewtouch.cpp b/src/uisupport/treeviewtouch.cpp index 0ef3b366..96845ac4 100644 --- a/src/uisupport/treeviewtouch.cpp +++ b/src/uisupport/treeviewtouch.cpp @@ -33,7 +33,11 @@ TreeViewTouch::TreeViewTouch(QWidget *parent) bool TreeViewTouch::event(QEvent *event) { - if (event->type() == QEvent::TouchBegin) { +#if QT_VERSION >= 0x050000 + if (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->device()->type()==QTouchDevice::TouchScreen) { +#else + if (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->deviceType()==QTouchEvent::TouchScreen) { +#endif // Register that we may be scrolling, set the scroll mode to scroll-per-pixel // and accept the event (return true) so that we will receive TouchUpdate and TouchEnd/TouchCancel _touchScrollInProgress = true;