On Fri, Mar 1, 2013 at 1:34 PM, Alin M Elena <span dir="ltr"><<a href="mailto:alinm.elena@gmail.com" target="_blank">alinm.elena@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im">> It looks like the right place to me, but I don't remember a<br>
> {Tp/KTp}::Contact::avatar() method to reimplement, I think that we have<br>
> just a "QString Tp::Contact::avatarToken()" that returns just a string.<br>
> We could add a KTp::contact::avatar() that does the magic though, but<br>
> I'm not sure if we want it grayed wherever it is used, so I'd suggest to<br>
> add a "bool KTp::Contact::avatar(grayIfUnavailable = false)".<br>
</div>there is no avatar() method so I need to add it... and shall return a<br>
QPixmap...<br>
<br>
the issue I see is that<br>
<br>
this is a snap of code from the tooltip (changed a little bit by me but keeps<br>
the spirit)<br>
<br>
    QString avatar = index.data(KTp::ContactAvatarPathRole).toString();<br>
    if (avatar.isEmpty()) {<br>
        QPixmap avatarPixmap(KIconLoader::global()->loadIcon("im-user",<br>
KIconLoader::NoGroup, 96));<br>
        if<br>
(index.data(KTp::ContactPresenceTypeRole)==Tp::ConnectionPresenceTypeOffline) {<br>
            avatarToGray(avatarPixmap);<br>
        }<br>
        ui->avatarLabel->setPixmap(avatarPixmap);<br>
    } else {<br>
        QPixmap avatarPixmap(avatar);<br>
        if<br>
(index.data(KTp::ContactPresenceTypeRole)==Tp::ConnectionPresenceTypeOffline) {<br>
             avatarToGray(avatarPixmap);<br>
        }<br>
        ui->avatarLabel->setPixmap(avatarPixmap.scaled(ui->avatarLabel-<br>
>size(), Qt::KeepAspectRatio));<br>
    }<br></blockquote><div><br></div><div>If you're loading the icon using KIconLoader (the pawn), you can use just KIconLoader::global()->loadIcon("im-user",</div>KIconLoader::NoGroup, 96, KIconLoader::DisabledState) and don't have to go through your method.<div>

 </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
so my idea is that what my method shall do..<br>
is to return the proper Qpixmap (that is a proper image or the pawn) and<br>
grayed if the contact is offline...<br>
of course that will imply  that in contact list and everywhere we use<br>
complicated code to set the avatar we can simply call the avatar method.<br>
<br>
     ui->avatarLabel->setPixmap(avatarPixmap.scaled(ui->avatarLabel->size(),<br>
Qt::KeepAspectRatio));<br>
<br>
Do we agree on this?<br></blockquote><div><br></div><div>I'm happy to have a method in KTp::Contact returning the pixmap. But that also requires adding a role to the models and changing all the code to either use the new role or the avatar() method.</div>

<div><br></div></div><div>Cheers</div>-- <br><div><span style="color:rgb(102,102,102)">Martin Klapetek | KDE Developer</span></div>