Init rewritten avatar.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#ifndef SpectralUser_H
|
||||
#define SpectralUser_H
|
||||
|
||||
#include "paintable.h"
|
||||
#include "room.h"
|
||||
#include "user.h"
|
||||
|
||||
@@ -8,18 +9,34 @@
|
||||
|
||||
using namespace QMatrixClient;
|
||||
|
||||
class UserPaintable : public Paintable {
|
||||
Q_OBJECT
|
||||
public:
|
||||
UserPaintable(User* parent) : Paintable(parent), m_user(parent) {
|
||||
connect(m_user, &User::avatarChanged, [=] { emit paintableChanged(); });
|
||||
}
|
||||
|
||||
QImage image(int dimension) override {
|
||||
if (!m_user) return QImage();
|
||||
return m_user->avatar(dimension);
|
||||
}
|
||||
QImage image(int width, int height) override {
|
||||
if (!m_user) return QImage();
|
||||
return m_user->avatar(width, height);
|
||||
}
|
||||
|
||||
private:
|
||||
User* m_user;
|
||||
};
|
||||
|
||||
class SpectralUser : public User {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QImage avatar READ getAvatar NOTIFY inheritedAvatarChanged)
|
||||
Q_PROPERTY(Paintable* paintable READ paintable CONSTANT)
|
||||
public:
|
||||
SpectralUser(QString userId, Connection* connection);
|
||||
SpectralUser(QString userId, Connection* connection)
|
||||
: User(userId, connection) {}
|
||||
|
||||
QImage getAvatar() { return avatar(128); }
|
||||
|
||||
signals:
|
||||
void inheritedAvatarChanged(
|
||||
User* user,
|
||||
const Room* roomContext); // https://bugreports.qt.io/browse/QTBUG-7684
|
||||
Paintable* paintable() { return new UserPaintable(this); }
|
||||
};
|
||||
|
||||
#endif // SpectralUser_H
|
||||
|
||||
Reference in New Issue
Block a user