+ if (m_enlargeSmallPreviews) {
+ KPixmapModifier::applyFrame(scaledPixmap, m_iconSize);
+ } else {
+ // Assure that small previews don't get enlarged. Instead they
+ // should be shown centered within the frame.
+ const QSize contentSize = KPixmapModifier::sizeInsideFrame(m_iconSize);
+ const bool enlargingRequired = scaledPixmap.width() < contentSize.width() &&
+ scaledPixmap.height() < contentSize.height();
+ if (enlargingRequired) {
+ QSize frameSize = scaledPixmap.size();
+ frameSize.scale(m_iconSize, Qt::KeepAspectRatio);
+
+ QPixmap largeFrame(frameSize);
+ largeFrame.fill(Qt::transparent);
+
+ KPixmapModifier::applyFrame(largeFrame, frameSize);
+
+ QPainter painter(&largeFrame);
+ painter.drawPixmap((largeFrame.width() - scaledPixmap.width()) / 2,
+ (largeFrame.height() - scaledPixmap.height()) / 2,
+ scaledPixmap);
+ scaledPixmap = largeFrame;
+ } else {
+ // The image must be shrinked as it is too large to fit into
+ // the available icon size
+ KPixmapModifier::applyFrame(scaledPixmap, m_iconSize);
+ }
+ }