1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-23 17:29:42 +01:00

* Added squareCenterPixmap( QPixmap ) to TomahawkUtils.

This commit is contained in:
Christian Muehlhaeuser 2012-12-09 06:38:57 +01:00
parent a01233124b
commit 455e525b11
2 changed files with 24 additions and 4 deletions

View File

@ -913,6 +913,28 @@ addDropShadow( const QPixmap& source, const QSize& targetSize )
}
QPixmap
squareCenterPixmap( const QPixmap& sourceImage )
{
if ( sourceImage.width() != sourceImage.height() )
{
const int sqwidth = qMin( sourceImage.width(), sourceImage.height() );
const int delta = abs( sourceImage.width() - sourceImage.height() );
if ( sourceImage.width() > sourceImage.height() )
{
return sourceImage.copy( delta / 2, 0, sqwidth, sqwidth );
}
else
{
return sourceImage.copy( 0, delta / 2, sqwidth, sqwidth );
}
}
return sourceImage;
}
void
drawCompositedPopup( QWidget* widget,
const QPainterPath& outline,

View File

@ -63,17 +63,15 @@ namespace TomahawkUtils
DLLEXPORT int defaultFontHeight();
DLLEXPORT QSize defaultIconSize();
DLLEXPORT QPixmap defaultPixmap( ImageType type, ImageMode mode = TomahawkUtils::Original, const QSize& size = QSize( 0, 0 ) );
DLLEXPORT void prepareStyleOption( QStyleOptionViewItemV4* option, const QModelIndex& index, PlayableItem* item );
DLLEXPORT void drawRoundedButton( QPainter* painter, const QRect& btnRect, const QColor& color, const QColor &gradient1bottom = QColor(), const QColor& gradient2top = QColor(), const QColor& gradient2bottom = QColor() );
DLLEXPORT void styleScrollBar( QScrollBar* scrollBar );
DLLEXPORT QPixmap defaultPixmap( ImageType type, ImageMode mode = TomahawkUtils::Original, const QSize& size = QSize( 0, 0 ) );
DLLEXPORT QPixmap createTiledPixmap( int width, int height, const QImage& src );
DLLEXPORT QPixmap addDropShadow( const QPixmap& sourceImage, const QSize& targetSize );
DLLEXPORT QPixmap squareCenterPixmap( const QPixmap& sourceImage );
DLLEXPORT void drawCompositedPopup( QWidget* widget, const QPainterPath& outline, const QColor& lineColor, const QBrush& backgroundBrush, qreal opacity );