summaryrefslogtreecommitdiffstats
path: root/gui/widgets/IconLabel.cpp
blob: 1bfe8dc91e9988bcc8b32acd8d5334c5a61f758d (plain)
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
#include "IconLabel.h"

#include <QStyle>
#include <QStyleOption>
#include <QLayout>
#include <QPainter>
#include <QRect>

IconLabel::IconLabel(QWidget *parent, QIcon icon, QSize size)
	: QWidget(parent), m_icon(icon), m_size(size)
{
	setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
}

QSize IconLabel::sizeHint() const
{
	return m_size;
}

void IconLabel::setIcon(QIcon icon)
{
	m_icon = icon;
	update();
}

void IconLabel::paintEvent(QPaintEvent *)
{
	QPainter p(this);
	m_icon.paint(&p, contentsRect());
}