diff options
-rw-r--r-- | src/webview.cpp | 24 | ||||
-rw-r--r-- | src/webview.h | 1 |
2 files changed, 25 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() { diff --git a/src/webview.h b/src/webview.h index b9c04e47..f7341644 100644 --- a/src/webview.h +++ b/src/webview.h @@ -71,6 +71,7 @@ private slots: void openLinkInNewTab(); void viewImage(Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers); + void slotCopyImageLocation(); void inspect(); void scrollFrameChanged(); |