Don't paint QPixmap-s in theme preview icons.

This commit is contained in:
John Preston 2018-01-02 22:23:54 +03:00
parent 0ef3e19bc2
commit 6b25160e3f
1 changed files with 41 additions and 16 deletions

View File

@ -184,28 +184,53 @@ void MonoIcon::fill(QPainter &p, const QRect &rect, QColor colorOverride) const
} }
} }
void MonoIcon::paint(QPainter &p, const QPoint &pos, int outerw, const style::palette &paletteOverride) const { void MonoIcon::paint(
int w = width(), h = height(); QPainter &p,
QPoint fullOffset = pos + offset(); const QPoint &pos,
int partPosX = rtl() ? (outerw - fullOffset.x() - w) : fullOffset.x(); int outerw,
int partPosY = fullOffset.y(); const style::palette &paletteOverride) const {
auto size = readGeneratedSize(_mask, cScale());
auto maskImage = QImage();
if (size.isEmpty()) {
maskImage = createIconMask(_mask, cScale());
size = maskImage.size() / cIntRetinaFactor();
}
ensureLoaded(); const auto w = size.width();
if (_pixmap.isNull()) { const auto h = size.height();
p.fillRect(partPosX, partPosY, w, h, _color[paletteOverride]); const auto fullOffset = pos + offset();
const auto partPosX = rtl() ? (outerw - fullOffset.x() - w) : fullOffset.x();
const auto partPosY = fullOffset.y();
if (!maskImage.isNull()) {
auto colorizedImage = QImage(
maskImage.size(),
QImage::Format_ARGB32_Premultiplied);
colorizeImage(maskImage, _color[paletteOverride]->c, &colorizedImage);
p.drawImage(partPosX, partPosY, colorizedImage);
} else { } else {
ensureColorizedImage(_color[paletteOverride]->c); p.fillRect(partPosX, partPosY, w, h, _color[paletteOverride]);
p.drawImage(partPosX, partPosY, _colorizedImage);
} }
} }
void MonoIcon::fill(QPainter &p, const QRect &rect, const style::palette &paletteOverride) const { void MonoIcon::fill(
ensureLoaded(); QPainter &p,
if (_pixmap.isNull()) { const QRect &rect,
p.fillRect(rect, _color[paletteOverride]); const style::palette &paletteOverride) const {
auto size = readGeneratedSize(_mask, cScale());
auto maskImage = QImage();
if (size.isEmpty()) {
maskImage = createIconMask(_mask, cScale());
size = maskImage.size() / cIntRetinaFactor();
}
if (!maskImage.isNull()) {
auto colorizedImage = QImage(
maskImage.size(),
QImage::Format_ARGB32_Premultiplied);
colorizeImage(maskImage, _color[paletteOverride]->c, &colorizedImage);
p.drawImage(rect, colorizedImage, colorizedImage.rect());
} else { } else {
ensureColorizedImage(_color[paletteOverride]->c); p.fillRect(rect, _color[paletteOverride]);
p.drawImage(rect, _colorizedImage, _colorizedImage.rect());
} }
} }