-rw-r--r-- | bin/kdepim/WhatsNew.txt | 4 | ||||
-rw-r--r-- | kabc/addresseeview.cpp | 28 |
2 files changed, 31 insertions, 1 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt index d75ff7e..013c3f8 100644 --- a/bin/kdepim/WhatsNew.txt +++ b/bin/kdepim/WhatsNew.txt @@ -16,2 +16,6 @@ Fixed a problem with the default view and view selection at startup. Formatted name is now set on import, if formatted name is empty. +Fixed a problem of displaying images in the contact details view: +Now the wid/hei ratio is not changed. +I a picture is larger than 128 pixels in wid or hei it is downscaled to +max 128 pixels wid/hei. diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp index f3cfb23..05d604f 100644 --- a/kabc/addresseeview.cpp +++ b/kabc/addresseeview.cpp @@ -392,2 +392,3 @@ void AddresseeView::setAddressee( const KABC::Addressee& mAddressee ) KABC::Picture picture = mAddressee.photo(); + if (picture.undefined() ) picture = mAddressee.logo(); bool picAvailintern = false; @@ -402,5 +403,30 @@ void AddresseeView::setAddressee( const KABC::Addressee& mAddressee ) 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 { |