matrixion/include/ui/Avatar.h

49 lines
1.1 KiB
C
Raw Permalink Normal View History

#pragma once
2017-04-06 02:06:42 +03:00
#include <QIcon>
#include <QImage>
#include <QPixmap>
#include <QWidget>
#include "Theme.h"
class Avatar : public QWidget
{
2017-09-10 12:59:21 +03:00
Q_OBJECT
2017-04-06 02:06:42 +03:00
2017-09-10 12:59:21 +03:00
Q_PROPERTY(QColor textColor WRITE setTextColor READ textColor)
Q_PROPERTY(QColor backgroundColor WRITE setBackgroundColor READ backgroundColor)
2017-04-06 02:06:42 +03:00
public:
2017-09-10 12:59:21 +03:00
explicit Avatar(QWidget *parent = 0);
~Avatar();
2017-04-06 02:06:42 +03:00
2017-09-10 12:59:21 +03:00
void setBackgroundColor(const QColor &color);
void setIcon(const QIcon &icon);
void setImage(const QImage &image);
void setLetter(const QChar &letter);
void setSize(int size);
void setTextColor(const QColor &color);
2017-04-06 02:06:42 +03:00
2017-09-10 12:59:21 +03:00
QColor backgroundColor() const;
QColor textColor() const;
int size() const;
2017-04-06 02:06:42 +03:00
2017-09-10 12:59:21 +03:00
QSize sizeHint() const override;
2017-04-06 02:06:42 +03:00
protected:
2017-09-10 12:59:21 +03:00
void paintEvent(QPaintEvent *event) override;
2017-04-06 02:06:42 +03:00
private:
2017-09-10 12:59:21 +03:00
void init();
ui::AvatarType type_;
QChar letter_;
QColor background_color_;
QColor text_color_;
QIcon icon_;
QImage image_;
QPixmap pixmap_;
int size_;
2017-04-06 02:06:42 +03:00
};