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 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/protocolhandler.cpp') 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) ; -- cgit v1.2.1