summary refs log tree commit diff
path: root/src/ui/Avatar.h
blob: 41967af559b3752082524bee06a6650853a41a1f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once

#include <QIcon>
#include <QImage>
#include <QPixmap>
#include <QWidget>

#include "Theme.h"

class Avatar : public QWidget
{
        Q_OBJECT

        Q_PROPERTY(QColor textColor WRITE setTextColor READ textColor)
        Q_PROPERTY(QColor backgroundColor WRITE setBackgroundColor READ backgroundColor)

public:
        explicit Avatar(QWidget *parent = 0);

        void setBackgroundColor(const QColor &color);
        void setIcon(const QIcon &icon);
        void setImage(const QImage &image);
        void setLetter(const QString &letter);
        void setSize(int size);
        void setTextColor(const QColor &color);

        QColor backgroundColor() const;
        QColor textColor() const;
        int size() const;

        QSize sizeHint() const override;

protected:
        void paintEvent(QPaintEvent *event) override;

private:
        void init();

        ui::AvatarType type_;
        QString letter_;
        QColor background_color_;
        QColor text_color_;
        QIcon icon_;
        QImage image_;
        QPixmap pixmap_;
        int size_;
};