[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Providing a SourceFactory for KHTMLPart
From:       David Faure <faure () kde ! org>
Date:       2005-04-27 23:46:24
Message-ID: 200504280146.24798.faure () kde ! org
[Download RAW message or body]

On Tuesday 26 April 2005 11:42, tim wrote:
> Hi ppl,
> 
> I'm developing a Qt/KDE CHM files viewer, you can check it at 
> http://kchmviewer.sourceforge.net
> 
> Now I'm working on adding KDE integration (at this moment, I'm working on UI 
> and KHTML integration, no KParts yet). In Qt version I use QTextBrowser among 
> with QMimeSourceFactory. This allows me just to "tell" QTextBrowser - "open 
> the url ABCD", and then QTextBrowser asks mine QMimeSourceFactory about the 
> content of url  ABCD, and about any image it needs to get to show this page.
> 
> Unfortunately, I found no such functionality in KHTML. I can show the HTML 
> page itself (by using begin(), write() and end()), but I see no way to 
> provide KHTML with application-embedded source, which would provide KHTML 
> with needed data.
> 
> Is it ever possible?

You can use a URL like
  data:image/png;base64,<......>
so that the image data is provided "inline" in the HTML.

This is what kmail does, with code like this:

  QString FancyHeaderStyle::imgToDataUrl( const QImage &image, const char* fmt  )
  {
    QBuffer buffer;
    buffer.open( IO_WriteOnly );
    image.save( &buffer, fmt );
    return QString::fromLatin1("data:image/%1;base64,%2")
           .arg( fmt, KCodecs::base64Encode( buffer.buffer() ) );
  }


-- 
David Faure, faure@kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic