summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2011-11-22 09:44:38 +0100
committerAndrea Diamantini <adjam7@gmail.com>2011-11-22 09:45:59 +0100
commit06b040c342e5bd6ffe62aa13171408d6c1f4c346 (patch)
tree3d14355bcab01c073561c7e4d52074a247bd8ef8 /src
parentClean up WebView::contextMenuEvent function (diff)
downloadrekonq-06b040c342e5bd6ffe62aa13171408d6c1f4c346.tar.xz
Share URL by mail action
This is heavily based on Andrea Di Menna's patch on reviewboard. Thanks :) REVIEW: 102674
Diffstat (limited to 'src')
-rw-r--r--src/webview.cpp28
-rw-r--r--src/webview.h1
2 files changed, 29 insertions, 0 deletions
diff --git a/src/webview.cpp b/src/webview.cpp
index 72923158..c4019d71 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -52,6 +52,7 @@
#include <KMenu>
#include <KStandardAction>
#include <KStandardDirs>
+#include <KToolInvocation>
// Qt Includes
#include <QtCore/QFile>
@@ -148,6 +149,10 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
KAction *inspectAction = new KAction(KIcon("layer-visible-on"), i18n("Inspect Element"), this);
connect(inspectAction, SIGNAL(triggered(bool)), this, SLOT(inspect()));
+ KAction *sendByMailAction = new KAction(this);
+ sendByMailAction->setIcon(KIcon("mail-send"));
+ connect(sendByMailAction, SIGNAL(triggered(bool)), this, SLOT(sendByMail()));
+
// Choose right context
int resultHit = 0;
if (result.linkUrl().isEmpty())
@@ -174,6 +179,10 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
// EMPTY PAGE ACTIONS -------------------------------------------------------------------------
if (resultHit == WebView::EmptySelection)
{
+ // send by mail: page url
+ sendByMailAction->setData(page()->currentFrame()->url());
+ sendByMailAction->setText(i18n("Share page url"));
+
// navigation
QWebHistory *history = page()->history();
if (history->canGoBack())
@@ -241,6 +250,10 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
// LINK ACTIONS -------------------------------------------------------------------------------
if (resultHit & WebView::LinkSelection)
{
+ // send by mail: link url
+ sendByMailAction->setData(result.linkUrl());
+ sendByMailAction->setText(i18n("Share link"));
+
a = new KAction(KIcon("tab-new"), i18n("Open in New &Tab"), this);
a->setData(result.linkUrl());
connect(a, SIGNAL(triggered(bool)), this, SLOT(openLinkInNewTab()));
@@ -265,6 +278,10 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
// IMAGE ACTIONS ------------------------------------------------------------------------------
if (resultHit & WebView::ImageSelection)
{
+ // send by mail: image url
+ sendByMailAction->setData(result.imageUrl());
+ sendByMailAction->setText(i18n("Share image link"));
+
// TODO remove copy_this_image action
a = new KAction(KIcon("view-media-visualization"), i18n("&View Image"), this);
a->setData(result.imageUrl());
@@ -362,6 +379,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
// DEFAULT ACTIONs (on the bottom) ---------------------------------------------------
menu.addSeparator();
+ menu.addAction(sendByMailAction);
menu.addAction(inspectAction);
// finally launch the menu...
@@ -886,3 +904,13 @@ void WebView::dragMoveEvent(QDragMoveEvent *event)
else
KWebView::dragMoveEvent(event);
}
+
+
+void WebView::sendByMail()
+{
+ KAction *a = qobject_cast<KAction*>(sender());
+ QString url = a->data().toString();
+ kDebug() << "URL " << url;
+
+ KToolInvocation::invokeMailer("", "", "", "", url);
+} \ No newline at end of file
diff --git a/src/webview.h b/src/webview.h
index 042f95c6..7ab3acfa 100644
--- a/src/webview.h
+++ b/src/webview.h
@@ -86,6 +86,7 @@ private Q_SLOTS:
void openLinkInNewWindow();
void openLinkInNewTab();
void bookmarkLink();
+ void sendByMail();
void viewImage(Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
void slotCopyImageLocation();