Spectral/src/spectraluser.h

45 lines
920 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>
#include <QPointer>
2018-09-10 01:51:02 +00:00
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:
UserPaintable(User* parent) : Paintable(parent), m_user(parent) {}
2018-11-04 11:14:02 +00:00
QImage image(int dimension) override {
2018-11-18 06:29:09 +00:00
if (!m_user) return {};
2018-11-04 11:14:02 +00:00
return m_user->avatar(dimension);
}
QImage image(int width, int height) override {
2018-11-18 06:29:09 +00:00
if (!m_user) return {};
2018-11-04 11:14:02 +00:00
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), m_paintable(this) {}
Paintable* paintable() { return &m_paintable; }
2018-09-10 01:51:02 +00:00
private:
UserPaintable m_paintable;
2018-09-10 01:51:02 +00:00
};
#endif // SpectralUser_H