Merge branch 'master' into plasma/mart/PageRow

This commit is contained in:
Marco Martin 2012-08-17 18:20:08 +02:00
commit 724d96a81d
2 changed files with 11 additions and 9 deletions

View File

@ -105,6 +105,7 @@ void QImageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
painter->setRenderHint(QPainter::Antialiasing, m_smooth);
painter->setRenderHint(QPainter::SmoothPixmapTransform, m_smooth);
QRect sourceRect = m_image.rect();
QRect destRect;
switch (m_fillMode) {
case PreserveAspectFit: {
@ -112,13 +113,13 @@ void QImageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
scaled.scale(boundingRect().size().toSize(), Qt::KeepAspectRatio);
destRect = QRect(QPoint(0, 0), scaled);
destRect.moveCenter(boundingRect().center().toPoint());
break;
}
case PreserveAspectCrop: {
painter->setClipRect(boundingRect(), Qt::IntersectClip);
QSize scaled = m_image.size();
scaled.scale(boundingRect().size().toSize(), Qt::KeepAspectRatioByExpanding);
destRect = QRect(QPoint(0, 0), scaled);
destRect = boundingRect().toRect();
sourceRect = destRect;
sourceRect.moveCenter(m_image.rect().center());
break;
}
case TileVertically: {
@ -142,7 +143,7 @@ void QImageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
if (m_fillMode >= Tile) {
painter->drawTiledPixmap(destRect, QPixmap::fromImage(m_image));
} else {
painter->drawImage(destRect, m_image, m_image.rect());
painter->drawImage(destRect, m_image, sourceRect);
}
painter->restore();

View File

@ -105,6 +105,7 @@ void QPixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
painter->setRenderHint(QPainter::Antialiasing, m_smooth);
painter->setRenderHint(QPainter::SmoothPixmapTransform, m_smooth);
QRect sourceRect = m_pixmap.rect();
QRect destRect;
switch (m_fillMode) {
case PreserveAspectFit: {
@ -112,13 +113,13 @@ void QPixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
scaled.scale(boundingRect().size().toSize(), Qt::KeepAspectRatio);
destRect = QRect(QPoint(0, 0), scaled);
destRect.moveCenter(boundingRect().center().toPoint());
break;
}
case PreserveAspectCrop: {
painter->setClipRect(boundingRect(), Qt::IntersectClip);
QSize scaled = m_pixmap.size();
scaled.scale(boundingRect().size().toSize(), Qt::KeepAspectRatioByExpanding);
destRect = QRect(QPoint(0, 0), scaled);
destRect = boundingRect().toRect();
sourceRect = destRect;
sourceRect.moveCenter(m_pixmap.rect().center());
break;
}
case TileVertically: {