Bug 317495

Summary: Show the blue pawn or avatar from KTp::Contact in query results
Product: telepathy Reporter: Daniel Vrátil <dvratil>
Component: contact-runnerAssignee: Daniel Vrátil <dvratil>
Status: RESOLVED FIXED    
Severity: wishlist CC: kde
Priority: NOR Keywords: junior-jobs
Version: git-latest   
Target Milestone: 0.7-beta   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 0.7.0

Description Daniel Vrátil 2013-03-28 15:35:26 UTC
- use the new method in KTp::Contact to retrieve contact avatar
 - when no avatar is available, show the blue pawn instead of presence icon
Comment 1 David Edmundson 2013-03-31 19:05:15 UTC
Marking as confirmed and as a junior-job.

Blue pawn image loading is already done inside KTp::Contact::avatarPixmap() anyway.

We need to replace all the match.setIcon() code in ContactRunner::matchContacts with something that sets the icon to contact->avatarPixmap
Comment 2 David Edmundson 2013-06-18 17:23:51 UTC
Turns out this isn't trivial to use avatarPixmap();

You will get an assert "QPixmap: It is not safe to use pixmaps outside the GUI thread"
Comment 3 Daniel Vrátil 2013-09-17 17:23:05 UTC
For the record: the warning is not an assert (won't crash), just a qWarning(), because using some methods (like QPixmap::grabWidget()) will crash when used outside GUI thread. Simple painting/copying pixmaps should be safe.

We could try adding QApplication::setAttribute(Qt::AA_X11InitThreads) to KRunner's main(), that should silence the warning.
Comment 4 Daniel Vrátil 2013-09-17 17:38:27 UTC
Update: we /must/ add the attribute to KRunner, otherwise the pixmaps are blank :(
Comment 5 David Edmundson 2013-09-17 17:39:12 UTC
Can we turn it off inside our block of code, and re-enable it when it leaves?
Comment 6 Daniel Vrátil 2013-09-17 18:28:05 UTC
Unfortunately not: 

Qt::AA_X11InitThreads:	Calls XInitThreads() as part of the QApplication construction in order to make Xlib calls thread-safe. This attribute must be set before QApplication is constructed. [0]

[0] http://qt-project.org/doc/qt-4.8/qt.html#ApplicationAttribute-enum
Comment 7 David Edmundson 2013-09-18 00:38:31 UTC
KTp rules have been we run on KDE Workspaces now and now-1. 

So we can't patch KDE workspaces now.  For Qt5 this problem doesn't exist as QPixmaps aren't X11 Pixmaps underneath so can be used in any thread.

Slightly more boring patch uploaded to RB.
Comment 8 David Edmundson 2013-09-18 09:32:40 UTC
Git commit d259b4c143e8bdf5e17194e18f60622714ad7e39 by David Edmundson.
Committed on 18/09/2013 at 01:36.
Pushed by davidedmundson into branch 'master'.

Show blue pawn icon if no avatar is available

This makes everything consistent

REVIEW: 112788
FIXED-IN: 0.7.0

M  +1    -1    src/contactrunner.cpp

http://commits.kde.org/ktp-contact-runner/d259b4c143e8bdf5e17194e18f60622714ad7e39