mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Fix allow clicking on a tags in maptips (#3218)
this is done by listening to the linkClicked signal
This commit is contained in:
parent
7697d79a21
commit
b4436271fe
@ -3,7 +3,7 @@
|
||||
* A maptip is a class to display a tip on a map canvas
|
||||
* when a mouse is hovered over a feature.
|
||||
*/
|
||||
class QgsMapTip
|
||||
class QgsMapTip: QWidget
|
||||
{
|
||||
%TypeHeaderCode
|
||||
#include <qgsmaptip.h>
|
||||
|
@ -401,6 +401,7 @@ SET(QGIS_GUI_MOC_HDRS
|
||||
qgsmaplayerproxymodel.h
|
||||
qgsmaplayerstylemanagerwidget.h
|
||||
qgsmapoverviewcanvas.h
|
||||
qgsmaptip.h
|
||||
qgsmaptool.h
|
||||
qgsmaptooladvanceddigitizing.h
|
||||
qgsmaptoolcapture.h
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <QToolTip>
|
||||
#include <QSettings>
|
||||
#include <QLabel>
|
||||
#include <QDesktopServices>
|
||||
#if WITH_QTWEBKIT
|
||||
#include <QWebElement>
|
||||
#endif
|
||||
@ -65,6 +66,13 @@ void QgsMapTip::showMapTip( QgsMapLayer *pLayer,
|
||||
mWidget = new QWidget( pMapCanvas );
|
||||
mWebView = new QgsWebView( mWidget );
|
||||
|
||||
|
||||
#if WITH_QTWEBKIT
|
||||
mWebView->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );//Handle link clicks by yourself
|
||||
mWebView->setContextMenuPolicy( Qt::NoContextMenu ); //No context menu is allowed if you don't need it
|
||||
connect( mWebView, SIGNAL( linkClicked( QUrl ) ), this, SLOT( onLinkClicked( QUrl ) ) );
|
||||
#endif
|
||||
|
||||
mWebView->page()->settings()->setAttribute(
|
||||
QWebSettings::DeveloperExtrasEnabled, true );
|
||||
mWebView->page()->settings()->setAttribute(
|
||||
@ -200,3 +208,9 @@ QString QgsMapTip::fetchFeature( QgsMapLayer *layer, QgsPoint &mapPosition, QgsM
|
||||
return feature.attribute( idx ).toString();
|
||||
}
|
||||
}
|
||||
|
||||
//This slot handles all clicks
|
||||
void QgsMapTip::onLinkClicked( const QUrl &url )
|
||||
{
|
||||
QDesktopServices::openUrl( url );
|
||||
}
|
||||
|
@ -19,8 +19,12 @@ class QgsMapLayer;
|
||||
class QgsMapCanvas;
|
||||
class QPoint;
|
||||
class QString;
|
||||
class QgsPoint;
|
||||
class QgsVectorLayer;
|
||||
class QgsWebView;
|
||||
|
||||
#include <QWidget>
|
||||
#include <QUrl>
|
||||
#include "qgsfeature.h"
|
||||
|
||||
/** \ingroup gui
|
||||
@ -42,8 +46,9 @@ class QgsWebView;
|
||||
* discourages link rel="stylesheet" in the body, but all browsers allow it.
|
||||
* see https://jakearchibald.com/2016/link-in-body/
|
||||
*/
|
||||
class GUI_EXPORT QgsMapTip
|
||||
class GUI_EXPORT QgsMapTip: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/** Default constructor
|
||||
*/
|
||||
@ -84,5 +89,7 @@ class GUI_EXPORT QgsMapTip
|
||||
QWidget* mWidget;
|
||||
QgsWebView* mWebView;
|
||||
|
||||
private slots:
|
||||
void onLinkClicked( const QUrl& url );
|
||||
};
|
||||
#endif // QGSMAPTIP_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user