Author: coolo Date: Thu May 15 22:31:15 2008 New Revision: 47600 URL: http://svn.opensuse.org/viewcvs/yast?rev=47600&view=rev Log: scale the picture keeping the aspect ratio (bnc#390208) Modified: trunk/qt/src/YQTimezoneSelector.cc Modified: trunk/qt/src/YQTimezoneSelector.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/src/YQTimezoneSelector.cc?rev=47600&r1=47599&r2=47600&view=diff ============================================================================== --- trunk/qt/src/YQTimezoneSelector.cc (original) +++ trunk/qt/src/YQTimezoneSelector.cc Thu May 15 22:31:15 2008 @@ -1,4 +1,4 @@ -/*---------------------------------------------------------------------\ + /*---------------------------------------------------------------------\ | | | __ __ ____ _____ ____ | | \ \ / /_ _/ ___|_ _|___ \ | @@ -231,10 +231,10 @@ { if ( d->cachePix.isNull() ) { - QImage t = d->_pix.scaled( width(), height() ); + QImage t = d->_pix.scaled( width(), height(), Qt::KeepAspectRatio ); d->cachePix = QPixmap::fromImage( t ); } - p.drawPixmap( 0, 0, d->cachePix ); + p.drawPixmap( ( width() - d->cachePix.width() ) / 2, ( height() - d->cachePix.height() ) / 2, d->cachePix ); setCursor( QCursor( QPixmap( zoom_in ) ) ); } else { @@ -331,8 +331,8 @@ { if ( _zoom.isNull() ) { - return QPoint( (int) ( double( pos.x() ) * parent->width() / _pix.width() ), - (int) ( double( pos.y() ) * parent->height() / _pix.height() ) ); + return QPoint( (int) ( double( pos.x() ) * cachePix.width() / _pix.width() ) + ( parent->width() - cachePix.width() ) / 2, + (int) ( double( pos.y() ) * cachePix.height() / _pix.height() ) + ( parent->height() - cachePix.height() ) /2 ); } int left = qMin( qMax( _zoom.x() - parent->width() / 2, 0 ), _pix.width() - parent->width() ); int top = qMin( qMax( _zoom.y() - parent->height() / 2, 0 ), _pix.height() - parent->height() ); -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org