[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.16-1409-g5afdf4d
vestbo at webkit.org
vestbo at webkit.org
Thu Dec 3 13:38:51 UTC 2009
The following commit has been merged in the webkit-1.1 branch:
commit e191cdb42dfc9eadab605e79a516ec78cf250039
Author: vestbo at webkit.org <vestbo at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Nov 18 12:58:29 2009 +0000
[Qt] Add QtLauncher support for opening links in the default browser
Reviewed by Simon Hausmann.
This can be triggered by either the context menu or by clicking a link
while holding down the Alt key. Opening a link in a new windows is
triggered by holding down Shift.
* QtLauncher/main.cpp:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51106 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
index aac2d72..00cdf2a 100644
--- a/WebKit/qt/ChangeLog
+++ b/WebKit/qt/ChangeLog
@@ -1,3 +1,15 @@
+2009-11-18 Tor Arne Vestbø <tor.arne.vestbo at nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] Add QtLauncher support for opening links in the default browser
+
+ This can be triggered by either the context menu or by clicking a link
+ while holding down the Alt key. Opening a link in a new windows is
+ triggered by holding down Shift.
+
+ * QtLauncher/main.cpp:
+
2009-11-17 Yael Aharon <yael.aharon at nokia.com>
Reviewed by Kenneth Rohde Christiansen.
diff --git a/WebKit/qt/QtLauncher/main.cpp b/WebKit/qt/QtLauncher/main.cpp
index cff0068..eae6171 100644
--- a/WebKit/qt/QtLauncher/main.cpp
+++ b/WebKit/qt/QtLauncher/main.cpp
@@ -40,6 +40,7 @@
#include <QtGui>
#include <QDebug>
#include <QtNetwork/QNetworkProxy>
+#include <QtNetwork/QNetworkRequest>
#if QT_VERSION >= 0x040400 && !defined(QT_NO_PRINTER)
#include <QPrintPreviewDialog>
#endif
@@ -66,6 +67,51 @@ static QUrl urlFromUserInput(const QString& input)
#endif
}
+class WebView : public QWebView
+{
+ Q_OBJECT
+public:
+ WebView(QWidget* parent) : QWebView(parent) {}
+
+protected:
+ virtual void contextMenuEvent(QContextMenuEvent* event)
+ {
+ QMenu* menu = page()->createStandardContextMenu();
+
+ QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos());
+
+ if (!r.linkUrl().isEmpty()) {
+ QAction* newTabAction = menu->addAction(tr("Open in Default &Browser"), this, SLOT(openUrlInDefaultBrowser()));
+ newTabAction->setData(r.linkUrl());
+ menu->insertAction(menu->actions().at(2), newTabAction);
+ }
+
+ menu->exec(mapToGlobal(event->pos()));
+ delete menu;
+ }
+
+ virtual void mousePressEvent(QMouseEvent* event)
+ {
+ mouseButtons = event->buttons();
+ keyboardModifiers = event->modifiers();
+
+ QWebView::mousePressEvent(event);
+ }
+
+public slots:
+ void openUrlInDefaultBrowser(const QUrl &url = QUrl())
+ {
+ if (QAction* action = qobject_cast<QAction*>(sender()))
+ QDesktopServices::openUrl(action->data().toUrl());
+ else
+ QDesktopServices::openUrl(url);
+ }
+
+public:
+ Qt::MouseButtons mouseButtons;
+ Qt::KeyboardModifiers keyboardModifiers;
+};
+
class WebPage : public QWebPage
{
public:
@@ -80,6 +126,22 @@ public:
return false;
}
virtual bool extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output);
+
+
+ virtual bool acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest &request, NavigationType type)
+ {
+ WebView* webView = static_cast<WebView*>(view());
+ if (webView->keyboardModifiers & Qt::ShiftModifier) {
+ QWebPage* page = createWindow(QWebPage::WebBrowserWindow);
+ page->mainFrame()->load(request);
+ return false;
+ } else if (webView->keyboardModifiers & Qt::AltModifier) {
+ webView->openUrlInDefaultBrowser(request.url());
+ return false;
+ }
+
+ return QWebPage::acceptNavigationRequest(frame, request, type);
+ }
};
class MainWindow : public QMainWindow
@@ -94,7 +156,7 @@ public:
QSplitter* splitter = new QSplitter(Qt::Vertical, this);
setCentralWidget(splitter);
- view = new QWebView(splitter);
+ view = new WebView(splitter);
WebPage* page = new WebPage(view);
view->setPage(page);
connect(view, SIGNAL(loadFinished(bool)),
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list