mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
* Fancy avatars are now scaled ignoring the aspect ratio. This fixed some odd clipping issues.
This commit is contained in:
@@ -62,7 +62,8 @@ createDragPixmap( MediaType type, int itemCount )
|
||||
{
|
||||
xCount = 5;
|
||||
size = 16;
|
||||
} else if( itemCount > 9 )
|
||||
}
|
||||
else if( itemCount > 9 )
|
||||
{
|
||||
xCount = 4;
|
||||
size = 22;
|
||||
@@ -126,9 +127,29 @@ createDragPixmap( MediaType type, int itemCount )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
drawShadowText( QPainter* painter, const QRect& rect, const QString& text, const QTextOption& textOption )
|
||||
{
|
||||
painter->save();
|
||||
|
||||
painter->drawText( rect, text, textOption );
|
||||
|
||||
/* QFont font = painter->font();
|
||||
font.setPixelSize( font.pixelSize() + 2 );
|
||||
painter->setFont( font );
|
||||
|
||||
painter->setPen( Qt::black );
|
||||
painter->drawText( rect, text, textOption );*/
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
drawBackgroundAndNumbers( QPainter* painter, const QString& text, const QRect& figRectIn )
|
||||
{
|
||||
painter->save();
|
||||
|
||||
QRect figRect = figRectIn;
|
||||
if ( text.length() == 1 )
|
||||
figRect.adjust( -painter->fontMetrics().averageCharWidth(), 0, 0, 0 );
|
||||
@@ -155,15 +176,13 @@ drawBackgroundAndNumbers( QPainter* painter, const QString& text, const QRect& f
|
||||
ppath.arcTo( leftArcRect, 270, 180 );
|
||||
painter->drawPath( ppath );
|
||||
|
||||
painter->setPen( origpen );
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
figRect.adjust( -1, 0, 0, 0 );
|
||||
#endif
|
||||
|
||||
QTextOption to( Qt::AlignCenter );
|
||||
painter->setPen( origpen );
|
||||
painter->setPen( Qt::white );
|
||||
painter->drawText( figRect.adjusted( -5, 0, 6, 0 ), text, to );
|
||||
painter->drawText( figRect.adjusted( -5, 0, 6, 0 ), text, QTextOption( Qt::AlignCenter ) );
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
|
||||
@@ -277,7 +296,7 @@ QPixmap
|
||||
createAvatarFrame( const QPixmap &avatar )
|
||||
{
|
||||
QPixmap frame( ":/data/images/avatar_frame.png" );
|
||||
QPixmap scaledAvatar = avatar.scaled( frame.height() * 75 / 100, frame.width() * 75 / 100, Qt::KeepAspectRatio, Qt::SmoothTransformation );
|
||||
QPixmap scaledAvatar = avatar.scaled( frame.height() * 75 / 100, frame.width() * 75 / 100, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
|
||||
|
||||
QPainter painter( &frame );
|
||||
painter.drawPixmap( ( frame.height() - scaledAvatar.height() ) / 2, ( frame.width() - scaledAvatar.width() ) / 2, scaledAvatar );
|
||||
|
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <QSize>
|
||||
#include <QModelIndex>
|
||||
#include <QTextOption>
|
||||
|
||||
#include "TomahawkUtils.h"
|
||||
#include "DllMacro.h"
|
||||
@@ -47,7 +48,9 @@ namespace TomahawkUtils
|
||||
DLLEXPORT QColor alphaBlend( const QColor& colorFrom, const QColor& colorTo, float opacity );
|
||||
DLLEXPORT QPixmap createDragPixmap( MediaType type, int itemCount = 1 );
|
||||
|
||||
DLLEXPORT void drawShadowText( QPainter* p, const QRect& rect, const QString& text, const QTextOption& textOption );
|
||||
DLLEXPORT void drawBackgroundAndNumbers( QPainter* p, const QString& text, const QRect& rect );
|
||||
|
||||
DLLEXPORT void unmarginLayout( QLayout* layout );
|
||||
|
||||
DLLEXPORT int headerHeight();
|
||||
|
Reference in New Issue
Block a user