+ if (!item.overlays().isEmpty()) {
+ // Avoid scaling the images that are smaller than the preview size, to be consistent when there is no overlays
+ if (pixmap.height() < m_preview->height() && pixmap.width() < m_preview->width()) {
+ p = QPixmap(m_preview->size() * devicePixelRatioF());
+ p.fill(Qt::transparent);
+ p.setDevicePixelRatio(devicePixelRatioF());
+
+ QPainter painter(&p);
+ painter.drawPixmap(QPointF{m_preview->width() / 2.0 - pixmap.width() / pixmap.devicePixelRatioF() / 2,
+ m_preview->height() / 2.0 - pixmap.height() / pixmap.devicePixelRatioF() / 2}
+ .toPoint(),
+ pixmap);
+ }
+ p = KIconUtils::addOverlays(p, item.overlays()).pixmap(m_preview->size(), devicePixelRatioF());
+ p.setDevicePixelRatio(devicePixelRatioF());
+ }
+
+ if (m_isVideo) {
+ // adds a play arrow overlay
+
+ auto maxDim = qMax(p.width(), p.height());
+ auto arrowSize = qMax(PLAY_ARROW_SIZE, maxDim / 8);
+
+ // compute relative pixel positions
+ const int zeroX = static_cast<int>((p.width() / 2 - arrowSize / 2) / p.devicePixelRatio());
+ const int zeroY = static_cast<int>((p.height() / 2 - arrowSize / 2) / p.devicePixelRatio());
+
+ QPolygon arrow;
+ arrow << QPoint(zeroX, zeroY);
+ arrow << QPoint(zeroX, zeroY + arrowSize);
+ arrow << QPoint(zeroX + arrowSize, zeroY + arrowSize / 2);
+
+ QPainterPath path;
+ path.addPolygon(arrow);
+
+ QLinearGradient gradient(QPointF(zeroX, zeroY + arrowSize / 2), QPointF(zeroX + arrowSize, zeroY + arrowSize / 2));
+
+ QColor whiteColor = Qt::white;
+ QColor blackColor = Qt::black;
+ gradient.setColorAt(0, whiteColor);
+ gradient.setColorAt(1, blackColor);
+
+ QBrush brush(gradient);
+
+ QPainter painter(&p);
+
+ QPen pen(blackColor, PLAY_ARROW_BORDER_SIZE, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
+ painter.setPen(pen);
+
+ painter.setRenderHint(QPainter::Antialiasing);
+ painter.drawPolygon(arrow);
+ painter.fillPath(path, brush);
+ }
+