aboutsummaryrefslogtreecommitdiff
path: root/user.cpp
diff options
context:
space:
mode:
authorElvis Angelaccio <elvis.angelaccio@kde.org>2017-03-26 13:22:07 +0200
committerElvis Angelaccio <elvis.angelaccio@kde.org>2017-03-26 13:22:07 +0200
commit2f52210d3d97feaebfb654b2a621ceda2e59af08 (patch)
tree34e72a0572ce8f895783dd291b48419fc33e8579 /user.cpp
parent57980b04c1a9d8bde974683fbae892580aee7466 (diff)
downloadlibquotient-2f52210d3d97feaebfb654b2a621ceda2e59af08.tar.gz
libquotient-2f52210d3d97feaebfb654b2a621ceda2e59af08.zip
Provide a default avatar
If the user doesn't have a custom avatar set, show a default avatar instead of nothing. This fixes a misalignment in the tableview between users with and without a custom avatar. Since libqmatrixclient doesn't recognize yet if a user is online or offline, just use the `user-available` standard [1] icon for now. [1]: https://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.htmli
Diffstat (limited to 'user.cpp')
-rw-r--r--user.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/user.cpp b/user.cpp
index 7d5024e5..8f0968bb 100644
--- a/user.cpp
+++ b/user.cpp
@@ -25,6 +25,7 @@
#include <QtCore/QTimer>
#include <QtCore/QDebug>
+#include <QtGui/QIcon>
#include <algorithm>
using namespace QMatrixClient;
@@ -39,6 +40,7 @@ class User::Private
Connection* connection;
QPixmap avatar;
+ QIcon defaultIcon;
QSize requestedSize;
bool avatarValid;
bool avatarOngoingRequest;
@@ -55,6 +57,7 @@ User::User(QString userId, Connection* connection)
d->avatarValid = false;
d->avatarOngoingRequest = false;
d->q = this;
+ d->defaultIcon = QIcon::fromTheme(QStringLiteral("user-available"));
}
User::~User()
@@ -102,7 +105,13 @@ QPixmap User::croppedAvatar(int width, int height)
}
if( d->avatar.isNull() )
- return d->avatar;
+ {
+ if (d->defaultIcon.isNull())
+ return d->avatar;
+
+ d->avatar = d->defaultIcon.pixmap(size);
+ }
+
for (const QPixmap& p: d->scaledAvatars)
{
if (p.size() == size)