summaryrefslogtreecommitdiff
path: root/src/webview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/webview.cpp')
-rw-r--r--src/webview.cpp83
1 files changed, 68 insertions, 15 deletions
diff --git a/src/webview.cpp b/src/webview.cpp
index ec747b36..e39cdacb 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(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 if (result.isContentEditable())
@@ -191,7 +205,34 @@ 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 if (!result.pixmap().isNull())
+ {
+ menu.addSeparator();
+
+ // TODO Add "View Image" && remove copy_this_image action
+ a = pageAction(QWebPage::DownloadImageToDisk);
+ a->setIcon(KIcon("document-save"));
+ menu.addAction(a);
+
+ a = pageAction(QWebPage::CopyImageToClipboard);
+ a->setIcon(KIcon("edit-copy"));
+ menu.addAction(a);
}
else
{
@@ -207,20 +248,6 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
menu.addAction(mainwindow->actionByName("history_back"));
menu.addAction(mainwindow->actionByName("history_forward"));
menu.addAction(mainwindow->actionByName("view_redisplay"));
-
- if (!result.pixmap().isNull())
- {
- menu.addSeparator();
-
- // TODO Add "View Image" && remove copy_this_image action
- a = pageAction(QWebPage::DownloadImageToDisk);
- a->setIcon(KIcon("document-save"));
- menu.addAction(a);
-
- a = pageAction(QWebPage::CopyImageToClipboard);
- a->setIcon(KIcon("edit-copy"));
- menu.addAction(a);
- }
menu.addSeparator();
@@ -271,6 +298,9 @@ void WebView::keyPressEvent(QKeyEvent *event)
void WebView::mousePressEvent(QMouseEvent *event)
{
+ m_page->m_pressedButtons = event->buttons();
+ m_page->m_keyboardModifiers = event->modifiers();
+
switch(event->button())
{
case Qt::XButton1:
@@ -283,3 +313,26 @@ void WebView::mousePressEvent(QMouseEvent *event)
QWebView::mousePressEvent(event);
};
}
+
+
+void WebView::wheelEvent(QWheelEvent *event)
+{
+ if (QApplication::keyboardModifiers() & Qt::ControlModifier)
+ {
+ int numDegrees = event->delta() / 8;
+ int numSteps = numDegrees / 15;
+ setTextSizeMultiplier(textSizeMultiplier() + numSteps * 0.1);
+ event->accept();
+ return;
+ }
+ QWebView::wheelEvent(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);
+}