Debian Codegraph @

tests/manual/chartdesigner/objectinspectorwidget.cpp

raw
1 // Copyright (C) 2016 The Qt Company Ltd.
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4 #include "objectinspectorwidget.h"
5 #include <QtGui/QIcon>
6 #include <QtGui/QPainter>
7 #include <QtGui/QPixmapCache>
8
9 InspectorWidget::InspectorWidget()
10 {
11
12 }
13
14 InspectorWidget::~InspectorWidget()
15 {
16
17 }
18
19 QIcon InspectorWidget::getColorIcon(const QColor& color,const QSize &size) const
20 {
21
22 QString key = QString("COLOR_ICON=%1:%2x%3").arg(color.name()).arg(size.width()).arg(size.height());
23
24 QPixmap pixmap(size);
25
26 if (!QPixmapCache::find(key, &pixmap)) {
27 pixmap.fill(Qt::white);
28 QPainter painter(&pixmap);
29 painter.fillRect(2, 2, 46, 46, color);
30 QPixmapCache::insert(key, pixmap);
31 }
32
33 return QIcon(pixmap);
34 }