25 if (opt.icon.isNull()) {
28 QIcon::State state = opt.state & QStyle::State_On ? QIcon::On : QIcon::Off;
30 if (!(opt.state & QStyle::State_Enabled)) {
31 mode = QIcon::Disabled;
32 }
else if ((opt.state & QStyle::State_MouseOver) && (opt.state & QStyle::State_AutoRaise)) {
38#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
39 QPixmap pixmap = opt.icon.pixmap(q->window()->windowHandle(), realIconSize, mode, state);
41 QPixmap pixmap = opt.icon.pixmap(realIconSize, q->window()->devicePixelRatio(), mode, state);
44 res.fill(Qt::transparent);
45 QPainter painter(&res);
46 int xPixmap = (res.width() - pixmap.width()) / 2;
49 QRect rPixmap = QRect(xPixmap, yPixmap, pixmap.width(), pixmap.height());
50 painter.drawPixmap(rPixmap, pixmap);
51 QRect colorRect = rPixmap.adjusted(0, pixmap.height() + 1, 0,
c_colorHeight + 1);
53 painter.fillRect(colorRect,
m_color);
55 QPen pen(Qt::red, 1, Qt::SolidLine, Qt::RoundCap);
57 painter.setRenderHint(QPainter::SmoothPixmapTransform,
true);
58 painter.setRenderHint(QPainter::Antialiasing,
true);
59 int ss = colorRect.width() / 3;
60 painter.drawLine(QPoint(colorRect.x() + ss, colorRect.bottom()),
61 QPoint(colorRect.right() - ss, colorRect.top()));
62 pen.setColor(Qt::black);
64 painter.drawRect(colorRect);