summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2009-07-26 17:09:47 +0200
committerAndrea Diamantini <adjam7@gmail.com>2009-07-26 17:09:47 +0200
commit33114df2208f08ac4dda744a2f01e3fd9f29829b (patch)
tree854e4e241115774f0295d413cf22689a961b9025
parentFixed clear private data (diff)
downloadrekonq-33114df2208f08ac4dda744a2f01e3fd9f29829b.tar.xz
Wikipedia && Google contextual actions
I started implementing them from Lionel's code but changed a bit to use KServices implementation and just a unique slot
-rw-r--r--src/webview.cpp39
-rw-r--r--src/webview.h3
2 files changed, 40 insertions, 2 deletions
diff --git a/src/webview.cpp b/src/webview.cpp
index ec747b36..97c2f325 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -170,6 +170,20 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
a->setShortcut(KStandardShortcut::paste().primary());
menu.addAction(a);
+ menu.addSeparator();
+
+ a = new KAction(i18n("Google Search"), this);
+ a->setIcon(Application::icon(KUrl("http://www.google.com")));
+ a->setData("gg:");
+ connect(a, SIGNAL(triggered(bool)), this, SLOT(slotGoogleSearch()));
+ menu.addAction(a);
+
+ a = new KAction(i18n("Wikipedia Search"), this);
+ a->setIcon(Application::icon(KUrl("http://wikipedia.org")));
+ a->setData("wk:");
+ connect(a, SIGNAL(triggered(bool)), this, SLOT(slotWikipediaSearch()));
+ menu.addAction(a);
+
// TODO Add translate, show translation
}
else if (result.isContentEditable())
@@ -191,7 +205,21 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
a->setShortcut(KStandardShortcut::copy().primary());
menu.addAction(a);
- // TODO Add search with google, wikipedia, show translation
+ menu.addSeparator();
+
+ a = new KAction(i18n("Google Search"), this);
+ a->setIcon(Application::icon(KUrl("http://www.google.com")));
+ a->setData("gg:");
+ connect(a, SIGNAL(triggered(bool)), this, SLOT(slotGooWikiSearch()));
+ menu.addAction(a);
+
+ a = new KAction(i18n("Wikipedia Search"), this);
+ a->setIcon(Application::icon(KUrl("http://wikipedia.org")));
+ a->setData("wk:");
+ connect(a, SIGNAL(triggered(bool)), this, SLOT(slotGooWikiSearch()));
+ menu.addAction(a);
+
+ // TODO Add translate, show translation
}
else
{
@@ -283,3 +311,12 @@ void WebView::mousePressEvent(QMouseEvent *event)
QWebView::mousePressEvent(event);
};
}
+
+
+void WebView::slotGooWikiSearch()
+{
+ KAction *a = qobject_cast<KAction*>(sender());
+ QString search = a->data().toString() + selectedText();
+ KUrl urlSearch = KUrl::fromEncoded(search.toUtf8());
+ Application::instance()->loadUrl(urlSearch, Rekonq::NewTab);
+}
diff --git a/src/webview.h b/src/webview.h
index 4efb2733..ea80ef1a 100644
--- a/src/webview.h
+++ b/src/webview.h
@@ -64,7 +64,8 @@ private slots:
void setProgress(int progress);
void loadFinished();
void setStatusBarText(const QString &string);
-
+ void slotGooWikiSearch();
+
private:
WebPage *m_page;