[Psi-devel] [LONG] Custom rostericons in tooltips or what am I doing wrong?

Michał Jazłowiecki michalj at poczta.neostrada.pl
Sun Dec 3 06:46:33 PST 2006


Hello,


As you may know (or simply notice), Psi uses the default roster iconset 
for displaying contact's current status in contact's tooltips. It would 
be more consistent to use the custom set roster iconset (the one 
selected for given contact).

In Psi-0.10 I was able to do so by modifying src/userlist.cpp file, 
UserListItem::makeBareTip(bool trim, bool doLinkify) const method. The 
required changes were rather small but efficient - simple replace (long 
single line comment scrubbed for sake of clarity):

QString imgTag = "icon name";
QString secstr;
if(isSecure(r.name()))
	secstr += QString(" <%1=\"psi/cryptoYes\">").arg(imgTag);
str += QString("<br><nobr>") + QString("<%1=\"%1\"> 
").arg(imgTag).arg(istr) + QString("<b>%1</b> 
").arg(expandEntities(name)) + QString("(%1)").arg(r.priority()) + 
secstr + "</nobr>";

with:

QString imgTag = "img src";
QString secstr;
if(isSecure(r.name()))
{
	const QString cryptoIconKey = "psi/cryptoYes";
	const Icon * cryptoIcon = IconsetFactory::iconPtr(cryptoIconKey);
	QMimeSourceFactory::defaultFactory()->setPixmap(cryptoIconKey, 
cryptoIcon->pixmap());
	secstr += QString(" <%1=\"%1\">").arg(imgTag).arg(cryptoIconKey);
}
QString statusIconKey = jid().full() + ":" + istr;
const Icon * statusIcon;
if (status == -1)
	statusIcon = IconsetFactory::iconPtr("status/noauth");
else
	statusIcon = is->statusPtr(jid(), status);
QMimeSourceFactory::defaultFactory()->setPixmap(statusIconKey, 
statusIcon->pixmap());
str += QString("<br><nobr>") + QString("<%1=\"%1\"> 
").arg(imgTag).arg(statusIconKey) + QString("<b>%1</b> 
").arg(expandEntities(name)) + QString("(%1)").arg(r.priority()) + 
secstr + "</nobr>";

The idea behind it was to create a hash code between pair (contact's 
JID, contact's status) and the icon (or its pixmap, doesn't matter).

What's the key of my post? I wanted to do the same in Psi-0.11, but 
failed. Of course, I had to replace QMimeSourceFactory with 
Q3MimeSourceFactory and do not change the imgTag value ("icon name" in 
Psi-0.11; otherwise no icon will be returned).

However, either no icon was returned (if imgTag was changed) or generic 
icon (image similar to "generic file" icon) was returned.


Am I doing something wrong in Psi-0.11 or maybe something in the core of 
Psi-0.11 had changed and the old method will not work?



Thanks in advance for any clues,

-- 
Michał Jazłowiecki (michalj)
Psi Forum & Wiki Moderator :: Psi-Daisy Author



More information about the psi-devel mailing list