diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2010-04-21 02:01:27 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2010-04-21 02:01:27 +0200 |
commit | 45da2cb69c8164f65b4cb4c4f8dd20f83dee0209 (patch) | |
tree | 633a66188dae2cb4ec82916cb9eac8b85ff98573 /src/webpage.cpp | |
parent | Nebulon's patch. (diff) | |
download | rekonq-45da2cb69c8164f65b4cb4c4f8dd20f83dee0209.tar.xz |
Fix embed kpart bahevior. Try embedding just when there is a ReadOnlyPart
available.
Otherwise, try loading it.
Diffstat (limited to 'src/webpage.cpp')
-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; } } |