diff options
Diffstat (limited to 'src/webpage.cpp')
-rw-r--r-- | src/webpage.cpp | 99 |
1 files changed, 82 insertions, 17 deletions
diff --git a/src/webpage.cpp b/src/webpage.cpp index a75272cd..1e25ce8d 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; } } @@ -551,3 +564,55 @@ void WebPage::showSSLInfo() ); } } + + + + +void WebPage::updateImage(bool ok) +{ + if(!ok) + kDebug() << "OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO"; + else + kDebug() << "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY"; + +/* int previewIndex = 1; + KUrl url; + QString snapTitle = QString("ciao");*/ +// // Update page, but only if open +// if(m_root.document().findAll("#rekonq-newtabpage").count() == 0) +// return; +// if(m_root.findAll(".favorites").count() == 0 || m_root.findAll(".closedTabs").count() == 0) +// return; +// +// QStringList urls = ReKonfig::previewUrls(); +// +// for(int i = 0; i < urls.count(); i++) +// { +// QString title = urls.at(i); +// KUrl url( title ); +// +// +// if( WebSnap::existsImage(url) ) +// { +// QStringList names = ReKonfig::previewNames(); +// names.replace(i, title); +// ReKonfig::setPreviewNames(names); +// ReKonfig::self()->writeConfig(); +// +// QWebElement prev = m_root.findFirst("#preview" + QVariant(i).toString()); +// if(KUrl(prev.findFirst("a").attribute("href")) == url ) +// { +// QWebElement newPrev = validPreview(i, url, title); +// +// if(m_root.findAll(".closedTabs").count() != 0) +// hideControls(newPrev); +// +// prev.replace(newPrev); +// } +// break; +// } +// } + + NewTabPage p( mainFrame() ); + p.snapFinished(); +} |