Skip to content
Permalink
Browse files

Merge pull request #4138 from nyalldawson/touch

Rework map touch tool
  • Loading branch information
m-kuhn committed Feb 16, 2017
2 parents 7f1ff08 + a124fbf commit 35d9b83aa5c9c36c2234672796d377fd0439767e
@@ -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)

@@ -48,8 +48,6 @@

#cmakedefine HAVE_ORACLE

#cmakedefine HAVE_TOUCH

#cmakedefine HAVE_OSGEARTHQT

#cmakedefine SERVER_SKIP_ECW
@@ -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}
@@ -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 \
@@ -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% ^
@@ -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" ^
@@ -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)
@@ -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
@@ -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.
@@ -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 );
@@ -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.

This file was deleted.

@@ -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 \
@@ -363,10 +363,6 @@ extern "C"
#include <DbgHelp.h>
#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<QGestureEvent*>( 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 )
@@ -131,10 +131,8 @@ class QgsDiagramProperties;
#include "ui_qgisapp.h"
#include "qgis_app.h"

#ifdef HAVE_TOUCH
#include <QGestureEvent>
#include <QTapAndHoldGesture>
#endif

#ifdef Q_OS_WIN
#include <windows.h>
@@ -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;
};
@@ -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(); }
@@ -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;

0 comments on commit 35d9b83

Please sign in to comment.
You can’t perform that action at this time.