summaryrefslogtreecommitdiff
path: root/src/webview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/webview.cpp')
-rw-r--r--src/webview.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/webview.cpp b/src/webview.cpp
index d911bc3a..49ca66df 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -233,6 +233,13 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
menu.addAction(pageAction(KWebPage::DownloadImageToDisk));
menu.addAction(pageAction(KWebPage::CopyImageToClipboard));
+
+ a = new KAction(KIcon("view-media-visualization"), i18n("&Copy Image Location"), this);
+ a->setData(result.imageUrl());
+ connect(a, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(slotCopyImageLocation()));
+ menu.addAction(a);
+
+ menu.addAction(pageAction(KWebPage::CopyLinkToClipboard));
menu.addSeparator();
menu.addAction(inspectAction);
@@ -445,6 +452,23 @@ void WebView::viewImage(Qt::MouseButtons buttons, Qt::KeyboardModifiers modifier
}
}
+void WebView::slotCopyImageLocation()
+{
+ KAction *a = qobject_cast<KAction*>(sender());
+ KUrl imageUrl (a->data().toUrl());
+#ifndef QT_NO_MIMECLIPBOARD
+ // Set it in both the mouse selection and in the clipboard
+ QMimeData* mimeData = new QMimeData;
+ imageUrl.populateMimeData( mimeData );
+ QApplication::clipboard()->setMimeData( mimeData, QClipboard::Clipboard );
+ mimeData = new QMimeData;
+ imageUrl.populateMimeData( mimeData );
+ QApplication::clipboard()->setMimeData( mimeData, QClipboard::Selection );
+#else
+ QApplication::clipboard()->setText( imageUrl.url() );
+#endif
+}
+
void WebView::openLinkInNewWindow()
{