summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Beschow <bbeschow@cs.tu-berlin.de>2016-09-17 20:48:17 (GMT)
committerBernhard Beschow <bbeschow@cs.tu-berlin.de>2016-09-18 09:48:54 (GMT)
commitf6e27008765c8023be8f124403b21a4b1a3377f0 (patch)
treee825433cb535971b5f78e71bc7e36c962447a507
parent7321f7fcf1d89f015659edecf32956eccd8442a0 (diff)
open URLs in external browser
An external browser greatly enhances browsing experience: * no more too small window * tabbed browsing * save web pages, add bookmarks * more privacy (adblockers) * browser extensions
-rw-r--r--src/lib/marble/PopupItem.cpp8
-rw-r--r--src/lib/marble/PopupItem.h6
2 files changed, 14 insertions, 0 deletions
diff --git a/src/lib/marble/PopupItem.cpp b/src/lib/marble/PopupItem.cpp
index c802d86..fff1601 100644
--- a/src/lib/marble/PopupItem.cpp
+++ b/src/lib/marble/PopupItem.cpp
@@ -27,6 +27,7 @@
#include <QPrintDialog>
#include <QMouseEvent>
#include <QApplication>
+#include <QDesktopServices>
#include <QPixmapCache>
#include <qdrawutil.h>
#include <QPainter>
@@ -64,6 +65,7 @@ PopupItem::PopupItem( QObject* parent ) :
m_ui.webView->setPalette(palette);
#ifndef MARBLE_NO_WEBKITWIDGETS
m_ui.webView->page()->setPalette(palette);
+ m_ui.webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
#endif
m_ui.webView->setAttribute(Qt::WA_OpaquePaintEvent, false);
m_ui.webView->setUrl( QUrl( "about:blank" ) );
@@ -75,6 +77,7 @@ PopupItem::PopupItem( QObject* parent ) :
#ifndef MARBLE_NO_WEBKITWIDGETS
// Update the popupitem on changes while loading the webpage
connect( m_ui.webView->page(), SIGNAL(repaintRequested(QRect)), this, SLOT(requestUpdate()) );
+ connect(m_ui.webView->page(), SIGNAL(linkClicked(QUrl)), this, SLOT(openUrl(QUrl)));
#endif
}
@@ -386,6 +389,11 @@ void PopupItem::goBack()
#endif
}
+void PopupItem::openUrl(const QUrl &url)
+{
+ QDesktopServices::openUrl(url);
+}
+
QPixmap PopupItem::pixmap( const QString &imageId ) const
{
QPixmap result;
diff --git a/src/lib/marble/PopupItem.h b/src/lib/marble/PopupItem.h
index 6d1e702..432b893 100644
--- a/src/lib/marble/PopupItem.h
+++ b/src/lib/marble/PopupItem.h
@@ -163,6 +163,12 @@ private Q_SLOTS:
*/
void goBack();
+ /**
+ * @brief Opens clicked URL in external browser.
+ * @param url URL to be opened in external browser
+ */
+ void openUrl(const QUrl &url);
+
protected:
void paint( QPainter *painter );