diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/webpage.cpp | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/src/webpage.cpp b/src/webpage.cpp index a75272cd..c3acc1ad 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -240,11 +240,11 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) const KUrl url( reply->url() ); QString mimeType = reply->header(QNetworkRequest::ContentTypeHeader).toString(); - KService::Ptr offer = KMimeTypeTrader::self()->preferredService(mimeType); + KService::Ptr appService = KMimeTypeTrader::self()->preferredService(mimeType); bool isLocal = url.isLocalFile(); - if( offer.isNull() ) // no service can handle this. We can just download it.. + if( appService.isNull() ) // no service can handle this. We can just download it.. { kDebug() << "no service can handle this. We can just download it.."; @@ -273,23 +273,36 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) break; } } + // case KParts::BrowserRun::Embed - QString html; - html += "<html>"; - html += "<head>"; - html += "<title>"; - html += url.pathOrUrl(); - html += "</title>"; - html += "<style type=\"text/css\">"; - html += "* { border: 0; padding: 0; margin: 0; }"; - html += "</style>"; - html += "</head>"; - html += "<body>"; - html += "<embed src=\"" + url.pathOrUrl() + "\" width=\"100%\" height=\"100%\" />"; - html += "</body>"; - html += "</html>"; - mainFrame()->setHtml(html, url); + KService::List partServices = KMimeTypeTrader::self()->query( mimeType, QL1S("KParts/ReadOnlyPart") ); + if(partServices.count() > 0) + { + // A part can handle this. Embed it! + QString html; + html += "<html>"; + html += "<head>"; + html += "<title>"; + html += url.pathOrUrl(); + html += "</title>"; + html += "<style type=\"text/css\">"; + html += "* { border: 0; padding: 0; margin: 0; }"; + html += "</style>"; + html += "</head>"; + html += "<body>"; + html += "<embed src=\"" + url.pathOrUrl() + "\" width=\"100%\" height=\"100%\" />"; + html += "</body>"; + html += "</html>"; + + mainFrame()->setHtml(html, url); + } + else + { + // No parts, just app services. Load it! + KRun::run(*appService, url, 0); + } + return; } } |