summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/application.cpp3
-rw-r--r--src/webview.cpp67
-rw-r--r--src/webview.h2
3 files changed, 46 insertions, 26 deletions
diff --git a/src/application.cpp b/src/application.cpp
index 4213e276..c49892b7 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -268,13 +268,14 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type)
if (loadingUrl.isRelative())
{
QString fn = loadingUrl.url(KUrl::RemoveTrailingSlash);
- loadingUrl.setUrl("//" + fn);
if(loadingUrl.path().contains('.'))
{
+ loadingUrl.setUrl("//" + fn);
loadingUrl.setScheme("http");
}
else
{
+ loadingUrl.setUrl(fn);
loadingUrl.setScheme("gg");
}
}
diff --git a/src/webview.cpp b/src/webview.cpp
index e39cdacb..fec96edc 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -41,6 +41,8 @@
#include <KActionCollection>
#include <KDebug>
#include <KToolInvocation>
+#include <KService>
+#include <KUriFilterData>
// Qt Includes
#include <QtGui/QContextMenuEvent>
@@ -172,17 +174,26 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
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);
+ KConfig config("kuriikwsfilterrc"); //Share with konqueror
+ KConfigGroup cg = config.group("General");
+ QStringList favoriteEngines;
+ favoriteEngines << "wikipedia" << "google"; //defaults
+ favoriteEngines = cg.readEntry("FavoriteSearchEngines", favoriteEngines);
+ const char keywordDelimiter = cg.readEntry("KeywordDelimiter", static_cast<int>(':'));
+ KService::Ptr service;
+ KUriFilterData data;
+ foreach (QString engine, favoriteEngines)
+ {
+ service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(engine));
+ const QString searchProviderPrefix = *(service->property("Keys").toStringList().begin()) + keywordDelimiter;
+ data.setData(searchProviderPrefix + "some keyword");
+ a = new KAction(i18n("Search with ")+service->name(), this);
+ a->setIcon(Application::icon(KUrl(data.uri())));
+ a->setData(searchProviderPrefix);
+ connect(a, SIGNAL(triggered(bool)), this, SLOT(slotSearch()));
+ menu.addAction(a);
+ }
+
// TODO Add translate, show translation
}
@@ -207,18 +218,26 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
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);
-
+ KConfig config("kuriikwsfilterrc"); //Share with konqueror
+ KConfigGroup cg = config.group("General");
+ QStringList favoriteEngines;
+ favoriteEngines << "wikipedia" << "google"; //defaults
+ favoriteEngines = cg.readEntry("FavoriteSearchEngines", favoriteEngines);
+ const char keywordDelimiter = cg.readEntry("KeywordDelimiter", static_cast<int>(':'));
+ KService::Ptr service;
+ KUriFilterData data;
+ foreach (QString engine, favoriteEngines)
+ {
+ service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(engine));
+ const QString searchProviderPrefix = *(service->property("Keys").toStringList().begin()) + keywordDelimiter;
+ data.setData(searchProviderPrefix + "some keyword");
+ a = new KAction(i18n("Search with ")+service->name(), this);
+ a->setIcon(Application::icon(KUrl(data.uri())));
+ a->setData(searchProviderPrefix);
+ connect(a, SIGNAL(triggered(bool)), this, SLOT(slotSearch()));
+ menu.addAction(a);
+ }
+
// TODO Add translate, show translation
}
else if (!result.pixmap().isNull())
@@ -329,7 +348,7 @@ void WebView::wheelEvent(QWheelEvent *event)
}
-void WebView::slotGooWikiSearch()
+void WebView::slotSearch()
{
KAction *a = qobject_cast<KAction*>(sender());
QString search = a->data().toString() + selectedText();
diff --git a/src/webview.h b/src/webview.h
index ffdc874c..08d597db 100644
--- a/src/webview.h
+++ b/src/webview.h
@@ -64,7 +64,7 @@ private slots:
void setProgress(int progress);
void loadFinished();
void setStatusBarText(const QString &string);
- void slotGooWikiSearch();
+ void slotSearch();
private:
WebPage *m_page;