Merge pull request #4138 from nyalldawson/touch

Rework map touch tool
This commit is contained in:
Matthias Kuhn 2017-02-16 12:00:16 +01:00 committed by GitHub
commit 35d9b83aa5
28 changed files with 117 additions and 383 deletions

View File

@ -269,23 +269,6 @@ IF (WITH_QTMOBILITY)
FIND_PACKAGE(QtMobility 1.1.0) FIND_PACKAGE(QtMobility 1.1.0)
ENDIF (WITH_QTMOBILITY) 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) # search for QScintilla2 (C++ lib)
FIND_PACKAGE(QScintilla REQUIRED) FIND_PACKAGE(QScintilla REQUIRED)

View File

@ -48,8 +48,6 @@
#cmakedefine HAVE_ORACLE #cmakedefine HAVE_ORACLE
#cmakedefine HAVE_TOUCH
#cmakedefine HAVE_OSGEARTHQT #cmakedefine HAVE_OSGEARTHQT
#cmakedefine SERVER_SKIP_ECW #cmakedefine SERVER_SKIP_ECW

View File

@ -269,6 +269,7 @@ should now call QgsCoordinateReferenceSystem::invalidateCache() and QgsCoordinat
- QgsMapCanvasMap. It is an internal class used by map canvas. - QgsMapCanvasMap. It is an internal class used by map canvas.
- QgsMapLayerRegistry. Its functionality has been moved to QgsProject. - QgsMapLayerRegistry. Its functionality has been moved to QgsProject.
- QgsMapRenderer. It has been replaced by QgsMapRendererJob with subclasses and QgsMapSettings. - 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. - QgsPhotoWidgetWrapper was removed. Use QgsExternalResourceWidgetWrapper instead.
- QgsPseudoColorShader. This shader has been broken for some time and was replaced by QgsSingleBandPseudoColorRenderer. - 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. - 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. - fileMenu() has been removed, use projectMenu() instead.
- actionRemoveLayer was removed as it no longer exists. - 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} QgsAbstractGeometry {#qgis_api_break_3_0_QgsAbstractGeometry}

View File

@ -28,7 +28,6 @@ cmake -D BUILDNAME="cygwin" \
-D WITH_QSPATIALITE=TRUE \ -D WITH_QSPATIALITE=TRUE \
-D WITH_SERVER=TRUE \ -D WITH_SERVER=TRUE \
-D WITH_GLOBE=TRUE \ -D WITH_GLOBE=TRUE \
-D WITH_TOUCH=TRUE \
-D WITH_ORACLE=FALSE \ -D WITH_ORACLE=FALSE \
-D CMAKE_LEGACY_CYGWIN_WIN32=0 \ -D CMAKE_LEGACY_CYGWIN_WIN32=0 \
-D PYUIC4_PROGRAM=/usr/lib/python2.7/site-packages/PyQt4/pyuic4 \ -D PYUIC4_PROGRAM=/usr/lib/python2.7/site-packages/PyQt4/pyuic4 \

View File

@ -167,7 +167,6 @@ cmake -G Ninja ^
-D WITH_GRASS7=TRUE ^ -D WITH_GRASS7=TRUE ^
-D GRASS_PREFIX7=%GRASS72_PATH:\=/% ^ -D GRASS_PREFIX7=%GRASS72_PATH:\=/% ^
-D WITH_GLOBE=FALSE ^ -D WITH_GLOBE=FALSE ^
-D WITH_TOUCH=TRUE ^
-D WITH_ORACLE=TRUE ^ -D WITH_ORACLE=TRUE ^
-D WITH_CUSTOM_WIDGETS=TRUE ^ -D WITH_CUSTOM_WIDGETS=TRUE ^
-D CMAKE_BUILD_TYPE=%BUILDCONF% ^ -D CMAKE_BUILD_TYPE=%BUILDCONF% ^

View File

@ -160,7 +160,6 @@ cmake -G Ninja ^
-D WITH_GRASS7=TRUE ^ -D WITH_GRASS7=TRUE ^
-D GRASS_PREFIX7=%GRASS72_PATH:\=/% ^ -D GRASS_PREFIX7=%GRASS72_PATH:\=/% ^
-D WITH_GLOBE=FALSE ^ -D WITH_GLOBE=FALSE ^
-D WITH_TOUCH=TRUE ^
-D WITH_ORACLE=TRUE ^ -D WITH_ORACLE=TRUE ^
-D WITH_CUSTOM_WIDGETS=TRUE ^ -D WITH_CUSTOM_WIDGETS=TRUE ^
-D CMAKE_CXX_FLAGS_RELEASE="/MD /MP /O2 /Ob2 /D NDEBUG" ^ -D CMAKE_CXX_FLAGS_RELEASE="/MD /MP /O2 /Ob2 /D NDEBUG" ^

View File

@ -130,10 +130,6 @@ ELSE(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} ARM) SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} ARM)
ENDIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^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) IF(NOT QT_MOBILITY_LOCATION_FOUND)
SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} MOBILITY_LOCATION) SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} MOBILITY_LOCATION)
ENDIF(NOT QT_MOBILITY_LOCATION_FOUND) ENDIF(NOT QT_MOBILITY_LOCATION_FOUND)

