summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2012-12-04 00:22:02 +0100
committerAndrea Diamantini <adjam7@gmail.com>2012-12-10 02:48:06 +0100
commit71c970a61ba6d27df8bc654a814196248b8140a1 (patch)
treea024b95249940b2b809c175c8cb3da3a9174c638
parentGet sure we are using suggested file name if available (diff)
downloadrekonq-71c970a61ba6d27df8bc654a814196248b8140a1.tar.xz
"Save as..." context menu action entry for images
BUG: 303357
-rw-r--r--src/webtab/webview.cpp22
-rw-r--r--src/webtab/webview.h1
2 files changed, 22 insertions, 1 deletions
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<KAction*>(sender());
@@ -775,6 +780,7 @@ void WebView::openLinkInPrivateWindow()
emit loadUrl(url, Rekonq::NewPrivateWindow);
}
+
void WebView::bookmarkLink()
{
KAction *a = qobject_cast<KAction*>(sender());
@@ -1478,3 +1484,17 @@ WebTab *WebView::parentTab()
{
return m_parentTab;
}
+
+
+void WebView::saveImage()
+{
+ KAction *a = qobject_cast<KAction*>(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();