matrixion/include/ui/Avatar.h

48 lines
1.1 KiB
C
Raw 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);
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);
2018-01-12 11:21:53 +03:00
void setLetter(const QString &letter);
2017-09-10 12:59:21 +03:00
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_;
2018-01-12 11:21:53 +03:00
QString letter_;
2017-09-10 12:59:21 +03:00
QColor background_color_;
QColor text_color_;
QIcon icon_;
QImage image_;
QPixmap pixmap_;
int size_;
2017-04-06 02:06:42 +03:00
};