From 3014a1d15cce472d7d895fbbaf906dd582cce55f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Tr=C3=B6scher?= Date: Mon, 1 Aug 2011 13:55:43 +0200 Subject: bookmark this link action in link's context menu REVIEW:102152 --- src/webview.cpp | 15 +++++++++++++++ src/webview.h | 1 + 2 files changed, 16 insertions(+) (limited to 'src') diff --git a/src/webview.cpp b/src/webview.cpp index a938ad70..1490c9bc 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -163,6 +163,11 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) connect(a, SIGNAL(triggered(bool)), this, SLOT(openLinkInNewWindow())); menu.addAction(a); + a = new KAction(KIcon("bookmark-new"), i18n("&Bookmark this Link"), this); + a->setData(result.linkUrl()); + connect(a, SIGNAL(triggered(bool)), this, SLOT(bookmarkLink())); + menu.addAction(a); + menu.addSeparator(); menu.addAction(pageAction(KWebPage::DownloadLinkToDisk)); menu.addAction(pageAction(KWebPage::CopyLinkToClipboard)); @@ -552,6 +557,16 @@ void WebView::openLinkInNewTab() } +void WebView::bookmarkLink() +{ + KAction *a = qobject_cast(sender()); + KUrl url(a->data().toUrl()); + + rApp->bookmarkProvider()->rootGroup().addBookmark(url.prettyUrl(), url); + rApp->bookmarkProvider()->bookmarkManager()->emitChanged(); +} + + void WebView::keyPressEvent(QKeyEvent *event) { if (event->modifiers() == Qt::ControlModifier) diff --git a/src/webview.h b/src/webview.h index b3db5ce0..790fa23f 100644 --- a/src/webview.h +++ b/src/webview.h @@ -76,6 +76,7 @@ private Q_SLOTS: void loadUrlInNewTab(const KUrl &); void openLinkInNewWindow(); void openLinkInNewTab(); + void bookmarkLink(); void viewImage(Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers); void slotCopyImageLocation(); -- cgit v1.2.1