summaryrefslogtreecommitdiffstats
path: root/gui/widgets/IconLabel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gui/widgets/IconLabel.cpp')
-rw-r--r--gui/widgets/IconLabel.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/gui/widgets/IconLabel.cpp b/gui/widgets/IconLabel.cpp
new file mode 100644
index 00000000..1bfe8dc9
--- /dev/null
+++ b/gui/widgets/IconLabel.cpp
@@ -0,0 +1,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());
+}