Skip to content

Commit c26ed69

Browse files
committed
Rework map touch tool
Qt5 allows runtime detection of touch devices. This commit reworks the current touch map tool by pulling its behavior into the normal pan tool when a touch device is detected. It avoids the need for a seperate map tool for touch interaction, and also avoids having this tool always appear on the Windows builds (regardless of the presence of a touch device)
1 parent 9a7c829 commit c26ed69

27 files changed

+112
-380
lines changed

CMakeLists.txt

-17
Original file line numberDiff line numberDiff line change
@@ -268,23 +268,6 @@ IF (WITH_QTMOBILITY)
268268
FIND_PACKAGE(QtMobility 1.1.0)
269269
ENDIF (WITH_QTMOBILITY)
270270

271-
IF (ANDROID)
272-
SET (DEFAULT_WITH_TOUCH TRUE)
273-
ELSE (ANDROID)
274-
SET (DEFAULT_WITH_TOUCH FALSE)
275-
ENDIF (ANDROID)
276-
277-
#Add a touch mode if Qt has Qt Gestures
278-
SET (WITH_TOUCH ${DEFAULT_WITH_TOUCH} CACHE BOOL "Determines if touch interface related code should be build")
279-
280-
IF (WITH_TOUCH)
281-
# following variable is used in qgsconfig.h
282-
SET (HAVE_TOUCH TRUE)
283-
MESSAGE (STATUS "Touch support enabled")
284-
ELSE (WITH_TOUCH)
285-
MESSAGE (STATUS "Touch support disabled")
286-
ENDIF (WITH_TOUCH)
287-
288271
# search for QScintilla2 (C++ lib)
289272
FIND_PACKAGE(QScintilla REQUIRED)
290273

cmake_templates/qgsconfig.h.in

-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@
4848

4949
#cmakedefine HAVE_ORACLE
5050

51-
#cmakedefine HAVE_TOUCH
52-
5351
#cmakedefine HAVE_OSGEARTHQT
5452

5553
#cmakedefine SERVER_SKIP_ECW

ms-windows/cygwin/package.sh

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ cmake -D BUILDNAME="cygwin" \
2828
-D WITH_QSPATIALITE=TRUE \
2929
-D WITH_SERVER=TRUE \
3030
-D WITH_GLOBE=TRUE \
31-
-D WITH_TOUCH=TRUE \
3231
-D WITH_ORACLE=FALSE \
3332
-D CMAKE_LEGACY_CYGWIN_WIN32=0 \
3433
-D PYUIC4_PROGRAM=/usr/lib/python2.7/site-packages/PyQt4/pyuic4 \

ms-windows/osgeo4w/package-nightly.cmd

-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ cmake -G Ninja ^
167167
-D WITH_GRASS7=TRUE ^
168168
-D GRASS_PREFIX7=%GRASS72_PATH:\=/% ^
169169
-D WITH_GLOBE=FALSE ^
170-
-D WITH_TOUCH=TRUE ^
171170
-D WITH_ORACLE=TRUE ^
172171
-D WITH_CUSTOM_WIDGETS=TRUE ^
173172
-D CMAKE_BUILD_TYPE=%BUILDCONF% ^

ms-windows/osgeo4w/package.cmd

-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ cmake -G Ninja ^
160160
-D WITH_GRASS7=TRUE ^
161161
-D GRASS_PREFIX7=%GRASS72_PATH:\=/% ^
162162
-D WITH_GLOBE=FALSE ^
163-
-D WITH_TOUCH=TRUE ^
164163
-D WITH_ORACLE=TRUE ^
165164
-D WITH_CUSTOM_WIDGETS=TRUE ^
166165
-D CMAKE_CXX_FLAGS_RELEASE="/MD /MP /O2 /Ob2 /D NDEBUG" ^

python/CMakeLists.txt

-4
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,6 @@ ELSE(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
130130
SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} ARM)
131131
ENDIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
132132

133-
IF(NOT WITH_TOUCH)
134-
SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} HAVE_TOUCH)
135-
ENDIF(NOT WITH_TOUCH)
136-
137133
IF(NOT QT_MOBILITY_LOCATION_FOUND)
138134
SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} MOBILITY_LOCATION)
139135
ENDIF(NOT QT_MOBILITY_LOCATION_FOUND)

python/gui/gui.sip

-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@
118118
%Include qgsmaptoolidentify.sip
119119
%Include qgsmaptoolidentifyfeature.sip
120120
%Include qgsmaptoolpan.sip
121-
%Include qgsmaptooltouch.sip
122121
%Include qgsmaptoolzoom.sip
123122
%Include qgsmaplayerstylemanagerwidget.sip
124123
%Include qgsmessagebar.sip

