aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2017-04-01 13:52:46 +0300
committerGitHub <noreply@github.com>2017-04-01 13:52:46 +0300
commitc5832458b129e5e23564b092df1f415d455582d7 (patch)
tree996a23afac49b805ee894de7a622968d574d65f8
parentf4fbf96e7ea5147ef2944784665671219692253d (diff)
parent2f52210d3d97feaebfb654b2a621ceda2e59af08 (diff)
downloadlibquotient-c5832458b129e5e23564b092df1f415d455582d7.tar.gz
libquotient-c5832458b129e5e23564b092df1f415d455582d7.zip
Merge pull request #57 from elvisangelaccio/default-avatar
Couldn't find anything cross-platform to track theme changes, so just merging this. Thanks!
-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)