From 6272731f996ce48ed405bb5eb1b53ebfdbeea08a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Fri, 20 Aug 2010 19:09:23 +0200
Subject: Disable dropping of images & URL context menus in the chat view.


diff --git a/Swift/QtUI/QtWebView.cpp b/Swift/QtUI/QtWebView.cpp
index a97357d..93ecc18 100644
--- a/Swift/QtUI/QtWebView.cpp
+++ b/Swift/QtUI/QtWebView.cpp
@@ -9,10 +9,10 @@
 
 #include <QKeyEvent>
 #include <QFocusEvent>
+#include <QMenu>
 
 namespace Swift {
 QtWebView::QtWebView(QWidget* parent) : QWebView(parent) {
-
 }
 
 void QtWebView::keyPressEvent(QKeyEvent* event) {
@@ -31,6 +31,19 @@ void QtWebView::keyPressEvent(QKeyEvent* event) {
 	delete translatedEvent;
 }
 
+void QtWebView::dragEnterEvent(QDragEnterEvent *event) {
+
+}
+
+void QtWebView::contextMenuEvent(QContextMenuEvent* ev) {
+	QAction* copyLinkAction = pageAction(QWebPage::CopyLinkToClipboard);
+	if (copyLinkAction) {
+		QMenu menu(this);
+		menu.addAction(copyLinkAction);
+		menu.exec(ev->globalPos());
+	}
+}
+
 void QtWebView::focusInEvent(QFocusEvent* event) {
 	QWebView::focusInEvent(event);
 	emit gotFocus();
diff --git a/Swift/QtUI/QtWebView.h b/Swift/QtUI/QtWebView.h
index 3ab5c64..171330d 100644
--- a/Swift/QtUI/QtWebView.h
+++ b/Swift/QtUI/QtWebView.h
@@ -15,6 +15,9 @@ namespace Swift {
 		public:
 			QtWebView(QWidget* parent);
 			void keyPressEvent(QKeyEvent* event);
+			void dragEnterEvent(QDragEnterEvent *event);
+			void contextMenuEvent(QContextMenuEvent* ev);
+
 		signals:
 			void gotFocus();
 
-- 
cgit v0.10.2-6-g49f6