summaryrefslogtreecommitdiffabout
path: root/kabc/addresseeview.cpp
Side-by-side diff
Diffstat (limited to 'kabc/addresseeview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kabc/addresseeview.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp
index f3cfb23..05d604f 100644
--- a/kabc/addresseeview.cpp
+++ b/kabc/addresseeview.cpp
@@ -385,29 +385,55 @@ void AddresseeView::setAddressee( const KABC::Addressee& mAddressee )
if ( true /*!mAddressee.organization().isEmpty()*/ ) {
aOrga = "<tr>"
"<td align=\"left\">" + mAddressee.organization() + "</td>"
"</tr>";
}
mText = "";
QString picString = "";
KABC::Picture picture = mAddressee.photo();
+ if (picture.undefined() ) picture = mAddressee.logo();
bool picAvailintern = false;
bool picAvailUrl = false;
if (! picture.undefined() ) {
picAvailintern = (picture.isIntern() && !picture.data().isNull());
picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() );
}
if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) {
picString = "<img src=\"myimage\" width=\"50\" height=\"70\">";
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("<img src=\"myimage\" width=\"%1\" height=\"%2\">").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("<img src=\"myimage\" width=\"%1\" height=\"%2\">").arg(wid).arg(hei);
} else {
if ( !mAddressee.custom( "KADDRESSBOOK", "X-Children" ).isEmpty() ) {
static bool setDefaultImageChildren = false;
if ( !setDefaultImageChildren ) {
QMimeSourceFactory::defaultFactory()->setPixmap( "familyIcon", KGlobal::iconLoader()->loadIcon( "ic_kids", KIcon::Desktop, 128 ) );
setDefaultImageChildren = true;
}
picString = "<img src=\"familyIcon\" width=\"64\" height=\"64\">";