- // is scaled to the available size.
- const bool scale = m_pixmap.width() > iconHeight || m_pixmap.height() > iconHeight ||
- (m_pixmap.width() < iconHeight && m_pixmap.height() < iconHeight);
- if (scale) {
- KPixmapModifier::scale(m_pixmap, QSize(iconHeight, iconHeight));
- }
- m_originalPixmapSize = m_pixmap.size();
-
- // To simplify the handling of scaling the original pixmap
- // will be embedded into a square pixmap.
- QPixmap squarePixmap(iconHeight, iconHeight);
- squarePixmap.fill(Qt::transparent);
-
- QPainter painter(&squarePixmap);
- const int x = (iconHeight - m_pixmap.width()) / 2; // Center horizontally
- int y = iconHeight - m_pixmap.height(); // Move to bottom
- if (!iconOnTop) {
- y /= 2.0; // Center vertically
- }
- painter.drawPixmap(x, y, m_pixmap);
-
- m_pixmap = squarePixmap;
- } else {
- m_originalPixmapSize = m_pixmap.size();
+ // is scaled to the maximum available size.
+ KPixmapModifier::scale(m_pixmap, QSize(maxIconWidth, maxIconHeight));