Open links in an external browser
authorJan Dumon <j.dumon@option.com>
Wed, 17 Mar 2010 20:25:28 +0000 (21:25 +0100)
committerJan Dumon <j.dumon@option.com>
Wed, 17 Mar 2010 20:25:28 +0000 (21:25 +0100)
src/contentwindow.cpp
src/contentwindow.h

index 2acc73e..bb0f88a 100644 (file)
@@ -126,9 +126,6 @@ class ViewportItem : public QGraphicsWidget, public QAbstractKineticScroller {
                                m_widget->setPos(-p + m_overShoot);
                }
 
-               void cancelLeftMouseButtonPress(const QPoint & /*globalPressPos*/) {
-               }
-
                void sendEvent(QGraphicsItem *i, QEvent *e) {
                        m_ignoreEvents = true;
                        scene()->sendEvent(i, e);
@@ -230,9 +227,11 @@ ContentWindow::ContentWindow(QWidget *parent, Entry *e) : QMainWindow(parent) {
 
        /* TODO: Configurable text size ?? */
        webview->settings()->setFontSize(QWebSettings::MinimumFontSize, 22);
+       webview->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
 
        connect(webview, SIGNAL(loadFinished(bool)), SLOT(loadFinished(bool)));
        connect(webview, SIGNAL(loadStarted()), SLOT(loadStarted()));
+       connect(webview->page(), SIGNAL(linkClicked(const QUrl &)), SLOT(showLink(const QUrl &)));
 
        webview->setHtml(entry->content);
 
@@ -255,10 +254,14 @@ void ContentWindow::loadFinished(bool) {
        setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
 }
 
-void ContentWindow::seeOriginal() {
+void ContentWindow::showLink(const QUrl &url) {
        /* Attempt to launch external browser */
-       if(!QDesktopServices::openUrl(entry->link))
-               webview->setUrl(entry->link); /* Failed... Show inline */
+       if(!QDesktopServices::openUrl(url))
+               webview->setUrl(url); /* Failed... Show inline */
+}
+
+void ContentWindow::seeOriginal() {
+       showLink(entry->link);
 }
 
 void ContentWindow::closeEvent(QCloseEvent *event) {
index cdc0a78..a366a50 100644 (file)
@@ -19,6 +19,7 @@ class ContentWindow : public QMainWindow {
                void loadFinished(bool);
                void loadStarted();
                void seeOriginal();
+               void showLink(const QUrl &);
 
        private:
                Entry *entry;