summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2009-06-30 02:17:15 +0200
committerAndrea Diamantini <adjam7@gmail.com>2009-06-30 02:17:15 +0200
commit313314b39214c6b6c673d882dfbf3deab91007c0 (patch)
tree2d8c2bc503c4f5b1bb75d8c8cc628c7125f257f7 /src
parentFixing silly conditions on CMakeLists KDE version (diff)
downloadrekonq-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')
-rw-r--r--src/mainview.cpp58
-rw-r--r--src/mainview.h2
-rw-r--r--src/mainwindow.cpp1
-rw-r--r--src/webpage.cpp36
-rw-r--r--src/webpage.h5
5 files changed, 55 insertions, 47 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);
diff --git a/src/mainview.h b/src/mainview.h
index 7cb4e035..d338402a 100644
--- a/src/mainview.h
+++ b/src/mainview.h
@@ -2,7 +2,7 @@
*
* This file is a part of the rekonq project
*
-* Copyright (C) 2008 by Andrea Diamantini <adjam7 at gmail dot com>
+* Copyright (C) 2008-2009 by Andrea Diamantini <adjam7 at gmail dot com>
* Copyright (C) 2009 by Paweł Prażak <pawelprazak at gmail dot com>
*
*
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 519081d6..79a6db4b 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -891,7 +891,6 @@ void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status)
m_popup->setView(msg);
int h = KGlobalSettings::generalFont().pointSize();
- kWarning() << "h: " << h;
// setting popus in bottom-left position
int x = geometry().x();
diff --git a/src/webpage.cpp b/src/webpage.cpp
index 8c6c0d2a..133a263c 100644
--- a/src/webpage.cpp
+++ b/src/webpage.cpp
@@ -40,7 +40,7 @@
#include <KUrl>
#include <KActionCollection>
#include <KDebug>
-#include <KToolInvocation>
+
#include <KDE/KParts/BrowserRun>
#include <KDE/KMimeTypeTrader>
@@ -76,40 +76,6 @@ WebPage::WebPage(QObject *parent)
}
-bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type)
-{
-
- // TODO: implement ioslaves protocols
- QString scheme = request.url().scheme();
- if (scheme == QLatin1String("mailto"))
- {
- KToolInvocation::invokeMailer(request.url());
- return false;
- }
-
- // create convenience fake api:// protocol for KDE apidox search and Qt docs
- if (scheme == QLatin1String("api"))
- {
- QString path;
- QString className = request.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);
- }
- KUrl url(path);
-
- Application::instance()->mainWindow()->loadUrl(url);
- return false;
- }
-
- return QWebPage::acceptNavigationRequest(frame, request, type);
-}
-
-
KWebPage *WebPage::createWindow(QWebPage::WebWindowType type)
{
kDebug() << "creating window as new tab.. ";
diff --git a/src/webpage.h b/src/webpage.h
index 8fe9517d..c43212b6 100644
--- a/src/webpage.h
+++ b/src/webpage.h
@@ -48,13 +48,8 @@ public slots:
void manageNetworkErrors(QNetworkReply* reply);
protected:
- bool acceptNavigationRequest(QWebFrame *frame,
- const QNetworkRequest &request,
- NavigationType type);
-
KWebPage *createWindow(QWebPage::WebWindowType type);
-
protected Q_SLOTS:
virtual void slotHandleUnsupportedContent(QNetworkReply *reply);