const QString mimeTypeGroup = mimeType.left(slashIndex);
if (mimeTypeGroup == QLatin1String("image")) {
if (m_enlargeSmallPreviews) {
- KPixmapModifier::applyFrame(scaledPixmap, m_iconSize * qApp->devicePixelRatio());
+ KPixmapModifier::applyFrame(scaledPixmap, m_iconSize * scaledPixmap.devicePixelRatio());
} else {
// Assure that small previews don't get enlarged. Instead they
// should be shown centered within the frame.
scaledPixmap.height() < contentSize.height();
if (enlargingRequired) {
QSize frameSize = scaledPixmap.size();
- frameSize.scale(m_iconSize * qApp->devicePixelRatio(), Qt::KeepAspectRatio);
+ frameSize.scale(m_iconSize * scaledPixmap.devicePixelRatio(), Qt::KeepAspectRatio);
QPixmap largeFrame(frameSize);
largeFrame.fill(Qt::transparent);
} else {
// The image must be shrinked as it is too large to fit into
// the available icon size
- KPixmapModifier::applyFrame(scaledPixmap, m_iconSize * qApp->devicePixelRatio());
+ KPixmapModifier::applyFrame(scaledPixmap, m_iconSize * scaledPixmap.devicePixelRatio());
}
}
} else {
- KPixmapModifier::scale(scaledPixmap, m_iconSize * qApp->devicePixelRatio());
+ KPixmapModifier::scale(scaledPixmap, m_iconSize * scaledPixmap.devicePixelRatio());
}
- scaledPixmap.setDevicePixelRatio(qApp->devicePixelRatio());
QHash<QByteArray, QVariant> data = rolesData(item);
void KPixmapModifier::applyFrame(QPixmap& icon, const QSize& scaledSize)
{
static TileSet tileSet;
+ qreal dpr = icon.devicePixelRatio();
// Resize the icon to the maximum size minus the space required for the frame
- const QSize size(scaledSize.width() - TileSet::LeftMargin - TileSet::RightMargin,
- scaledSize.height() - TileSet::TopMargin - TileSet::BottomMargin);
+ const QSize size(scaledSize.width() - (TileSet::LeftMargin + TileSet::RightMargin) * dpr,
+ scaledSize.height() - (TileSet::TopMargin + TileSet::BottomMargin) * dpr);
scale(icon, size);
- QPixmap framedIcon(icon.size().width() + TileSet::LeftMargin + TileSet::RightMargin,
- icon.size().height() + TileSet::TopMargin + TileSet::BottomMargin);
+ QPixmap framedIcon(icon.size().width() + (TileSet::LeftMargin + TileSet::RightMargin) * dpr,
+ icon.size().height() + (TileSet::TopMargin + TileSet::BottomMargin * dpr) );
+ framedIcon.setDevicePixelRatio(dpr);
framedIcon.fill(Qt::transparent);
QPainter painter;
class DOLPHIN_EXPORT KPixmapModifier
{
public:
+ /**
+ * Scale a pixmap to a given size.
+ * @arg scaledSize is assumed to be the scaled to the same device pixel ratio as the source pixmap
+ * @arg scaledSize is in device pixels
+ */
static void scale(QPixmap& pixmap, const QSize& scaledSize);
+
+ /**
+ * Resize and paint a frame round an icon
+ * @arg scaledSize is assumed to be the scaled to the same device pixel ratio as the source icon
+ */
static void applyFrame(QPixmap& icon, const QSize& scaledSize);
+
+ /**
+ * return and paint a frame round an icon
+ * @arg framesize is in device-independent pixels
+ * @return is in device-indepent pixels
+ */
+
static QSize sizeInsideFrame(const QSize& frameSize);
};