diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2009-12-16 15:05:03 +0100 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2009-12-16 15:05:03 +0100 |
commit | 0f4543652464c80c80f4471450da274194ae687b (patch) | |
tree | 46f9d8aadbb4c023a17acf02b5459985154f336f | |
parent | rekonq 0.3.23 (diff) | |
download | rekonq-0f4543652464c80c80f4471450da274194ae687b.tar.xz |
Cleaner file management
-rw-r--r-- | src/protocolhandler.cpp | 8 | ||||
-rw-r--r-- | src/webpage.cpp | 28 |
2 files changed, 19 insertions, 17 deletions
diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index c66af403..1b60d0dc 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -104,17 +104,13 @@ bool ProtocolHandler::handle(const QNetworkRequest &request, QWebFrame *frame) if(url.protocol() == QLatin1String("file")) { QFileInfo fileInfo(url.path()); - if(fileInfo.isFile()) - { - new KRun(url, 0, 0, true); - } - else // dir + if(fileInfo.isDir()) { QString html = dirHandling(url); frame->setHtml(html); Application::instance()->mainWindow()->mainView()->urlBar()->setUrl(url); + return true; } - return true; } return false; diff --git a/src/webpage.cpp b/src/webpage.cpp index 1bc8c1c1..00f71805 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -134,27 +134,33 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) { if (reply->error() == QNetworkReply::NoError) { - const KUrl url(reply->request().url()); + const KUrl url( reply->url() ); QString mimeType = reply->header(QNetworkRequest::ContentTypeHeader).toString(); KService::Ptr offer = KMimeTypeTrader::self()->preferredService(mimeType); + bool isLocal = url.isLocalFile(); + if( offer.isNull() ) // no service can handle this. We can just download it.. { - downloadRequest(reply->request()); + isLocal ? KMessageBox::sorry(view(), i18n("No service can handle this :(") ) : downloadRequest(reply->request()); return; } - KParts::BrowserOpenOrSaveQuestion dlg(Application::instance()->mainWindow(), url, mimeType); - switch ( dlg.askEmbedOrSave() ) + if(!isLocal) { - case KParts::BrowserOpenOrSaveQuestion::Save: - downloadRequested(reply->request()); - return; - case KParts::BrowserOpenOrSaveQuestion::Cancel: - return; - default: // non extant case - break; + + KParts::BrowserOpenOrSaveQuestion dlg(Application::instance()->mainWindow(), url, mimeType); + switch ( dlg.askEmbedOrSave() ) + { + case KParts::BrowserOpenOrSaveQuestion::Save: + downloadRequested(reply->request()); + return; + case KParts::BrowserOpenOrSaveQuestion::Cancel: + return; + default: // non extant case + break; + } } // case KParts::BrowserRun::Embed KUrl::List list; |