diff options
author | Pierre Rossi <pierre.rossi@digia.com> | 2013-08-28 14:19:14 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-10-11 14:20:07 +0200 |
commit | 3062467e7ae4ca68377216083e015846b307e5a0 (patch) | |
tree | 13250a49a7c925524a0d50aa807cc229fa95b1d4 /lib/widgets/Api/qwebengineview.cpp | |
parent | 18e6f0ac27cf53bc21cf8c54887932de116648ff (diff) |
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 <zeno.albisser@digia.com>
Diffstat (limited to 'lib/widgets/Api/qwebengineview.cpp')
-rw-r--r-- | lib/widgets/Api/qwebengineview.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
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 <QAction> +#include <QMenu> +#include <QContextMenuEvent> #include <QStackedLayout> 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" |