python/gui/qgisinterface.sip

-2
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,6 @@ class QgisInterface : QObject
404404
// View menu actions
405405
//! Get access to the native pan action. Call trigger() on it to set the default pan map tool.
406406
virtual QAction *actionPan() = 0;
407-
//! Get access to the native touch action.
408-
virtual QAction *actionTouch() = 0;
409407
//! Get access to the native pan to selected action. Call trigger() on it to pan the map canvas to the selection.
410408
virtual QAction *actionPanToSelected() = 0;
411409
//! Get access to the native zoom in action. Call trigger() on it to set the default zoom in map tool.

python/gui/qgsmapcanvas.sip

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
%Feature HAVE_TOUCH
2-
31
/** \ingroup gui
42
* Map canvas is a class for displaying all GIS data types on a canvas.
53
*/
@@ -486,10 +484,9 @@ class QgsMapCanvas : QGraphicsView
486484
void messageEmitted( const QString& title, const QString& message, QgsMessageBar::MessageLevel = QgsMessageBar::INFO );
487485

488486
protected:
489-
%If (HAVE_TOUCH)
487+
490488
//! Overridden standard event to be gestures aware
491489
bool event( QEvent * e );
492-
%End
493490

494491
//! Overridden key press event
495492
void keyPressEvent( QKeyEvent * e );

python/gui/qgsmaptool.sip

-2
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,8 @@ class QgsMapTool : QObject
7171
//! Key event for overriding. Default implementation does nothing.
7272
virtual void keyReleaseEvent( QKeyEvent* e );
7373

74-
%If (HAVE_TOUCH)
7574
//! gesture event for overriding. Default implementation does nothing.
7675
virtual bool gestureEvent( QGestureEvent* e );
77-
%End
7876

