From 45da2cb69c8164f65b4cb4c4f8dd20f83dee0209 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 21 Apr 2010 02:01:27 +0200 Subject: Fix embed kpart bahevior. Try embedding just when there is a ReadOnlyPart available. Otherwise, try loading it. --- src/webpage.cpp | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) (limited to 'src/webpage.cpp') 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 += ""; - html += url.pathOrUrl(); - html += ""; - html += ""; - html += ""; - html += ""; - html += ""; - 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 += ""; + html += url.pathOrUrl(); + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + + mainFrame()->setHtml(html, url); + } + else + { + // No parts, just app services. Load it! + KRun::run(*appService, url, 0); + } + return; } } -- cgit v1.2.1