diff options
Diffstat (limited to 'src/webview.cpp')
-rw-r--r-- | src/webview.cpp | 39 |
1 files changed, 38 insertions, 1 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); +} |