diff options
author | megabigbug <megabigbug@arrakis.(none)> | 2010-08-27 22:17:58 +0200 |
---|---|---|
committer | megabigbug <megabigbug@arrakis.(none)> | 2010-08-27 22:17:58 +0200 |
commit | d8ee5b51d7028bf572ed6b6ec907bc6421e5863c (patch) | |
tree | 6a415b7fee9a0414c709bd621f105e68b50761d5 /src | |
parent | Merge commit 'refs/merge-requests/2292' of git://gitorious.org/rekonq/mainline (diff) | |
download | rekonq-d8ee5b51d7028bf572ed6b6ec907bc6421e5863c.tar.xz |
add "copy image location" action in the webview's contextual menu
Diffstat (limited to 'src')
-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(); |