From 9de953866db87933c9773b98502f07ac408c8ef7 Mon Sep 17 00:00:00 2001 From: zautrix Date: Wed, 17 Aug 2005 23:32:26 +0000 Subject: fix picture kapi --- (limited to 'kabc/addresseeview.cpp') diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp index f3cfb23..05d604f 100644 --- a/kabc/addresseeview.cpp +++ b/kabc/addresseeview.cpp @@ -390,6 +390,7 @@ void AddresseeView::setAddressee( const KABC::Addressee& mAddressee ) mText = ""; QString picString = ""; KABC::Picture picture = mAddressee.photo(); + if (picture.undefined() ) picture = mAddressee.logo(); bool picAvailintern = false; bool picAvailUrl = false; if (! picture.undefined() ) { @@ -400,9 +401,34 @@ void AddresseeView::setAddressee( const KABC::Addressee& mAddressee ) picString = ""; if ( picAvailintern ) { QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() ); + int wid = picture.data().width(); + int hei = picture.data().height(); + if ( wid > 128 || hei > 128 ) { + if ( wid > hei ) { + hei = (hei*128)/wid; + wid = 128; + } else { + wid = (wid*128)/hei; + hei = 128; + } + } + picString = QString("").arg(wid).arg(hei); } else { if ( picAvailUrl ) { - QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() )); + QPixmap picPix( picture.url() ); + QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", picPix ); + int wid = picPix.width(); + int hei = picPix.height(); + if ( wid > 128 || hei > 128 ) { + if ( wid > hei ) { + hei = (hei*128)/wid; + wid = 128; + } else { + wid = (wid*128)/hei; + hei = 128; + } + } + picString = QString("").arg(wid).arg(hei); } else { if ( !mAddressee.custom( "KADDRESSBOOK", "X-Children" ).isEmpty() ) { static bool setDefaultImageChildren = false; -- cgit v0.9.0.2