From 5403b3eeb3309bdfebb9ced2cf091ce885065f88 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 16 Dec 2009 02:26:19 +0100 Subject: local files krun! --- src/protocolhandler.cpp | 18 +++++++++++++----- src/protocolhandler.h | 2 +- src/webpage.cpp | 2 -- 3 files changed, 14 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index c9b34945..26766377 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -28,6 +28,7 @@ // Local Includes #include "newtabpage.h" +#include "application.h" // KDE Includes #include @@ -99,8 +100,16 @@ bool ProtocolHandler::handle(const QNetworkRequest &request, QWebFrame *frame) // "file" handling if(url.protocol() == QLatin1String("file")) { - QString html = fileHandling(url); - frame->setHtml( html ); + QFileInfo fileInfo(url.path()); + if(fileInfo.isFile()) + { + new KRun(url, 0, 0, true); + } + else // dir + { + QString html = dirHandling(url); + frame->setHtml( html ); + } // KUrl::List list; // list.append(url); // KRun::run("dolphin %u",url,0); @@ -112,7 +121,7 @@ bool ProtocolHandler::handle(const QNetworkRequest &request, QWebFrame *frame) } -QString ProtocolHandler::fileHandling(const KUrl &url) +QString ProtocolHandler::dirHandling(const KUrl &url) { QDir dir(url.toLocalFile()); @@ -170,7 +179,7 @@ QString ProtocolHandler::fileHandling(const KUrl &url) msg += ""; if(item.isFile()) { - msg += QString::number( item.size()/1024 ) + "KB"; + msg += QString::number( item.size()/1024 ) + " KB"; } msg += ""; @@ -185,7 +194,6 @@ QString ProtocolHandler::fileHandling(const KUrl &url) QString html = QString(QLatin1String(file.readAll())) .arg(title) -// .arg(imagesPath) .arg(msg) ; diff --git a/src/protocolhandler.h b/src/protocolhandler.h index 09a28c21..8628a4f7 100644 --- a/src/protocolhandler.h +++ b/src/protocolhandler.h @@ -44,7 +44,7 @@ public: bool handle(const QNetworkRequest &request, QWebFrame *frame); private: - QString fileHandling(const KUrl &url); + QString dirHandling(const KUrl &url); }; #endif // PROTOCOL_HANDLER_H diff --git a/src/webpage.cpp b/src/webpage.cpp index accf0e44..1890e74c 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -224,7 +224,6 @@ QString WebPage::errorPage(QNetworkReply *reply) } QString title = i18n("Error loading: %1", reply->url().path()); - QString imagesPath = QString("file://") + KGlobal::dirs()->findResourceDir("data", "rekonq/pics/bg.png") + QString("rekonq/pics"); QString msg = "

" + reply->errorString() + "

"; QString urlString = reply->url().toString( QUrl::RemoveUserInfo | QUrl::RemoveQuery ); @@ -239,7 +238,6 @@ QString WebPage::errorPage(QNetworkReply *reply) QString html = QString(QLatin1String(file.readAll())) .arg(title) - .arg(imagesPath) .arg(msg) ; return html; -- cgit v1.2.1