best place for a helper function

Alin M Elena alinm.elena at gmail.com
Fri Mar 1 12:34:30 UTC 2013


> It looks like the right place to me, but I don't remember a
> {Tp/KTp}::Contact::avatar() method to reimplement, I think that we have
> just a "QString Tp::Contact::avatarToken()" that returns just a string.
> We could add a KTp::contact::avatar() that does the magic though, but
> I'm not sure if we want it grayed wherever it is used, so I'd suggest to
> add a "bool KTp::Contact::avatar(grayIfUnavailable = false)".
there is no avatar() method so I need to add it... and shall return a 
QPixmap...

the issue I see is that 

this is a snap of code from the tooltip (changed a little bit by me but keeps 
the spirit)

    QString avatar = index.data(KTp::ContactAvatarPathRole).toString();
    if (avatar.isEmpty()) {
        QPixmap avatarPixmap(KIconLoader::global()->loadIcon("im-user", 
KIconLoader::NoGroup, 96));
        if 
(index.data(KTp::ContactPresenceTypeRole)==Tp::ConnectionPresenceTypeOffline) {
            avatarToGray(avatarPixmap);
        }
        ui->avatarLabel->setPixmap(avatarPixmap);
    } else {
        QPixmap avatarPixmap(avatar);
        if 
(index.data(KTp::ContactPresenceTypeRole)==Tp::ConnectionPresenceTypeOffline) {
             avatarToGray(avatarPixmap);
        }
        ui->avatarLabel->setPixmap(avatarPixmap.scaled(ui->avatarLabel-
>size(), Qt::KeepAspectRatio));
    }


so my idea is that what my method shall do.. 
is to return the proper Qpixmap (that is a proper image or the pawn) and 
grayed if the contact is offline... 
of course that will imply  that in contact list and everywhere we use 
complicated code to set the avatar we can simply call the avatar method.

     ui->avatarLabel->setPixmap(avatarPixmap.scaled(ui->avatarLabel->size(), 
Qt::KeepAspectRatio));

Do we agree on this?

regards,

Alin


-- 
Without Questions there are no Answers!
______________________________________________________________________
Alin Marin ELENA
Advanced Molecular Simulation Research Laboratory
School of Physics, University College Dublin
----
Ardionsamblú Móilíneach Saotharlann Taighde
Scoil na Fisice, An Coláiste Ollscoile, Baile Átha Cliath

-----------------------------------------------------------------------------------
http://alin.elenaworld.net
______________________________________________________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2033 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-telepathy/attachments/20130301/65cd3d6c/attachment.p7s>


More information about the KDE-Telepathy mailing list