diff --git a/CMakeLists.txt b/CMakeLists.txt index 463393eb5c6..a646dd76c40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -269,23 +269,6 @@ IF (WITH_QTMOBILITY) FIND_PACKAGE(QtMobility 1.1.0) ENDIF (WITH_QTMOBILITY) -IF (ANDROID) - SET (DEFAULT_WITH_TOUCH TRUE) -ELSE (ANDROID) - SET (DEFAULT_WITH_TOUCH FALSE) -ENDIF (ANDROID) - -#Add a touch mode if Qt has Qt Gestures -SET (WITH_TOUCH ${DEFAULT_WITH_TOUCH} CACHE BOOL "Determines if touch interface related code should be build") - -IF (WITH_TOUCH) - # following variable is used in qgsconfig.h - SET (HAVE_TOUCH TRUE) - MESSAGE (STATUS "Touch support enabled") -ELSE (WITH_TOUCH) - MESSAGE (STATUS "Touch support disabled") -ENDIF (WITH_TOUCH) - # search for QScintilla2 (C++ lib) FIND_PACKAGE(QScintilla REQUIRED) diff --git a/cmake_templates/qgsconfig.h.in b/cmake_templates/qgsconfig.h.in index d96e70044c5..ffb6651208c 100644 --- a/cmake_templates/qgsconfig.h.in +++ b/cmake_templates/qgsconfig.h.in @@ -48,8 +48,6 @@ #cmakedefine HAVE_ORACLE -#cmakedefine HAVE_TOUCH - #cmakedefine HAVE_OSGEARTHQT #cmakedefine SERVER_SKIP_ECW diff --git a/doc/api_break.dox b/doc/api_break.dox index 07dbbe8640b..d7ff1331434 100644 --- a/doc/api_break.dox +++ b/doc/api_break.dox @@ -269,6 +269,7 @@ should now call QgsCoordinateReferenceSystem::invalidateCache() and QgsCoordinat - QgsMapCanvasMap. It is an internal class used by map canvas. - QgsMapLayerRegistry. Its functionality has been moved to QgsProject. - QgsMapRenderer. It has been replaced by QgsMapRendererJob with subclasses and QgsMapSettings. +- QgsMapToolTouch. The touch navigation functionality is now built into the standard QgsMapToolPan tool. - QgsPhotoWidgetWrapper was removed. Use QgsExternalResourceWidgetWrapper instead. - QgsPseudoColorShader. This shader has been broken for some time and was replaced by QgsSingleBandPseudoColorRenderer. - QgsProjectBadLayerGuiHandler was removed. It was unused in QGIS code and barely useful. Implement your own QgsProjectBadLayerHandler subclass if needed. @@ -360,6 +361,7 @@ QgisInterface {#qgis_api_break_3_0_QgisInterface} - fileMenu() has been removed, use projectMenu() instead. - actionRemoveLayer was removed as it no longer exists. +- actionTouch was removed, as the corresponding action no longer exists (see notes on QgsMapToolTouch) QgsAbstractGeometry {#qgis_api_break_3_0_QgsAbstractGeometry} diff --git a/ms-windows/cygwin/package.sh b/ms-windows/cygwin/package.sh index cad4460642b..87333b65570 100644 --- a/ms-windows/cygwin/package.sh +++ b/ms-windows/cygwin/package.sh @@ -28,7 +28,6 @@ cmake -D BUILDNAME="cygwin" \ -D WITH_QSPATIALITE=TRUE \ -D WITH_SERVER=TRUE \ -D WITH_GLOBE=TRUE \ - -D WITH_TOUCH=TRUE \ -D WITH_ORACLE=FALSE \ -D CMAKE_LEGACY_CYGWIN_WIN32=0 \ -D PYUIC4_PROGRAM=/usr/lib/python2.7/site-packages/PyQt4/pyuic4 \ diff --git a/ms-windows/osgeo4w/package-nightly.cmd b/ms-windows/osgeo4w/package-nightly.cmd index 4adfe3939a2..f2d158a546a 100644 --- a/ms-windows/osgeo4w/package-nightly.cmd +++ b/ms-windows/osgeo4w/package-nightly.cmd @@ -167,7 +167,6 @@ cmake -G Ninja ^ -D WITH_GRASS7=TRUE ^ -D GRASS_PREFIX7=%GRASS72_PATH:\=/% ^ -D WITH_GLOBE=FALSE ^ - -D WITH_TOUCH=TRUE ^ -D WITH_ORACLE=TRUE ^ -D WITH_CUSTOM_WIDGETS=TRUE ^ -D CMAKE_BUILD_TYPE=%BUILDCONF% ^ diff --git a/ms-windows/osgeo4w/package.cmd b/ms-windows/osgeo4w/package.cmd index ab12b49eccb..dd284d1f2da 100644 --- a/ms-windows/osgeo4w/package.cmd +++ b/ms-windows/osgeo4w/package.cmd @@ -160,7 +160,6 @@ cmake -G Ninja ^ -D WITH_GRASS7=TRUE ^ -D GRASS_PREFIX7=%GRASS72_PATH:\=/% ^ -D WITH_GLOBE=FALSE ^ - -D WITH_TOUCH=TRUE ^ -D WITH_ORACLE=TRUE ^ -D WITH_CUSTOM_WIDGETS=TRUE ^ -D CMAKE_CXX_FLAGS_RELEASE="/MD /MP /O2 /Ob2 /D NDEBUG" ^ diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index e6637f401ab..52b092ffe52 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -130,10 +130,6 @@ ELSE(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} ARM) ENDIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") -IF(NOT WITH_TOUCH) - SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} HAVE_TOUCH) -ENDIF(NOT WITH_TOUCH) - IF(NOT QT_MOBILITY_LOCATION_FOUND) SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} MOBILITY_LOCATION) ENDIF(NOT QT_MOBILITY_LOCATION_FOUND) diff --git a/python/gui/gui.sip b/python/gui/gui.sip index c105a1bc6a3..225ef6a593c 100644 --- a/python/gui/gui.sip +++ b/python/gui/gui.sip @@ -117,7 +117,6 @@ %Include qgsmaptoolidentify.sip %Include qgsmaptoolidentifyfeature.sip %Include qgsmaptoolpan.sip -%Include qgsmaptooltouch.sip %Include qgsmaptoolzoom.sip %Include qgsmaplayerstylemanagerwidget.sip %Include qgsmessagebar.sip diff --git a/python/gui/qgisinterface.sip b/python/gui/qgisinterface.sip index 2c6d1be6482..915ad2dc081 100644 --- a/python/gui/qgisinterface.sip +++ b/python/gui/qgisinterface.sip @@ -404,8 +404,6 @@ class QgisInterface : QObject // View menu actions //! Get access to the native pan action. Call trigger() on it to set the default pan map tool. virtual QAction *actionPan() = 0; - //! Get access to the native touch action. - virtual QAction *actionTouch() = 0; //! Get access to the native pan to selected action. Call trigger() on it to pan the map canvas to the selection. virtual QAction *actionPanToSelected() = 0; //! Get access to the native zoom in action. Call trigger() on it to set the default zoom in map tool. diff --git a/python/gui/qgsmapcanvas.sip b/python/gui/qgsmapcanvas.sip index 7a23a8479cf..b4a212ed095 100644 --- a/python/gui/qgsmapcanvas.sip +++ b/python/gui/qgsmapcanvas.sip @@ -1,5 +1,3 @@ -%Feature HAVE_TOUCH - /** \ingroup gui * Map canvas is a class for displaying all GIS data types on a canvas. */ @@ -486,10 +484,9 @@ class QgsMapCanvas : QGraphicsView void messageEmitted( const QString& title, const QString& message, QgsMessageBar::MessageLevel = QgsMessageBar::INFO ); protected: -%If (HAVE_TOUCH) + //! Overridden standard event to be gestures aware bool event( QEvent * e ); -%End //! Overridden key press event void keyPressEvent( QKeyEvent * e ); diff --git a/python/gui/qgsmaptool.sip b/python/gui/qgsmaptool.sip index a5c94a67c13..f03c5c67d23 100644 --- a/python/gui/qgsmaptool.sip +++ b/python/gui/qgsmaptool.sip @@ -71,10 +71,8 @@ class QgsMapTool : QObject //! Key event for overriding. Default implementation does nothing. virtual void keyReleaseEvent( QKeyEvent* e ); -%If (HAVE_TOUCH) //! gesture event for overriding. Default implementation does nothing. virtual bool gestureEvent( QGestureEvent* e ); -%End /** Use this to associate a QAction to this maptool. Then when the setMapTool * method of mapcanvas is called the action state will be set to on. diff --git a/python/gui/qgsmaptooltouch.sip b/python/gui/qgsmaptooltouch.sip deleted file mode 100644 index 57ff8525baa..00000000000 --- a/python/gui/qgsmaptooltouch.sip +++ /dev/null @@ -1,22 +0,0 @@ -%If (HAVE_TOUCH) -class QgsMapToolTouch : QgsMapTool -{ -%TypeHeaderCode -#include -%End - - public: - //! constructor - QgsMapToolTouch( QgsMapCanvas* canvas ); - - ~QgsMapToolTouch(); - - void activate(); - void deactivate(); - virtual void canvasMoveEvent( QgsMapMouseEvent *e ); - virtual void canvasReleaseEvent( QgsMapMouseEvent *e ); - virtual void canvasDoubleClickEvent( QgsMapMouseEvent *e ); - virtual Flags flags() const; - bool gestureEvent( QGestureEvent *e ); -}; -%End diff --git a/rpm/qgis.spec.template b/rpm/qgis.spec.template index 9f217f98bcb..720976e7379 100644 --- a/rpm/qgis.spec.template +++ b/rpm/qgis.spec.template @@ -198,7 +198,6 @@ gzip ChangeLog # Necessary for the test suite #export LD_LIBRARY_PATH=%{_builddir}%{name}-%{version}/output/%{_lib} -#Info: TOUCH needs Qt >= 4.5 %cmake \ %{_cmake_skip_rpath} \ -D QGIS_LIB_SUBDIR=%{_lib} \ @@ -224,7 +223,6 @@ gzip ChangeLog -D WITH_INTERNAL_SIX:BOOL=FALSE \ -D WITH_PYSPATIALITE:BOOL=FALSE \ -D WITH_SERVER:BOOL=TRUE \ - -D WITH_TOUCH:BOOL=TRUE \ %{configure_with_spatialite} \ . #-D WITH_QTMOBILITY:BOOL=TRUE \ diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index 32ed91e0291..6d36ad7406f 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -363,10 +363,6 @@ extern "C" #include #endif -#ifdef HAVE_TOUCH -#include "qgsmaptooltouch.h" -#endif - class QTreeWidgetItem; /** Set the application title bar text @@ -1097,14 +1093,11 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh QgsDebugMsg( "Tips are disabled" ); } -#ifdef HAVE_TOUCH - //add reacting to long click in touch - grabGesture( Qt::TapAndHoldGesture ); -#else - //remove mActionTouch button - delete mActionTouch; - mActionTouch = nullptr; -#endif + if ( ! QTouchDevice::devices().isEmpty() ) + { + //add reacting to long click in touch + grabGesture( Qt::TapAndHoldGesture ); + } // supposedly all actions have been added, now register them to the shortcut manager QgsShortcutsManager::instance()->registerAllChildren( this ); @@ -1258,9 +1251,6 @@ QgisApp::~QgisApp() delete mMapTools.mZoomIn; delete mMapTools.mZoomOut; delete mMapTools.mPan; -#ifdef HAVE_TOUCH - delete mMapTools.mTouch; -#endif delete mMapTools.mAddFeature; delete mMapTools.mAddPart; delete mMapTools.mAddRing; @@ -1501,12 +1491,10 @@ bool QgisApp::event( QEvent * event ) openFile( foe->file() ); done = true; } -#ifdef HAVE_TOUCH - else if ( event->type() == QEvent::Gesture ) + else if ( !QTouchDevice::devices().isEmpty() && event->type() == QEvent::Gesture ) { done = gestureEvent( static_cast( event ) ); } -#endif else { // pass other events to base class @@ -1644,10 +1632,6 @@ void QgisApp::createActions() connect( mActionOffsetCurve, SIGNAL( triggered() ), this, SLOT( offsetCurve() ) ); // View Menu Items - -#ifdef HAVE_TOUCH - connect( mActionTouch, SIGNAL( triggered() ), this, SLOT( touch() ) ); -#endif connect( mActionPan, SIGNAL( triggered() ), this, SLOT( pan() ) ); connect( mActionPanToSelected, SIGNAL( triggered() ), this, SLOT( panToSelected() ) ); connect( mActionZoomIn, SIGNAL( triggered() ), this, SLOT( zoomIn() ) ); @@ -1878,9 +1862,6 @@ void QgisApp::createActionGroups() // // Map Tool Group mMapToolGroup = new QActionGroup( this ); -#ifdef HAVE_TOUCH - mMapToolGroup->addAction( mActionTouch ); -#endif mMapToolGroup->addAction( mActionPan ); mMapToolGroup->addAction( mActionZoomIn ); mMapToolGroup->addAction( mActionZoomOut ); @@ -2689,9 +2670,6 @@ void QgisApp::setTheme( const QString& theThemeName ) mActionZoomFullExtent->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomFullExtent.svg" ) ) ); mActionZoomToSelected->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomToSelected.svg" ) ) ); mActionShowRasterCalculator->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionShowRasterCalculator.png" ) ) ); -#ifdef HAVE_TOUCH - mActionTouch->setIcon( QgsApplication::getThemeIcon( "/mActionTouch.svg" ) ); -#endif mActionPan->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionPan.svg" ) ) ); mActionPanToSelected->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionPanToSelected.svg" ) ) ); mActionZoomLast->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomLast.svg" ) ) ); @@ -2868,10 +2846,6 @@ void QgisApp::createCanvasTools() mMapTools.mZoomOut->setAction( mActionZoomOut ); mMapTools.mPan = new QgsMapToolPan( mMapCanvas ); mMapTools.mPan->setAction( mActionPan ); -#ifdef HAVE_TOUCH - mMapTools.mTouch = new QgsMapToolTouch( mMapCanvas ); - mMapTools.mTouch->setAction( mActionTouch ); -#endif mMapTools.mIdentify = new QgsMapToolIdentifyAction( mMapCanvas ); mMapTools.mIdentify->setAction( mActionIdentify ); connect( mMapTools.mIdentify, SIGNAL( copyToClipboard( QgsFeatureStore & ) ), @@ -4598,15 +4572,10 @@ void QgisApp::fileNew( bool thePromptToSaveFlag, bool forceBlank ) } // set the initial map tool -#ifndef HAVE_TOUCH mMapCanvas->setMapTool( mMapTools.mPan ); mNonEditMapTool = mMapTools.mPan; // signals are not yet setup to catch this -#else - mMapCanvas->setMapTool( mMapTools.mTouch ); - mNonEditMapTool = mMapTools.mTouch; // signals are not yet setup to catch this -#endif -} // QgisApp::fileNew(bool thePromptToSaveFlag) +} bool QgisApp::fileNewFromTemplate( const QString& fileName ) { @@ -5849,13 +5818,6 @@ void QgisApp::pan() mMapCanvas->setMapTool( mMapTools.mPan ); } -#ifdef HAVE_TOUCH -void QgisApp::touch() -{ - mMapCanvas->setMapTool( mMapTools.mTouch ); -} -#endif - void QgisApp::zoomFull() { mMapCanvas->zoomToFullExtent(); @@ -12129,8 +12091,6 @@ void QgisApp::onLayerError( const QString& msg ) mInfoBar->pushCritical( tr( "Layer %1" ).arg( layer->name() ), msg ); } - -#ifdef HAVE_TOUCH bool QgisApp::gestureEvent( QGestureEvent *event ) { if ( QGesture *tapAndHold = event->gesture( Qt::TapAndHoldGesture ) ) @@ -12153,7 +12113,6 @@ void QgisApp::tapAndHoldTriggered( QTapAndHoldGesture *gesture ) QApplication::postEvent( receiver, new QMouseEvent( QEvent::MouseButtonRelease, receiver->mapFromGlobal( pos ), Qt::RightButton, Qt::RightButton, Qt::NoModifier ) ); } } -#endif #ifdef Q_OS_WIN LONG WINAPI QgisApp::qgisCrashDump( struct _EXCEPTION_POINTERS *ExceptionInfo ) diff --git a/src/app/qgisapp.h b/src/app/qgisapp.h index a151ac07f11..1d66c7e43fb 100644 --- a/src/app/qgisapp.h +++ b/src/app/qgisapp.h @@ -131,10 +131,8 @@ class QgsDiagramProperties; #include "ui_qgisapp.h" #include "qgis_app.h" -#ifdef HAVE_TOUCH #include #include -#endif #ifdef Q_OS_WIN #include @@ -352,7 +350,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow QAction *actionSnappingOptions() { return mActionSnappingOptions; } QAction *actionOffsetCurve() { return mActionOffsetCurve; } QAction *actionPan() { return mActionPan; } - QAction *actionTouch() { return mActionTouch; } QAction *actionPanToSelected() { return mActionPanToSelected; } QAction *actionZoomIn() { return mActionZoomIn; } QAction *actionZoomOut() { return mActionZoomOut; } @@ -1222,10 +1219,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow void zoomIn(); //! Set map tool to pan void pan(); -#ifdef HAVE_TOUCH - //! Set map tool to touch - void touch(); -#endif //! Identify feature(s) on the currently selected layer void identify(); //! Measure distance @@ -1590,9 +1583,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow : mZoomIn( nullptr ) , mZoomOut( nullptr ) , mPan( nullptr ) -#ifdef HAVE_TOUCH - , mTouch( 0 ) -#endif , mIdentify( nullptr ) , mFeatureAction( nullptr ) , mMeasureDist( nullptr ) @@ -1639,9 +1629,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow QgsMapTool *mZoomIn; QgsMapTool *mZoomOut; QgsMapTool *mPan; -#ifdef HAVE_TOUCH - QgsMapTool *mTouch; -#endif QgsMapTool *mIdentify; QgsMapTool *mFeatureAction; QgsMapTool *mMeasureDist; @@ -1865,10 +1852,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow QStackedWidget* mCentralContainer; int mProjOpen; -#ifdef HAVE_TOUCH + bool gestureEvent( QGestureEvent *event ); void tapAndHoldTriggered( QTapAndHoldGesture *gesture ); -#endif friend class TestQgisAppPython; }; diff --git a/src/app/qgisappinterface.cpp b/src/app/qgisappinterface.cpp index 5a438c3b374..acf54654f75 100644 --- a/src/app/qgisappinterface.cpp +++ b/src/app/qgisappinterface.cpp @@ -573,7 +573,6 @@ QAction *QgisAppInterface::actionNodeTool() { return qgis->actionNodeTool(); } //! View menu actions QAction *QgisAppInterface::actionPan() { return qgis->actionPan(); } -QAction *QgisAppInterface::actionTouch() { return qgis->actionTouch(); } QAction *QgisAppInterface::actionPanToSelected() { return qgis->actionPanToSelected(); } QAction *QgisAppInterface::actionZoomIn() { return qgis->actionZoomIn(); } QAction *QgisAppInterface::actionZoomOut() { return qgis->actionZoomOut(); } diff --git a/src/app/qgisappinterface.h b/src/app/qgisappinterface.h index f7e4a6315a9..1dad2e91288 100644 --- a/src/app/qgisappinterface.h +++ b/src/app/qgisappinterface.h @@ -392,7 +392,6 @@ class APP_EXPORT QgisAppInterface : public QgisInterface //! View menu actions virtual QAction *actionPan() override; - virtual QAction *actionTouch() override; virtual QAction *actionPanToSelected() override; virtual QAction *actionZoomIn() override; virtual QAction *actionZoomOut() override; diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 99f80b44fae..738878cb8e8 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -314,14 +314,6 @@ SET(QGIS_GUI_SRCS qgsfiledownloader.cpp ) - -IF (WITH_TOUCH) - SET(QGIS_GUI_SRCS - ${QGIS_GUI_SRCS} - qgsmaptooltouch.cpp - ) -ENDIF (WITH_TOUCH) - SET(QGIS_GUI_MOC_HDRS qgisinterface.h qgsactionmenu.h @@ -691,13 +683,6 @@ SET(QGIS_GUI_HDRS symbology-ng/qgssymbolwidgetcontext.h ) -IF (WITH_TOUCH) - SET(QGIS_GUI_HDRS - ${QGIS_GUI_HDRS} - qgsmaptooltouch.h - ) -ENDIF (WITH_TOUCH) - SET(QGIS_GUI_UI_HDRS ${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsauthauthoritieseditor.h ${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsauthcertificateinfo.h diff --git a/src/gui/qgisinterface.h b/src/gui/qgisinterface.h index f0841d32564..284d65de510 100644 --- a/src/gui/qgisinterface.h +++ b/src/gui/qgisinterface.h @@ -458,8 +458,6 @@ class GUI_EXPORT QgisInterface : public QObject // View menu actions //! Get access to the native pan action. Call trigger() on it to set the default pan map tool. virtual QAction *actionPan() = 0; - //! Get access to the native touch action. - virtual QAction *actionTouch() = 0; //! Get access to the native pan to selected action. Call trigger() on it to pan the map canvas to the selection. virtual QAction *actionPanToSelected() = 0; //! Get access to the native zoom in action. Call trigger() on it to set the default zoom in map tool. diff --git a/src/gui/qgsmapcanvas.cpp b/src/gui/qgsmapcanvas.cpp index 61fe7763d15..48101a3f954 100644 --- a/src/gui/qgsmapcanvas.cpp +++ b/src/gui/qgsmapcanvas.cpp @@ -1962,26 +1962,23 @@ void QgsMapCanvas::mapToolDestroyed() mMapTool = nullptr; } -#ifdef HAVE_TOUCH bool QgsMapCanvas::event( QEvent * e ) { - bool done = false; - if ( e->type() == QEvent::Gesture ) + if ( !QTouchDevice::devices().empty() ) { - // call handler of current map tool - if ( mMapTool ) + if ( e->type() == QEvent::Gesture ) { - done = mMapTool->gestureEvent( static_cast( e ) ); + // call handler of current map tool + if ( mMapTool ) + { + return mMapTool->gestureEvent( static_cast( e ) ); + } } } - else - { - // pass other events to base class - done = QGraphicsView::event( e ); - } - return done; + + // pass other events to base class + return QGraphicsView::event( e ); } -#endif void QgsMapCanvas::refreshAllLayers() { diff --git a/src/gui/qgsmapcanvas.h b/src/gui/qgsmapcanvas.h index a2d158f23fe..f94fef2f8fe 100644 --- a/src/gui/qgsmapcanvas.h +++ b/src/gui/qgsmapcanvas.h @@ -33,10 +33,8 @@ #include "qgsmapsettings.h" // TEMPORARY #include "qgsprevieweffect.h" //for QgsPreviewEffect::PreviewMode -#ifdef HAVE_TOUCH #include #include "qgis_gui.h" -#endif class QWheelEvent; class QPixmap; @@ -555,10 +553,9 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView void messageEmitted( const QString& title, const QString& message, QgsMessageBar::MessageLevel = QgsMessageBar::INFO ); protected: -#ifdef HAVE_TOUCH + //! Overridden standard event to be gestures aware bool event( QEvent * e ) override; -#endif //! Overridden key press event void keyPressEvent( QKeyEvent * e ) override; diff --git a/src/gui/qgsmaptool.cpp b/src/gui/qgsmaptool.cpp index b2b7308fefd..08696183b8a 100644 --- a/src/gui/qgsmaptool.cpp +++ b/src/gui/qgsmaptool.cpp @@ -176,13 +176,11 @@ void QgsMapTool::keyReleaseEvent( QKeyEvent *e ) Q_UNUSED( e ); } -#ifdef HAVE_TOUCH bool QgsMapTool::gestureEvent( QGestureEvent *e ) { Q_UNUSED( e ); return true; } -#endif QgsMapCanvas* QgsMapTool::canvas() { diff --git a/src/gui/qgsmaptool.h b/src/gui/qgsmaptool.h index b09d1e4f39c..b6beb2b7f7d 100644 --- a/src/gui/qgsmaptool.h +++ b/src/gui/qgsmaptool.h @@ -25,10 +25,8 @@ #include #include -#ifdef HAVE_TOUCH #include #include "qgis_gui.h" -#endif class QgsMapLayer; class QgsMapCanvas; @@ -95,10 +93,8 @@ class GUI_EXPORT QgsMapTool : public QObject //! Key event for overriding. Default implementation does nothing. virtual void keyReleaseEvent( QKeyEvent* e ); -#ifdef HAVE_TOUCH //! gesture event for overriding. Default implementation does nothing. virtual bool gestureEvent( QGestureEvent* e ); -#endif /** Use this to associate a QAction to this maptool. Then when the setMapTool * method of mapcanvas is called the action state will be set to on. diff --git a/src/gui/qgsmaptoolpan.cpp b/src/gui/qgsmaptoolpan.cpp index 296ad2e0849..c8e378942b3 100644 --- a/src/gui/qgsmaptoolpan.cpp +++ b/src/gui/qgsmaptoolpan.cpp @@ -31,6 +31,23 @@ QgsMapToolPan::QgsMapToolPan( QgsMapCanvas* canvas ) mCursor = QCursor( Qt::OpenHandCursor ); } +QgsMapToolPan::~QgsMapToolPan() +{ + mCanvas->ungrabGesture( Qt::PinchGesture ); +} + +void QgsMapToolPan::activate() +{ + mCanvas->grabGesture( Qt::PinchGesture ); + QgsMapTool::activate(); +} + +void QgsMapToolPan::deactivate() +{ + mCanvas->ungrabGesture( Qt::PinchGesture ); + QgsMapTool::deactivate(); +} + void QgsMapToolPan::canvasPressEvent( QgsMapMouseEvent* e ) { if ( e->button() == Qt::LeftButton ) @@ -40,30 +57,83 @@ void QgsMapToolPan::canvasPressEvent( QgsMapMouseEvent* e ) void QgsMapToolPan::canvasMoveEvent( QgsMapMouseEvent* e ) { - if (( e->buttons() & Qt::LeftButton ) ) + if ( !mPinching ) { - mDragging = true; - // move map and other canvas items - mCanvas->panAction( e ); + if (( e->buttons() & Qt::LeftButton ) ) + { + mDragging = true; + // move map and other canvas items + mCanvas->panAction( e ); + } } } void QgsMapToolPan::canvasReleaseEvent( QgsMapMouseEvent* e ) { - if ( e->button() == Qt::LeftButton ) + if ( !mPinching ) { - if ( mDragging ) + if ( e->button() == Qt::LeftButton ) { - mCanvas->panActionEnd( e->pos() ); - mDragging = false; - } - else // add pan to mouse cursor - { - // transform the mouse pos to map coordinates - QgsPoint center = mCanvas->getCoordinateTransform()->toMapPoint( e->x(), e->y() ); - mCanvas->setCenter( center ); - mCanvas->refresh(); + if ( mDragging ) + { + mCanvas->panActionEnd( e->pos() ); + mDragging = false; + } + else // add pan to mouse cursor + { + // transform the mouse pos to map coordinates + QgsPoint center = mCanvas->getCoordinateTransform()->toMapPoint( e->x(), e->y() ); + mCanvas->setCenter( center ); + mCanvas->refresh(); + } } } mCanvas->setCursor( mCursor ); } + +void QgsMapToolPan::canvasDoubleClickEvent( QgsMapMouseEvent* e ) +{ + if ( !QTouchDevice::devices().isEmpty() && !mPinching ) + { + mCanvas->zoomWithCenter( e->x(), e->y(), true ); + } +} + +bool QgsMapToolPan::gestureEvent( QGestureEvent* event ) +{ + if ( QTouchDevice::devices().isEmpty() ) + return true; // no touch support + + qDebug() << "gesture " << event; + if ( QGesture *gesture = event->gesture( Qt::PinchGesture ) ) + { + mPinching = true; + pinchTriggered( static_cast( gesture ) ); + } + return true; +} + +void QgsMapToolPan::pinchTriggered( QPinchGesture* gesture ) +{ + if ( gesture->state() == Qt::GestureFinished ) + { + //a very small totalScaleFactor indicates a two finger tap (pinch gesture without pinching) + if ( 0.98 < gesture->totalScaleFactor() && gesture->totalScaleFactor() < 1.02 ) + { + mCanvas->zoomOut(); + } + else + { + //Transfor global coordinates to widget coordinates + QPoint pos = gesture->centerPoint().toPoint(); + pos = mCanvas->mapFromGlobal( pos ); + // transform the mouse pos to map coordinates + QgsPoint center = mCanvas->getCoordinateTransform()->toMapPoint( pos.x(), pos.y() ); + QgsRectangle r = mCanvas->extent(); + r.scale( 1 / gesture->totalScaleFactor(), ¢er ); + mCanvas->setExtent( r ); + mCanvas->refresh(); + } + mPinching = false; + } +} diff --git a/src/gui/qgsmaptoolpan.h b/src/gui/qgsmaptoolpan.h index 9eab80bced6..211256a787e 100644 --- a/src/gui/qgsmaptoolpan.h +++ b/src/gui/qgsmaptoolpan.h @@ -32,17 +32,26 @@ class GUI_EXPORT QgsMapToolPan : public QgsMapTool public: //! constructor QgsMapToolPan( QgsMapCanvas* canvas ); + ~QgsMapToolPan(); + + void activate() override; + void deactivate() override; virtual Flags flags() const override { return QgsMapTool::Transient | QgsMapTool::AllowZoomRect; } virtual void canvasPressEvent( QgsMapMouseEvent* e ) override; virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override; virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override; + virtual void canvasDoubleClickEvent( QgsMapMouseEvent *e ) override; + bool gestureEvent( QGestureEvent *e ) override; private: //! Flag to indicate a map canvas drag operation is taking place bool mDragging; + //! Flag to indicate a pinch gesture is taking place + bool mPinching = false; + void pinchTriggered( QPinchGesture *gesture ); }; #endif diff --git a/src/gui/qgsmaptooltouch.cpp b/src/gui/qgsmaptooltouch.cpp deleted file mode 100644 index a5d00c5c79d..00000000000 --- a/src/gui/qgsmaptooltouch.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/*************************************************************************** - qgsmaptooltouch.cpp - map tool for zooming and panning using qgestures - ---------------------- - begin : February 2012 - copyright : (C) 2012 by Marco Bernasocchi - email : marco at bernawebdesign.ch - *************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include "qgsmaptooltouch.h" -#include "qgsmapcanvas.h" -#include "qgscursors.h" -#include "qgsmaptopixel.h" -#include -#include -#include -#include - - -QgsMapToolTouch::QgsMapToolTouch( QgsMapCanvas* canvas ) - : QgsMapTool( canvas ), mDragging( false ), mPinching( false ) -{ - // set cursor -// QBitmap panBmp = QBitmap::fromData( QSize( 16, 16 ), pan_bits ); -// QBitmap panBmpMask = QBitmap::fromData( QSize( 16, 16 ), pan_mask_bits ); -// mCursor = QCursor( panBmp, panBmpMask, 5, 5 ); -} - -QgsMapToolTouch::~QgsMapToolTouch() -{ - mCanvas->ungrabGesture( Qt::PinchGesture ); -} - -void QgsMapToolTouch::activate() -{ - mCanvas->grabGesture( Qt::PinchGesture ); - QgsMapTool::activate(); -} - -void QgsMapToolTouch::deactivate() -{ - mCanvas->ungrabGesture( Qt::PinchGesture ); - QgsMapTool::deactivate(); -} - -void QgsMapToolTouch::canvasMoveEvent( QgsMapMouseEvent* e ) -{ - if ( !mPinching ) - { - if (( e->buttons() & Qt::LeftButton ) ) - { - mDragging = true; - // move map and other canvas items - mCanvas->panAction( e ); - } - } -} - -void QgsMapToolTouch::canvasReleaseEvent( QgsMapMouseEvent* e ) -{ - if ( !mPinching ) - { - if ( e->button() == Qt::LeftButton ) - { - if ( mDragging ) - { - mCanvas->panActionEnd( e->pos() ); - mDragging = false; - } - else // add pan to mouse cursor - { - // transform the mouse pos to map coordinates - QgsPoint center = mCanvas->getCoordinateTransform()->toMapPoint( e->x(), e->y() ); - mCanvas->setExtent( QgsRectangle( center, center ) ); - mCanvas->refresh(); - } - } - } -} - -void QgsMapToolTouch::canvasDoubleClickEvent( QgsMapMouseEvent* e ) -{ - if ( !mPinching ) - { - mCanvas->zoomWithCenter( e->x(), e->y(), true ); - } -} - -bool QgsMapToolTouch::gestureEvent( QGestureEvent *event ) -{ - qDebug() << "gesture " << event; - if ( QGesture *gesture = event->gesture( Qt::PinchGesture ) ) - { - mPinching = true; - pinchTriggered( static_cast( gesture ) ); - } - return true; -} - - -void QgsMapToolTouch::pinchTriggered( QPinchGesture *gesture ) -{ - if ( gesture->state() == Qt::GestureFinished ) - { - //a very small totalScaleFactor indicates a two finger tap (pinch gesture without pinching) - if ( 0.98 < gesture->totalScaleFactor() && gesture->totalScaleFactor() < 1.02 ) - { - mCanvas->zoomOut(); - } - else - { - //Transfor global coordinates to widget coordinates - QPoint pos = gesture->centerPoint().toPoint(); - pos = mCanvas->mapFromGlobal( pos ); - // transform the mouse pos to map coordinates - QgsPoint center = mCanvas->getCoordinateTransform()->toMapPoint( pos.x(), pos.y() ); - QgsRectangle r = mCanvas->extent(); - r.scale( 1 / gesture->totalScaleFactor(), ¢er ); - mCanvas->setExtent( r ); - mCanvas->refresh(); - } - mPinching = false; - } -} diff --git a/src/gui/qgsmaptooltouch.h b/src/gui/qgsmaptooltouch.h deleted file mode 100644 index 03a9868f1bd..00000000000 --- a/src/gui/qgsmaptooltouch.h +++ /dev/null @@ -1,57 +0,0 @@ -/*************************************************************************** - qgsmaptooltouch.h - map tool for zooming and panning using qgestures - ---------------------- - begin : February 2012 - copyright : (C) 2012 by Marco Bernasocchi - email : marco at bernawebdesign.ch - *************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef QGSMAPTOOLTOUCH_H -#define QGSMAPTOOLTOUCH_H - -#include "qgsmaptool.h" -#include -#include -#include "qgis_gui.h" - -class QgsMapCanvas; - - -/** \ingroup gui - * A map tool for panning the map. - * @see QgsMapTool - * @note may not be available in Python bindings on all platforms - */ -class GUI_EXPORT QgsMapToolTouch : public QgsMapTool -{ - public: - //! constructor - QgsMapToolTouch( QgsMapCanvas* canvas ); - - ~QgsMapToolTouch(); - - void activate() override; - void deactivate() override; - virtual void canvasMoveEvent( QgsMapMouseEvent *e ) override; - virtual void canvasReleaseEvent( QgsMapMouseEvent *e ) override; - virtual void canvasDoubleClickEvent( QgsMapMouseEvent *e ) override; - virtual Flags flags() const override { return QgsMapTool::Transient | QgsMapTool::AllowZoomRect; } - bool gestureEvent( QGestureEvent *e ) override; - - private: - - //! Flag to indicate a map canvas drag operation is taking place - bool mDragging; - //! Flag to indicate a pinch gesture is taking place - bool mPinching; - void pinchTriggered( QPinchGesture *gesture ); -}; - -#endif diff --git a/src/ui/qgisapp.ui b/src/ui/qgisapp.ui index b669882c2a3..f3c3627ba98 100644 --- a/src/ui/qgisapp.ui +++ b/src/ui/qgisapp.ui @@ -17,7 +17,7 @@ 0 0 1018 - 19 + 25 @@ -422,7 +422,6 @@ false - @@ -1878,21 +1877,6 @@ Ctrl (Cmd) increments by 15 deg. Pan Map to Selection - - - true - - - - :/images/themes/default/mActionTouch.svg:/images/themes/default/mActionTouch.svg - - - Touch Zoom and Pan - - - Touch zoom and pan - - true