From 71c970a61ba6d27df8bc654a814196248b8140a1 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 4 Dec 2012 00:22:02 +0100 Subject: "Save as..." context menu action entry for images BUG: 303357 --- src/webtab/webview.cpp | 22 +++++++++++++++++++++- src/webtab/webview.h | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/webtab/webview.cpp b/src/webtab/webview.cpp index db87a993..862355e9 100644 --- a/src/webtab/webview.cpp +++ b/src/webtab/webview.cpp @@ -38,6 +38,7 @@ // Local Includes #include "adblockmanager.h" #include "bookmarkmanager.h" +#include "downloadmanager.h" #include "iconmanager.h" #include "searchengine.h" @@ -411,7 +412,10 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) this, SLOT(viewImage(Qt::MouseButtons, Qt::KeyboardModifiers))); menu.addAction(a); - menu.addAction(pageAction(KWebPage::DownloadImageToDisk)); + a = new KAction(KIcon("document-save"), i18n("Save image as..."), this); + a->setData(m_contextMenuHitResult.imageUrl()); + connect(a, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(saveImage())); + menu.addAction(a); a = new KAction(KIcon("view-media-visualization"), i18n("&Copy Image Location"), this); a->setData(m_contextMenuHitResult.imageUrl()); @@ -767,6 +771,7 @@ void WebView::openLinkInNewTab() emit loadUrl(url, Rekonq::NewFocusedTab); } + void WebView::openLinkInPrivateWindow() { KAction *a = qobject_cast(sender()); @@ -775,6 +780,7 @@ void WebView::openLinkInPrivateWindow() emit loadUrl(url, Rekonq::NewPrivateWindow); } + void WebView::bookmarkLink() { KAction *a = qobject_cast(sender()); @@ -1478,3 +1484,17 @@ WebTab *WebView::parentTab() { return m_parentTab; } + + +void WebView::saveImage() +{ + KAction *a = qobject_cast(sender()); + KUrl imageUrl(a->data().toUrl()); + + DownloadManager::self()->downloadResource( imageUrl, + KIO::MetaData(), + this, + true, + QString(), + !settings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)); +} diff --git a/src/webtab/webview.h b/src/webtab/webview.h index b33f3d87..161d8c65 100644 --- a/src/webtab/webview.h +++ b/src/webtab/webview.h @@ -109,6 +109,7 @@ private Q_SLOTS: void slotSpellCheckDone(const QString&); void sendByMail(); + void saveImage(); void viewImage(Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers); void slotCopyImageLocation(); -- cgit v1.2.1