From 3062467e7ae4ca68377216083e015846b307e5a0 Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Wed, 28 Aug 2013 14:19:14 +0200 Subject: Add preliminary context menu support This is essentially the widgets part, with some tricks to get it to honor the widget's context menu policy. It enables c++11 for the widgets library for the convenience of using lambdas, which admitedly we could do without, but seems reasonable considering our timeline and the fact that we build chromium that way. Change-Id: I6a632a78d2aa48fb0dfecfe491e92651d12407db Reviewed-by: Zeno Albisser --- lib/widgets/Api/qwebengineview.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lib/widgets/Api/qwebengineview.cpp') diff --git a/lib/widgets/Api/qwebengineview.cpp b/lib/widgets/Api/qwebengineview.cpp index d07e710ab..536f075f3 100644 --- a/lib/widgets/Api/qwebengineview.cpp +++ b/lib/widgets/Api/qwebengineview.cpp @@ -44,6 +44,9 @@ #include "qwebenginepage_p.h" +#include +#include +#include #include QT_BEGIN_NAMESPACE @@ -186,6 +189,24 @@ void QWebEngineView::setZoomFactor(qreal factor) page()->setZoomFactor(factor); } +bool QWebEngineView::event(QEvent *ev) +{ + Q_D(QWebEngineView); + // We swallow spontaneous contextMenu events and synthethize those back later on when we get the + // HandleContextMenu callback from chromium + if (ev->type() == QEvent::ContextMenu) { + ev->accept(); + return true; + } + return QWidget::event(ev); +} + +void QWebEngineView::contextMenuEvent(QContextMenuEvent *event) +{ + QMenu *menu = page()->createStandardContextMenu(); + menu->popup(event->globalPos()); +} + QT_END_NAMESPACE #include "moc_qwebengineview.cpp" -- cgit v1.2.1