diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2009-06-30 02:17:15 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2009-06-30 02:17:15 +0200 |
commit | 313314b39214c6b6c673d882dfbf3deab91007c0 (patch) | |
tree | 2d8c2bc503c4f5b1bb75d8c8cc628c7125f257f7 /src/mainview.cpp | |
parent | Fixing silly conditions on CMakeLists KDE version (diff) | |
download | rekonq-313314b39214c6b6c673d882dfbf3deab91007c0.tar.xz |
Fake gg:// and wk:// protocol.
Initial Url && Search Bar (to be improved in 0.3)
Trivial cleaning things here and there..
Diffstat (limited to 'src/mainview.cpp')
-rw-r--r-- | src/mainview.cpp | 58 |
1 files changed, 53 insertions, 5 deletions
diff --git a/src/mainview.cpp b/src/mainview.cpp index 75154528..f3ccbce2 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -46,6 +46,7 @@ #include <KActionCollection> #include <KDebug> #include <KStandardDirs> +#include <KToolInvocation> // Qt Includes #include <QtCore/QTimer> @@ -629,24 +630,71 @@ void MainView::webViewUrlChanged(const QUrl &url) } +// WARNING this method is ready to be refactored with real KServices implementation +// and moved to a RekonqRun class (0.3 target) void MainView::loadUrl(const KUrl &url) { if (url.isEmpty()) return; - currentUrlBar()->setUrl(url.prettyUrl()); + QString scheme = url.scheme(); - WebView *webView = currentWebView(); + if (scheme == QLatin1String("mailto")) + { + KToolInvocation::invokeMailer(url); + return; + } KUrl loadingUrl(url); + // create convenience fake api:// protocol for KDE apidox search and Qt docs + if (scheme == QLatin1String("api")) + { + QString path; + QString className = url.host().toLower(); + if (className[0] == 'k') + { + path = QString("http://api.kde.org/new.classmapper.php?class=%1").arg(className); + } + else if (className[0] == 'q') + { + path = QString("http://doc.trolltech.com/4.5/%1.html").arg(className); + } + loadingUrl.setUrl(path); + } + if (loadingUrl.isRelative()) { - QString fn = loadingUrl.url(KUrl::RemoveTrailingSlash); - loadingUrl.setUrl("//" + fn); - loadingUrl.setScheme("http"); + if(loadingUrl.path().contains('.')) + { + QString fn = loadingUrl.url(KUrl::RemoveTrailingSlash); + loadingUrl.setUrl("//" + fn); + loadingUrl.setScheme("http"); + } + else + { + scheme = QLatin1String("gg"); + } + } + + // create convenience fake gg:// protocol, waiting for KServices learning + if(scheme == QLatin1String("gg")) + { + QString str = loadingUrl.path(); + loadingUrl.setUrl( QString("http://google.com/complete/search?output=toolbar&q=%1").arg(str) ); } + // create convenience fake wk:// protocol, waiting for KServices learning + if(scheme == QLatin1String("wk")) + { + QString str = loadingUrl.path(); + loadingUrl.setUrl( QString("http://en.wikipedia.org/wiki/%1").arg(str) ); + } + + currentUrlBar()->setUrl(loadingUrl.prettyUrl()); + + WebView *webView = currentWebView(); + if (webView) { webView->load(loadingUrl); |