image viewers: a different approach

David Faure faure at kde.org
Mon Oct 31 10:55:26 GMT 2005


On Sunday 30 October 2005 11:37, Ingo Klöcker wrote:
> On Sunday 30 October 2005 10:32, Michael Olbrich wrote:
> > On Sat, Oct 29, 2005 at 11:31:41PM +0200, Ingo Klöcker wrote:
> > > On Sunday 30 October 2005 00:00, Benjamin Meyer wrote:
> > > > You make no sense.  You are embedding khtmlpart so embedding *is*
> > > > done.  In essence khtmlpart is your image viewer.
> > >
> > > It might not make sense to you because I didn't explain it good
> > > enough. Anyway, the current situation is like this:
> > > - For viewing messages we use KHTMLPart. If attached images are
> > > shown inline then they are obviously displayed by the KHTMLPart.
> > > This won't change.
> > > - For viewing single attached images (e.g. via context menu->View)
> > > we currently open a simple window with a KHTMLPart which displays a
> > > trivial HTML page with a single <img> tag.
> > >
> > > I don't like the latter (because the user can't even rotate the
> > > image) and therefore want to use an external image viewer in KDE 4.
> >
> > Why not start an image viewer kpart like you start KHTMLPart now?
> 
> Because it needs additional glue which means additional code that needs 
> to be maintained. Moreover, this additional code would have to be 
> duplicated in every application that wants to use the image viewer 
> kpart. OTOH, if there would be a static convenience method in kdelibs 
> so that we could show an image in a separate window with a simple
>   KImagePart::showImage( url );
> then we'll make use of this.

Actually there is such a method already. OK, it takes 5 lines instead of 1,
but it's really easy (and documented in componentfactory.h)

     QString mimetype = KMimeType::findByURL( url )->name();
     KParts::ReadOnlyPart* part = KParts::ComponentFactory::createPartInstanceFromQuery<KParts::ReadOnlyPart>( mimetype, QString::null, parentWidget, 0, parentObject, 0 );
     if ( part ) {
              part->openURL( url );
              part->widget()->show();
    }
(with 0 as parentWidget to get a toplevel window)

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).





More information about the kde-core-devel mailing list