summaryrefslogtreecommitdiffstats
path: root/lib/web_contents_view_qt.cpp
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@digia.com>2013-08-28 14:19:14 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-11 14:20:07 +0200
commit3062467e7ae4ca68377216083e015846b307e5a0 (patch)
tree13250a49a7c925524a0d50aa807cc229fa95b1d4 /lib/web_contents_view_qt.cpp
parent18e6f0ac27cf53bc21cf8c54887932de116648ff (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/web_contents_view_qt.cpp')
-rw-r--r--lib/web_contents_view_qt.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/web_contents_view_qt.cpp b/lib/web_contents_view_qt.cpp
index 340075c9a..8fc7f5b12 100644
--- a/lib/web_contents_view_qt.cpp
+++ b/lib/web_contents_view_qt.cpp
@@ -48,6 +48,7 @@
#include "base/command_line.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/public/common/content_switches.h"
+#include "content/public/common/context_menu_params.h"
void WebContentsViewQt::initialize(WebContentsAdapterClient* client)
{
@@ -111,3 +112,19 @@ void WebContentsViewQt::SetInitialFocus()
{
Focus();
}
+
+static WebEngineContextMenuData fromParams(const content::ContextMenuParams &params)
+{
+ WebEngineContextMenuData ret;
+ ret.pos = QPoint(params.x, params.y);
+ ret.linkUrl = toQt(params.link_url);
+ ret.linkText = toQt(params.link_text.data());
+ ret.selectedText = toQt(params.selection_text.data());
+ return ret;
+}
+
+void WebContentsViewQt::ShowContextMenu(const content::ContextMenuParams &params)
+{
+ WebEngineContextMenuData contextMenuData(fromParams(params));
+ m_client->contextMenuRequested(contextMenuData);
+}