View File

@ -117,7 +117,6 @@
%Include qgsmaptoolidentify.sip %Include qgsmaptoolidentify.sip
%Include qgsmaptoolidentifyfeature.sip %Include qgsmaptoolidentifyfeature.sip
%Include qgsmaptoolpan.sip %Include qgsmaptoolpan.sip
%Include qgsmaptooltouch.sip
%Include qgsmaptoolzoom.sip %Include qgsmaptoolzoom.sip
%Include qgsmaplayerstylemanagerwidget.sip %Include qgsmaplayerstylemanagerwidget.sip
%Include qgsmessagebar.sip %Include qgsmessagebar.sip

View File

@ -404,8 +404,6 @@ class QgisInterface : QObject
// View menu actions // View menu actions
//! Get access to the native pan action. Call trigger() on it to set the default pan map tool. //! Get access to the native pan action. Call trigger() on it to set the default pan map tool.
virtual QAction *actionPan() = 0; 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. //! 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; virtual QAction *actionPanToSelected() = 0;
//! Get access to the native zoom in action. Call trigger() on it to set the default zoom in map tool. //! Get access to the native zoom in action. Call trigger() on it to set the default zoom in map tool.

View File

@ -1,5 +1,3 @@
%Feature HAVE_TOUCH
/** \ingroup gui /** \ingroup gui
* Map canvas is a class for displaying all GIS data types on a canvas. * 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 ); void messageEmitted( const QString& title, const QString& message, QgsMessageBar::MessageLevel = QgsMessageBar::INFO );
protected: protected:
%If (HAVE_TOUCH)
//! Overridden standard event to be gestures aware //! Overridden standard event to be gestures aware
bool event( QEvent * e ); bool event( QEvent * e );
%End
//! Overridden key press event //! Overridden key press event
void keyPressEvent( QKeyEvent * e ); void keyPressEvent( QKeyEvent * e );

View File

@ -71,10 +71,8 @@ class QgsMapTool : QObject
//! Key event for overriding. Default implementation does nothing. //! Key event for overriding. Default implementation does nothing.
virtual void keyReleaseEvent( QKeyEvent* e ); virtual void keyReleaseEvent( QKeyEvent* e );
%If (HAVE_TOUCH)
//! gesture event for overriding. Default implementation does nothing. //! gesture event for overriding. Default implementation does nothing.
virtual bool gestureEvent( QGestureEvent* e ); virtual bool gestureEvent( QGestureEvent* e );
%End
/** Use this to associate a QAction to this maptool. Then when the setMapTool /** 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. * method of mapcanvas is called the action state will be set to on.

View File

@ -1,22 +0,0 @@
%If (HAVE_TOUCH)
class QgsMapToolTouch : QgsMapTool
{
%TypeHeaderCode
#include <qgsmaptooltouch.h>
%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

View File

@ -198,7 +198,6 @@ gzip ChangeLog
# Necessary for the test suite # Necessary for the test suite
#export LD_LIBRARY_PATH=%{_builddir}%{name}-%{version}/output/%{_lib} #export LD_LIBRARY_PATH=%{_builddir}%{name}-%{version}/output/%{_lib}
#Info: TOUCH needs Qt >= 4.5
%cmake \ %cmake \
%{_cmake_skip_rpath} \ %{_cmake_skip_rpath} \
-D QGIS_LIB_SUBDIR=%{_lib} \ -D QGIS_LIB_SUBDIR=%{_lib} \
@ -224,7 +223,6 @@ gzip ChangeLog
-D WITH_INTERNAL_SIX:BOOL=FALSE \ -D WITH_INTERNAL_SIX:BOOL=FALSE \
-D WITH_PYSPATIALITE:BOOL=FALSE \ -D WITH_PYSPATIALITE:BOOL=FALSE \
-D WITH_SERVER:BOOL=TRUE \ -D WITH_SERVER:BOOL=TRUE \
-D WITH_TOUCH:BOOL=TRUE \
%{configure_with_spatialite} \ %{configure_with_spatialite} \
. .
#-D WITH_QTMOBILITY:BOOL=TRUE \ #-D WITH_QTMOBILITY:BOOL=TRUE \

View File

@ -363,10 +363,6 @@ extern "C"
#include <DbgHelp.h> #include <DbgHelp.h>
#endif #endif
#ifdef HAVE_TOUCH
#include "qgsmaptooltouch.h"
#endif
class QTreeWidgetItem; class QTreeWidgetItem;
/** Set the application title bar text /** Set the application title bar text
@ -1097,14 +1093,11 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
QgsDebugMsg( "Tips are disabled" ); QgsDebugMsg( "Tips are disabled" );
} }
#ifdef HAVE_TOUCH if ( ! QTouchDevice::devices().isEmpty() )
//add reacting to long click in touch {
grabGesture( Qt::TapAndHoldGesture ); //add reacting to long click in touch
#else grabGesture( Qt::TapAndHoldGesture );
//remove mActionTouch button }
delete mActionTouch;
mActionTouch = nullptr;
#endif
// supposedly all actions have been added, now register them to the shortcut manager // supposedly all actions have been added, now register them to the shortcut manager
QgsShortcutsManager::instance()->registerAllChildren( this ); QgsShortcutsManager::instance()->registerAllChildren( this );
@ -1258,9 +1251,6 @@ QgisApp::~QgisApp()
delete mMapTools.mZoomIn; delete mMapTools.mZoomIn;
delete mMapTools.mZoomOut; delete mMapTools.mZoomOut;
delete mMapTools.mPan; delete mMapTools.mPan;
#ifdef HAVE_TOUCH
delete mMapTools.mTouch;
#endif
delete mMapTools.mAddFeature; delete mMapTools.mAddFeature;
delete mMapTools.mAddPart; delete mMapTools.mAddPart;
delete mMapTools.mAddRing; delete mMapTools.mAddRing;
@ -1501,12 +1491,10 @@ bool QgisApp::event( QEvent * event )
openFile( foe->file() ); openFile( foe->file() );
done = true; done = true;
} }
#ifdef HAVE_TOUCH else if ( !QTouchDevice::devices().isEmpty() && event->type() == QEvent::Gesture )
else if ( event->type() == QEvent::Gesture )
{ {
done = gestureEvent( static_cast<QGestureEvent*>( event ) ); done = gestureEvent( static_cast<QGestureEvent*>( event ) );
} }
#endif
else else
{ {
// pass other events to base class // pass other events to base class
@ -1644,10 +1632,6 @@ void QgisApp::createActions()
connect( mActionOffsetCurve, SIGNAL( triggered() ), this, SLOT( offsetCurve() ) ); connect( mActionOffsetCurve, SIGNAL( triggered() ), this, SLOT( offsetCurve() ) );
// View Menu Items // View Menu Items
#ifdef HAVE_TOUCH
connect( mActionTouch, SIGNAL( triggered() ), this, SLOT( touch() ) );
#endif
connect( mActionPan, SIGNAL( triggered() ), this, SLOT( pan() ) ); connect( mActionPan, SIGNAL( triggered() ), this, SLOT( pan() ) );
connect( mActionPanToSelected, SIGNAL( triggered() ), this, SLOT( panToSelected() ) ); connect( mActionPanToSelected, SIGNAL( triggered() ), this, SLOT( panToSelected() ) );
connect( mActionZoomIn, SIGNAL( triggered() ), this, SLOT( zoomIn() ) ); connect( mActionZoomIn, SIGNAL( triggered() ), this, SLOT( zoomIn() ) );
@ -1878,9 +1862,6 @@ void QgisApp::createActionGroups()
// //
// Map Tool Group // Map Tool Group
mMapToolGroup = new QActionGroup( this ); mMapToolGroup = new QActionGroup( this );
#ifdef HAVE_TOUCH
mMapToolGroup->addAction( mActionTouch );
#endif
mMapToolGroup->addAction( mActionPan ); mMapToolGroup->addAction( mActionPan );
mMapToolGroup->addAction( mActionZoomIn ); mMapToolGroup->addAction( mActionZoomIn );
mMapToolGroup->addAction( mActionZoomOut ); mMapToolGroup->addAction( mActionZoomOut );
@ -2689,9 +2670,6 @@ void QgisApp::setTheme( const QString& theThemeName )
mActionZoomFullExtent->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomFullExtent.svg" ) ) ); mActionZoomFullExtent->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomFullExtent.svg" ) ) );
mActionZoomToSelected->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomToSelected.svg" ) ) ); mActionZoomToSelected->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomToSelected.svg" ) ) );
mActionShowRasterCalculator->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionShowRasterCalculator.png" ) ) ); mActionShowRasterCalculator->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionShowRasterCalculator.png" ) ) );
#ifdef HAVE_TOUCH
mActionTouch->setIcon( QgsApplication::getThemeIcon( "/mActionTouch.svg" ) );
#endif
mActionPan->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionPan.svg" ) ) ); mActionPan->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionPan.svg" ) ) );
mActionPanToSelected->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionPanToSelected.svg" ) ) ); mActionPanToSelected->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionPanToSelected.svg" ) ) );
mActionZoomLast->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomLast.svg" ) ) ); mActionZoomLast->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomLast.svg" ) ) );
@ -2868,10 +2846,6 @@ void QgisApp::createCanvasTools()
mMapTools.mZoomOut->setAction( mActionZoomOut ); mMapTools.mZoomOut->setAction( mActionZoomOut );
mMapTools.mPan = new QgsMapToolPan( mMapCanvas ); mMapTools.mPan = new QgsMapToolPan( mMapCanvas );
mMapTools.mPan->setAction( mActionPan ); mMapTools.mPan->setAction( mActionPan );
#ifdef HAVE_TOUCH
mMapTools.mTouch = new QgsMapToolTouch( mMapCanvas );
mMapTools.mTouch->setAction( mActionTouch );
#endif
mMapTools.mIdentify = new QgsMapToolIdentifyAction( mMapCanvas ); mMapTools.mIdentify = new QgsMapToolIdentifyAction( mMapCanvas );
mMapTools.mIdentify->setAction( mActionIdentify ); mMapTools.mIdentify->setAction( mActionIdentify );
connect( mMapTools.mIdentify, SIGNAL( copyToClipboard( QgsFeatureStore & ) ), connect( mMapTools.mIdentify, SIGNAL( copyToClipboard( QgsFeatureStore & ) ),
@ -4598,15 +4572,10 @@ void QgisApp::fileNew( bool thePromptToSaveFlag, bool forceBlank )
} }
// set the initial map tool // set the initial map tool
#ifndef HAVE_TOUCH
mMapCanvas->setMapTool( mMapTools.mPan ); mMapCanvas->setMapTool( mMapTools.mPan );
mNonEditMapTool = mMapTools.mPan; // signals are not yet setup to catch this 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 ) bool QgisApp::fileNewFromTemplate( const QString& fileName )
{ {
@ -5849,13 +5818,6 @@ void QgisApp::pan()
mMapCanvas->setMapTool( mMapTools.mPan ); mMapCanvas->setMapTool( mMapTools.mPan );
} }
#ifdef HAVE_TOUCH
void QgisApp::touch()
{
mMapCanvas->setMapTool( mMapTools.mTouch );
}
#endif
void QgisApp::zoomFull() void QgisApp::zoomFull()
{ {
mMapCanvas->zoomToFullExtent(); mMapCanvas->zoomToFullExtent();
@ -12129,8 +12091,6 @@ void QgisApp::onLayerError( const QString& msg )
mInfoBar->pushCritical( tr( "Layer %1" ).arg( layer->name() ), msg ); mInfoBar->pushCritical( tr( "Layer %1" ).arg( layer->name() ), msg );
} }
#ifdef HAVE_TOUCH
bool QgisApp::gestureEvent( QGestureEvent *event ) bool QgisApp::gestureEvent( QGestureEvent *event )
{ {
if ( QGesture *tapAndHold = event->gesture( Qt::TapAndHoldGesture ) ) 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 ) ); QApplication::postEvent( receiver, new QMouseEvent( QEvent::MouseButtonRelease, receiver->mapFromGlobal( pos ), Qt::RightButton, Qt::RightButton, Qt::NoModifier ) );
} }
} }
#endif
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
LONG WINAPI QgisApp::qgisCrashDump( struct _EXCEPTION_POINTERS *ExceptionInfo ) LONG WINAPI QgisApp::qgisCrashDump( struct _EXCEPTION_POINTERS *ExceptionInfo )

View File

@ -131,10 +131,8 @@ class QgsDiagramProperties;
#include "ui_qgisapp.h" #include "ui_qgisapp.h"
#include "qgis_app.h" #include "qgis_app.h"
#ifdef HAVE_TOUCH
#include <QGestureEvent> #include <QGestureEvent>
#include <QTapAndHoldGesture> #include <QTapAndHoldGesture>
#endif
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#include <windows.h> #include <windows.h>
@ -352,7 +350,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
QAction *actionSnappingOptions() { return mActionSnappingOptions; } QAction *actionSnappingOptions() { return mActionSnappingOptions; }
QAction *actionOffsetCurve() { return mActionOffsetCurve; } QAction *actionOffsetCurve() { return mActionOffsetCurve; }
QAction *actionPan() { return mActionPan; } QAction *actionPan() { return mActionPan; }
QAction *actionTouch() { return mActionTouch; }
QAction *actionPanToSelected() { return mActionPanToSelected; } QAction *actionPanToSelected() { return mActionPanToSelected; }
QAction *actionZoomIn() { return mActionZoomIn; } QAction *actionZoomIn() { return mActionZoomIn; }
QAction *actionZoomOut() { return mActionZoomOut; } QAction *actionZoomOut() { return mActionZoomOut; }
@ -1222,10 +1219,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
void zoomIn(); void zoomIn();
//! Set map tool to pan //! Set map tool to pan
void pan(); void pan();
#ifdef HAVE_TOUCH
//! Set map tool to touch
void touch();
#endif
//! Identify feature(s) on the currently selected layer //! Identify feature(s) on the currently selected layer
void identify(); void identify();
//! Measure distance //! Measure distance
@ -1590,9 +1583,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
: mZoomIn( nullptr ) : mZoomIn( nullptr )
, mZoomOut( nullptr ) , mZoomOut( nullptr )
, mPan( nullptr ) , mPan( nullptr )
#ifdef HAVE_TOUCH
, mTouch( 0 )
#endif
, mIdentify( nullptr ) , mIdentify( nullptr )
, mFeatureAction( nullptr ) , mFeatureAction( nullptr )
, mMeasureDist( nullptr ) , mMeasureDist( nullptr )
@ -1639,9 +1629,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
QgsMapTool *mZoomIn; QgsMapTool *mZoomIn;
QgsMapTool *mZoomOut; QgsMapTool *mZoomOut;
QgsMapTool *mPan; QgsMapTool *mPan;
#ifdef HAVE_TOUCH
QgsMapTool *mTouch;
#endif
QgsMapTool *mIdentify; QgsMapTool *mIdentify;
QgsMapTool *mFeatureAction; QgsMapTool *mFeatureAction;
QgsMapTool *mMeasureDist; QgsMapTool *mMeasureDist;
@ -1865,10 +1852,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
QStackedWidget* mCentralContainer; QStackedWidget* mCentralContainer;
int mProjOpen; int mProjOpen;
#ifdef HAVE_TOUCH
bool gestureEvent( QGestureEvent *event ); bool gestureEvent( QGestureEvent *event );
void tapAndHoldTriggered( QTapAndHoldGesture *gesture ); void tapAndHoldTriggered( QTapAndHoldGesture *gesture );
#endif
friend class TestQgisAppPython; friend class TestQgisAppPython;
}; };

View File

@ -573,7 +573,6 @@ QAction *QgisAppInterface::actionNodeTool() { return qgis->actionNodeTool(); }
//! View menu actions //! View menu actions
QAction *QgisAppInterface::actionPan() { return qgis->actionPan(); } QAction *QgisAppInterface::actionPan() { return qgis->actionPan(); }
QAction *QgisAppInterface::actionTouch() { return qgis->actionTouch(); }
QAction *QgisAppInterface::actionPanToSelected() { return qgis->actionPanToSelected(); } QAction *QgisAppInterface::actionPanToSelected() { return qgis->actionPanToSelected(); }
QAction *QgisAppInterface::actionZoomIn() { return qgis->actionZoomIn(); } QAction *QgisAppInterface::actionZoomIn() { return qgis->actionZoomIn(); }
QAction *QgisAppInterface::actionZoomOut() { return qgis->actionZoomOut(); } QAction *QgisAppInterface::actionZoomOut() { return qgis->actionZoomOut(); }

View File

@ -392,7 +392,6 @@ class APP_EXPORT QgisAppInterface : public QgisInterface
//! View menu actions //! View menu actions
virtual QAction *actionPan() override; virtual QAction *actionPan() override;
virtual QAction *actionTouch() override;
virtual QAction *actionPanToSelected() override; virtual QAction *actionPanToSelected() override;
virtual QAction *actionZoomIn() override; virtual QAction *actionZoomIn() override;
virtual QAction *actionZoomOut() override; virtual QAction *actionZoomOut() override;

View File

@ -314,14 +314,6 @@ SET(QGIS_GUI_SRCS
qgsfiledownloader.cpp qgsfiledownloader.cpp
) )
IF (WITH_TOUCH)
SET(QGIS_GUI_SRCS
${QGIS_GUI_SRCS}
qgsmaptooltouch.cpp
)
ENDIF (WITH_TOUCH)
SET(QGIS_GUI_MOC_HDRS SET(QGIS_GUI_MOC_HDRS
qgisinterface.h qgisinterface.h
qgsactionmenu.h qgsactionmenu.h
@ -691,13 +683,6 @@ SET(QGIS_GUI_HDRS
symbology-ng/qgssymbolwidgetcontext.h symbology-ng/qgssymbolwidgetcontext.h
) )
IF (WITH_TOUCH)
SET(QGIS_GUI_HDRS
${QGIS_GUI_HDRS}
qgsmaptooltouch.h
)
ENDIF (WITH_TOUCH)
SET(QGIS_GUI_UI_HDRS SET(QGIS_GUI_UI_HDRS
${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsauthauthoritieseditor.h ${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsauthauthoritieseditor.h
${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsauthcertificateinfo.h ${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsauthcertificateinfo.h

View File

@ -458,8 +458,6 @@ class GUI_EXPORT QgisInterface : public QObject
// View menu actions // View menu actions
//! Get access to the native pan action. Call trigger() on it to set the default pan map tool. //! Get access to the native pan action. Call trigger() on it to set the default pan map tool.
virtual QAction *actionPan() = 0; 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. //! 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; virtual QAction *actionPanToSelected() = 0;
//! Get access to the native zoom in action. Call trigger() on it to set the default zoom in map tool. //! Get access to the native zoom in action. Call trigger() on it to set the default zoom in map tool.

View File

@ -1962,26 +1962,23 @@ void QgsMapCanvas::mapToolDestroyed()
mMapTool = nullptr; mMapTool = nullptr;
} }
#ifdef HAVE_TOUCH
bool QgsMapCanvas::event( QEvent * e ) bool QgsMapCanvas::event( QEvent * e )
{ {
bool done = false; if ( !QTouchDevice::devices().empty() )
if ( e->type() == QEvent::Gesture )
{ {
// call handler of current map tool if ( e->type() == QEvent::Gesture )
if ( mMapTool )
{ {
done = mMapTool->gestureEvent( static_cast<QGestureEvent*>( e ) ); // call handler of current map tool
if ( mMapTool )
{
return mMapTool->gestureEvent( static_cast<QGestureEvent*>( e ) );
}
} }
} }
else
{ // pass other events to base class
// pass other events to base class return QGraphicsView::event( e );
done = QGraphicsView::event( e );
}
return done;
} }
#endif
void QgsMapCanvas::refreshAllLayers() void QgsMapCanvas::refreshAllLayers()
{ {

View File

@ -33,10 +33,8 @@
#include "qgsmapsettings.h" // TEMPORARY #include "qgsmapsettings.h" // TEMPORARY
#include "qgsprevieweffect.h" //for QgsPreviewEffect::PreviewMode #include "qgsprevieweffect.h" //for QgsPreviewEffect::PreviewMode
#ifdef HAVE_TOUCH
#include <QGestureEvent> #include <QGestureEvent>
#include "qgis_gui.h" #include "qgis_gui.h"
#endif
class QWheelEvent; class QWheelEvent;
class QPixmap; class QPixmap;
@ -555,10 +553,9 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
void messageEmitted( const QString& title, const QString& message, QgsMessageBar::MessageLevel = QgsMessageBar::INFO ); void messageEmitted( const QString& title, const QString& message, QgsMessageBar::MessageLevel = QgsMessageBar::INFO );
protected: protected:
#ifdef HAVE_TOUCH
//! Overridden standard event to be gestures aware //! Overridden standard event to be gestures aware
bool event( QEvent * e ) override; bool event( QEvent * e ) override;
#endif
//! Overridden key press event //! Overridden key press event
void keyPressEvent( QKeyEvent * e ) override; void keyPressEvent( QKeyEvent * e ) override;

View File

@ -176,13 +176,11 @@ void QgsMapTool::keyReleaseEvent( QKeyEvent *e )
Q_UNUSED( e ); Q_UNUSED( e );
} }
#ifdef HAVE_TOUCH
bool QgsMapTool::gestureEvent( QGestureEvent *e ) bool QgsMapTool::gestureEvent( QGestureEvent *e )
{ {
Q_UNUSED( e ); Q_UNUSED( e );
return true; return true;
} }
#endif
QgsMapCanvas* QgsMapTool::canvas() QgsMapCanvas* QgsMapTool::canvas()
{ {

View File

@ -25,10 +25,8 @@
#include <QString> #include <QString>
#include <QObject> #include <QObject>
#ifdef HAVE_TOUCH
#include <QGestureEvent> #include <QGestureEvent>
#include "qgis_gui.h" #include "qgis_gui.h"
#endif
class QgsMapLayer; class QgsMapLayer;
class QgsMapCanvas; class QgsMapCanvas;
@ -95,10 +93,8 @@ class GUI_EXPORT QgsMapTool : public QObject
//! Key event for overriding. Default implementation does nothing. //! Key event for overriding. Default implementation does nothing.
virtual void keyReleaseEvent( QKeyEvent* e ); virtual void keyReleaseEvent( QKeyEvent* e );
#ifdef HAVE_TOUCH
//! gesture event for overriding. Default implementation does nothing. //! gesture event for overriding. Default implementation does nothing.
virtual bool gestureEvent( QGestureEvent* e ); virtual bool gestureEvent( QGestureEvent* e );
#endif
/** Use this to associate a QAction to this maptool. Then when the setMapTool /** 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. * method of mapcanvas is called the action state will be set to on.

View File

@ -31,6 +31,23 @@ QgsMapToolPan::QgsMapToolPan( QgsMapCanvas* canvas )
mCursor = QCursor( Qt::OpenHandCursor ); 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 ) void QgsMapToolPan::canvasPressEvent( QgsMapMouseEvent* e )
{ {
if ( e->button() == Qt::LeftButton ) if ( e->button() == Qt::LeftButton )
@ -40,30 +57,83 @@ void QgsMapToolPan::canvasPressEvent( QgsMapMouseEvent* e )
void QgsMapToolPan::canvasMoveEvent( QgsMapMouseEvent* e ) void QgsMapToolPan::canvasMoveEvent( QgsMapMouseEvent* e )
{ {
if (( e->buttons() & Qt::LeftButton ) ) if ( !mPinching )
{ {
mDragging = true; if (( e->buttons() & Qt::LeftButton ) )
// move map and other canvas items {
mCanvas->panAction( e ); mDragging = true;
// move map and other canvas items
mCanvas->panAction( e );
}
} }
} }
void QgsMapToolPan::canvasReleaseEvent( QgsMapMouseEvent* e ) void QgsMapToolPan::canvasReleaseEvent( QgsMapMouseEvent* e )
{ {
if ( e->button() == Qt::LeftButton ) if ( !mPinching )
{ {
if ( mDragging ) if ( e->button() == Qt::LeftButton )
{ {
mCanvas->panActionEnd( e->pos() ); if ( mDragging )
mDragging = false; {
} mCanvas->panActionEnd( e->pos() );
else // add pan to mouse cursor mDragging = false;
{ }
// transform the mouse pos to map coordinates else // add pan to mouse cursor
QgsPoint center = mCanvas->getCoordinateTransform()->toMapPoint( e->x(), e->y() ); {
mCanvas->setCenter( center ); // transform the mouse pos to map coordinates
mCanvas->refresh(); QgsPoint center = mCanvas->getCoordinateTransform()->toMapPoint( e->x(), e->y() );
mCanvas->setCenter( center );
mCanvas->refresh();
}
} }
} }
mCanvas->setCursor( mCursor ); 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<QPinchGesture *>( 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(), &center );
mCanvas->setExtent( r );
mCanvas->refresh();
}
mPinching = false;
}
}

View File

@ -32,17 +32,26 @@ class GUI_EXPORT QgsMapToolPan : public QgsMapTool
public: public:
//! constructor //! constructor
QgsMapToolPan( QgsMapCanvas* canvas ); QgsMapToolPan( QgsMapCanvas* canvas );
~QgsMapToolPan();
void activate() override;
void deactivate() override;
virtual Flags flags() const override { return QgsMapTool::Transient | QgsMapTool::AllowZoomRect; } virtual Flags flags() const override { return QgsMapTool::Transient | QgsMapTool::AllowZoomRect; }
virtual void canvasPressEvent( QgsMapMouseEvent* e ) override; virtual void canvasPressEvent( QgsMapMouseEvent* e ) override;
virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override; virtual void canvasMoveEvent( QgsMapMouseEvent* e ) override;
virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override; virtual void canvasReleaseEvent( QgsMapMouseEvent* e ) override;
virtual void canvasDoubleClickEvent( QgsMapMouseEvent *e ) override;
bool gestureEvent( QGestureEvent *e ) override;
private: private:
//! Flag to indicate a map canvas drag operation is taking place //! Flag to indicate a map canvas drag operation is taking place
bool mDragging; bool mDragging;
//! Flag to indicate a pinch gesture is taking place
bool mPinching = false;
void pinchTriggered( QPinchGesture *gesture );
}; };
#endif #endif

View File

@ -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 <QBitmap>
#include <QCursor>
#include <QMouseEvent>
#include <qgslogger.h>
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<QPinchGesture *>( 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(), &center );
mCanvas->setExtent( r );
mCanvas->refresh();
}
mPinching = false;
}
}

View File

@ -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 <QGestureEvent>
#include <QPinchGesture>
#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

View File

@ -17,7 +17,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1018</width> <width>1018</width>
<height>19</height> <height>25</height>
</rect> </rect>
</property> </property>
<property name="toolTip"> <property name="toolTip">
@ -422,7 +422,6 @@
<attribute name="toolBarBreak"> <attribute name="toolBarBreak">
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
<addaction name="mActionTouch"/>
<addaction name="mActionPan"/> <addaction name="mActionPan"/>
<addaction name="mActionPanToSelected"/> <addaction name="mActionPanToSelected"/>
<addaction name="mActionZoomIn"/> <addaction name="mActionZoomIn"/>
@ -1878,21 +1877,6 @@ Ctrl (Cmd) increments by 15 deg.</string>
<string>Pan Map to Selection</string> <string>Pan Map to Selection</string>
</property> </property>
</action> </action>
<action name="mActionTouch">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:/images/themes/default/mActionTouch.svg</normaloff>:/images/themes/default/mActionTouch.svg</iconset>
</property>
<property name="text">
<string>Touch Zoom and Pan</string>
</property>
<property name="toolTip">
<string>Touch zoom and pan</string>
</property>
</action>
<action name="mActionOffsetCurve"> <action name="mActionOffsetCurve">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>