7977
/** Use this to associate a QAction to this maptool. Then when the setMapTool
8078
* method of mapcanvas is called the action state will be set to on.

python/gui/qgsmaptooltouch.sip

-22
This file was deleted.

rpm/qgis.spec.template

-2
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ gzip ChangeLog
198198
# Necessary for the test suite
199199
#export LD_LIBRARY_PATH=%{_builddir}%{name}-%{version}/output/%{_lib}
200200

201-
#Info: TOUCH needs Qt >= 4.5
202201
%cmake \
203202
%{_cmake_skip_rpath} \
204203
-D QGIS_LIB_SUBDIR=%{_lib} \
@@ -224,7 +223,6 @@ gzip ChangeLog
224223
-D WITH_INTERNAL_SIX:BOOL=FALSE \
225224
-D WITH_PYSPATIALITE:BOOL=FALSE \
226225
-D WITH_SERVER:BOOL=TRUE \
227-
-D WITH_TOUCH:BOOL=TRUE \
228226
%{configure_with_spatialite} \
229227
.
230228
#-D WITH_QTMOBILITY:BOOL=TRUE \

src/app/qgisapp.cpp

+7-48
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,6 @@ extern "C"
360360
#include <DbgHelp.h>
361361
#endif
362362

363-
#ifdef HAVE_TOUCH
364-
#include "qgsmaptooltouch.h"
365-
#endif
366-
367363
class QTreeWidgetItem;
368364

369365
/** Set the application title bar text
@@ -1092,14 +1088,11 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
10921088
QgsDebugMsg( "Tips are disabled" );
10931089
}
10941090

1095-
#ifdef HAVE_TOUCH
1096-
//add reacting to long click in touch
1097-
grabGesture( Qt::TapAndHoldGesture );
1098-
#else
1099-
//remove mActionTouch button
1100-
delete mActionTouch;
1101-
mActionTouch = nullptr;
1102-
#endif
1091+
if ( ! QTouchDevice::devices().isEmpty() )
1092+
{
1093+
//add reacting to long click in touch
1094+
grabGesture( Qt::TapAndHoldGesture );
1095+
}
11031096

11041097
// supposedly all actions have been added, now register them to the shortcut manager
11051098
QgsShortcutsManager::instance()->registerAllChildren( this );
@@ -1253,9 +1246,6 @@ QgisApp::~QgisApp()
12531246
delete mMapTools.mZoomIn;
12541247
delete mMapTools.mZoomOut;
12551248
delete mMapTools.mPan;
1256-
#ifdef HAVE_TOUCH
1257-
delete mMapTools.mTouch;
1258-
#endif
12591249
delete mMapTools.mAddFeature;
12601250
delete mMapTools.mAddPart;
12611251
delete mMapTools.mAddRing;
@@ -1496,12 +1486,10 @@ bool QgisApp::event( QEvent * event )
14961486
openFile( foe->file() );
14971487
done = true;
14981488
}
1499-
#ifdef HAVE_TOUCH
1500-
else if ( event->type() == QEvent::Gesture )
1489+
else if ( !QTouchDevice::devices().isEmpty() && event->type() == QEvent::Gesture )
15011490
{
15021491
done = gestureEvent( static_cast<QGestureEvent*>( event ) );
15031492
}
1504-
#endif
15051493
else
15061494
{
15071495
// pass other events to base class
@@ -1639,10 +1627,6 @@ void QgisApp::createActions()
16391627
connect( mActionOffsetCurve, SIGNAL( triggered() ), this, SLOT( offsetCurve() ) );
16401628

16411629
// View Menu Items
1642-
1643-
#ifdef HAVE_TOUCH
1644-
connect( mActionTouch, SIGNAL( triggered() ), this, SLOT( touch() ) );
1645-
#endif
16461630
connect( mActionPan, SIGNAL( triggered() ), this, SLOT( pan() ) );
16471631
connect( mActionPanToSelected, SIGNAL( triggered() ), this, SLOT( panToSelected() ) );
16481632
connect( mActionZoomIn, SIGNAL( triggered() ), this, SLOT( zoomIn() ) );
@@ -1871,9 +1855,6 @@ void QgisApp::createActionGroups()
18711855
//
18721856
// Map Tool Group
18731857
mMapToolGroup = new QActionGroup( this );
1874-
#ifdef HAVE_TOUCH
1875-
mMapToolGroup->addAction( mActionTouch );
1876-
#endif
18771858
mMapToolGroup->addAction( mActionPan );
18781859
mMapToolGroup->addAction( mActionZoomIn );
18791860
mMapToolGroup->addAction( mActionZoomOut );
@@ -2682,9 +2663,6 @@ void QgisApp::setTheme( const QString& theThemeName )
26822663
mActionZoomFullExtent->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomFullExtent.svg" ) ) );
26832664
mActionZoomToSelected->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomToSelected.svg" ) ) );
26842665
mActionShowRasterCalculator->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionShowRasterCalculator.png" ) ) );
2685-
#ifdef HAVE_TOUCH
2686-
mActionTouch->setIcon( QgsApplication::getThemeIcon( "/mActionTouch.svg" ) );
2687-
#endif
26882666
mActionPan->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionPan.svg" ) ) );
26892667
mActionPanToSelected->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionPanToSelected.svg" ) ) );
26902668
mActionZoomLast->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomLast.svg" ) ) );
@@ -2861,10 +2839,6 @@ void QgisApp::createCanvasTools()
28612839
mMapTools.mZoomOut->setAction( mActionZoomOut );
28622840
mMapTools.mPan = new QgsMapToolPan( mMapCanvas );
28632841
mMapTools.mPan->setAction( mActionPan );
2864-
#ifdef HAVE_TOUCH
2865-
mMapTools.mTouch = new QgsMapToolTouch( mMapCanvas );
2866-
mMapTools.mTouch->setAction( mActionTouch );
2867-
#endif
28682842
mMapTools.mIdentify = new QgsMapToolIdentifyAction( mMapCanvas );
28692843
mMapTools.mIdentify->setAction( mActionIdentify );
28702844
connect( mMapTools.mIdentify, SIGNAL( copyToClipboard( QgsFeatureStore & ) ),
@@ -4591,15 +4565,10 @@ void QgisApp::fileNew( bool thePromptToSaveFlag, bool forceBlank )
45914565
}
45924566

45934567
// set the initial map tool
4594-
#ifndef HAVE_TOUCH
45954568
mMapCanvas->setMapTool( mMapTools.mPan );
45964569
mNonEditMapTool = mMapTools.mPan; // signals are not yet setup to catch this
4597-
#else
4598-
mMapCanvas->setMapTool( mMapTools.mTouch );
4599-
mNonEditMapTool = mMapTools.mTouch; // signals are not yet setup to catch this
4600-
#endif
46014570

4602-
} // QgisApp::fileNew(bool thePromptToSaveFlag)
4571+
}
46034572

46044573
bool QgisApp::fileNewFromTemplate( const QString& fileName )
46054574
{
@@ -5834,13 +5803,6 @@ void QgisApp::pan()
58345803
mMapCanvas->setMapTool( mMapTools.mPan );
58355804
}
58365805

5837-
#ifdef HAVE_TOUCH
5838-
void QgisApp::touch()
5839-
{
5840-
mMapCanvas->setMapTool( mMapTools.mTouch );
5841-
}
5842-
#endif
5843-
58445806
void QgisApp::zoomFull()
58455807
{
58465808
mMapCanvas->zoomToFullExtent();
@@ -12101,8 +12063,6 @@ void QgisApp::onLayerError( const QString& msg )
1210112063
mInfoBar->pushCritical( tr( "Layer %1" ).arg( layer->name() ), msg );
1210212064
}
1210312065

12104-
12105-
#ifdef HAVE_TOUCH
1210612066
bool QgisApp::gestureEvent( QGestureEvent *event )
1210712067
{
1210812068
if ( QGesture *tapAndHold = event->gesture( Qt::TapAndHoldGesture ) )
@@ -12125,7 +12085,6 @@ void QgisApp::tapAndHoldTriggered( QTapAndHoldGesture *gesture )
1212512085
QApplication::postEvent( receiver, new QMouseEvent( QEvent::MouseButtonRelease, receiver->mapFromGlobal( pos ), Qt::RightButton, Qt::RightButton, Qt::NoModifier ) );
1212612086
}
1212712087
}
12128-
#endif
1212912088

1213012089
#ifdef Q_OS_WIN
1213112090
LONG WINAPI QgisApp::qgisCrashDump( struct _EXCEPTION_POINTERS *ExceptionInfo )

src/app/qgisapp.h

+1-15
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,8 @@ class QgsDiagramProperties;
131131
#include "ui_qgisapp.h"
132132
#include "qgis_app.h"
133133

134-
#ifdef HAVE_TOUCH
135134
#include <QGestureEvent>
136135
#include <QTapAndHoldGesture>
137-
#endif
138136

139137
#ifdef Q_OS_WIN
140138
#include <windows.h>
@@ -352,7 +350,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
352350
QAction *actionSnappingOptions() { return mActionSnappingOptions; }
353351
QAction *actionOffsetCurve() { return mActionOffsetCurve; }
354352
QAction *actionPan() { return mActionPan; }
355-
QAction *actionTouch() { return mActionTouch; }
356353
QAction *actionPanToSelected() { return mActionPanToSelected; }
357354
QAction *actionZoomIn() { return mActionZoomIn; }
358355
QAction *actionZoomOut() { return mActionZoomOut; }
@@ -1222,10 +1219,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
12221219
void zoomIn();
12231220
//! Set map tool to pan
12241221
void pan();
1225-
#ifdef HAVE_TOUCH
1226-
//! Set map tool to touch
1227-
void touch();
1228-
#endif
12291222
//! Identify feature(s) on the currently selected layer
12301223
void identify();
12311224
//! Measure distance
@@ -1590,9 +1583,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
15901583
: mZoomIn( nullptr )
15911584
, mZoomOut( nullptr )
15921585
, mPan( nullptr )
1593-
#ifdef HAVE_TOUCH
1594-
, mTouch( 0 )
1595-
#endif
15961586
, mIdentify( nullptr )
15971587
, mFeatureAction( nullptr )
15981588
, mMeasureDist( nullptr )
@@ -1639,9 +1629,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
16391629
QgsMapTool *mZoomIn;
16401630
QgsMapTool *mZoomOut;
16411631
QgsMapTool *mPan;
1642-
#ifdef HAVE_TOUCH
1643-
QgsMapTool *mTouch;
1644-
#endif
16451632
QgsMapTool *mIdentify;
16461633
QgsMapTool *mFeatureAction;
16471634
QgsMapTool *mMeasureDist;
@@ -1865,10 +1852,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
18651852
QStackedWidget* mCentralContainer;
18661853

18671854
int mProjOpen;
1868-
#ifdef HAVE_TOUCH
1855+
18691856
bool gestureEvent( QGestureEvent *event );
18701857
void tapAndHoldTriggered( QTapAndHoldGesture *gesture );
1871-
#endif
18721858

18731859
friend class TestQgisAppPython;
18741860
};

src/app/qgisappinterface.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,6 @@ QAction *QgisAppInterface::actionNodeTool() { return qgis->actionNodeTool(); }
573573

574574
//! View menu actions
575575
QAction *QgisAppInterface::actionPan() { return qgis->actionPan(); }
576-
QAction *QgisAppInterface::actionTouch() { return qgis->actionTouch(); }
577576
QAction *QgisAppInterface::actionPanToSelected() { return qgis->actionPanToSelected(); }
578577
QAction *QgisAppInterface::actionZoomIn() { return qgis->actionZoomIn(); }
579578
QAction *QgisAppInterface::actionZoomOut() { return qgis->actionZoomOut(); }

src/app/qgisappinterface.h

-1
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,6 @@ class APP_EXPORT QgisAppInterface : public QgisInterface
392392

393393
//! View menu actions
394394
virtual QAction *actionPan() override;
395-
virtual QAction *actionTouch() override;
396395
virtual QAction *actionPanToSelected() override;
397396
virtual QAction *actionZoomIn() override;
398397
virtual QAction *actionZoomOut() override;

0 commit comments

Comments
 (0)