Spectral/src/spectraluser.h

43 lines
944 B
C
Raw Normal View History

#ifndef SpectralUser_H
#define SpectralUser_H
2018-09-10 01:51:02 +00:00
2018-11-04 11:14:02 +00:00
#include "paintable.h"
2018-09-10 01:51:02 +00:00
#include "room.h"
2018-11-02 11:05:15 +00:00
#include "user.h"
2018-09-10 01:51:02 +00:00
#include <QObject>
using namespace QMatrixClient;
2018-11-04 11:14:02 +00:00
class UserPaintable : public Paintable {
2018-09-10 01:51:02 +00:00
Q_OBJECT
public:
2018-11-04 11:14:02 +00:00
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;
};
2018-09-10 01:51:02 +00:00
2018-11-04 11:14:02 +00:00
class SpectralUser : public User {
Q_OBJECT
Q_PROPERTY(Paintable* paintable READ paintable CONSTANT)
public:
SpectralUser(QString userId, Connection* connection)
: User(userId, connection) {}
2018-09-10 01:51:02 +00:00
2018-11-04 11:14:02 +00:00
Paintable* paintable() { return new UserPaintable(this); }
2018-09-10 01:51:02 +00:00
};
#endif // SpectralUser_H