summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-08-28 19:15:00 +0200
committerAndrea Diamantini <adjam7@gmail.com>2010-08-28 19:15:00 +0200
commit260486b9f880f78b800711abbe320b0cdf55d0bf (patch)
tree67051a295995eeeeb27acf3c52aac70758d95a1a
parentfix po file’s URL (playground-network → extragear-network) (diff)
parentadd "copy image location" action in the webview's contextual menu (diff)
downloadrekonq-260486b9f880f78b800711abbe320b0cdf55d0bf.tar.xz
Merge commit 'refs/merge-requests/192' of git://gitorious.org/rekonq/mainline
-rw-r--r--src/webview.cpp24
-rw-r--r--src/webview.h1
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();