mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-10 08:04:25 +02:00
* Fixed TWK-1058: GridItemDelegate's text-box might be too small in height.
This commit is contained in:
@@ -138,7 +138,7 @@ GridItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
qreal opacity = -1.;
|
qreal opacity = -1.;
|
||||||
if ( m_hoverFaders.contains( index ) )
|
if ( m_hoverFaders.contains( index ) )
|
||||||
{
|
{
|
||||||
const qreal pct = ( m_hoverFaders[ index ]->currentFrame() / 100. );
|
const qreal pct = ( m_hoverFaders[ index ]->currentFrame() / 100.0 );
|
||||||
opacity = 0.35 - pct * 0.35;
|
opacity = 0.35 - pct * 0.35;
|
||||||
}
|
}
|
||||||
else if ( m_hoverIndex == index )
|
else if ( m_hoverIndex == index )
|
||||||
@@ -146,7 +146,7 @@ GridItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
opacity = 0.35;
|
opacity = 0.35;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( opacity > -1. )
|
if ( opacity > -1.0 )
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
@@ -158,16 +158,6 @@ GridItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->save();
|
|
||||||
|
|
||||||
painter->setPen( Qt::black );
|
|
||||||
painter->setBrush( Qt::black );
|
|
||||||
painter->setOpacity( 0.5 );
|
|
||||||
painter->drawRoundedRect( r.adjusted( 4, +r.height() - 36, -4, -4 ), 3, 3 );
|
|
||||||
|
|
||||||
painter->restore();
|
|
||||||
|
|
||||||
painter->setPen( opt.palette.color( QPalette::HighlightedText ) );
|
|
||||||
QTextOption to;
|
QTextOption to;
|
||||||
to.setWrapMode( QTextOption::NoWrap );
|
to.setWrapMode( QTextOption::NoWrap );
|
||||||
|
|
||||||
@@ -178,18 +168,25 @@ GridItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
boldFont.setBold( true );
|
boldFont.setBold( true );
|
||||||
boldFont.setPointSize( TomahawkUtils::defaultFontSize() + 1 );
|
boldFont.setPointSize( TomahawkUtils::defaultFontSize() + 1 );
|
||||||
|
|
||||||
QRect textRect = option.rect.adjusted( 6, option.rect.height() - 36, -4, -6 );
|
int bottomHeight = QFontMetrics( font ).boundingRect( bottom ).height();
|
||||||
painter->setFont( font );
|
int topHeight = QFontMetrics( boldFont ).boundingRect( top ).height();
|
||||||
int bottomHeight = painter->fontMetrics().boundingRect( bottom ).height();
|
int frameHeight = bottomHeight + topHeight + 10;
|
||||||
painter->setFont( boldFont );
|
|
||||||
int topHeight = painter->fontMetrics().boundingRect( top ).height();
|
|
||||||
|
|
||||||
|
painter->save();
|
||||||
|
painter->setPen( Qt::black );
|
||||||
|
painter->setBrush( Qt::black );
|
||||||
|
painter->setOpacity( 0.5 );
|
||||||
|
painter->drawRoundedRect( r.adjusted( 4, r.height() - frameHeight, -4, -4 ), 3, 3 );
|
||||||
|
painter->restore();
|
||||||
|
|
||||||
|
painter->setPen( opt.palette.color( QPalette::HighlightedText ) );
|
||||||
|
|
||||||
|
QRect textRect = option.rect.adjusted( 6, option.rect.height() - frameHeight, -4, -6 );
|
||||||
bool oneLiner = false;
|
bool oneLiner = false;
|
||||||
if ( bottom.isEmpty() )
|
if ( bottom.isEmpty() )
|
||||||
oneLiner = true;
|
oneLiner = true;
|
||||||
else
|
|
||||||
oneLiner = ( textRect.height() < topHeight + bottomHeight );
|
|
||||||
|
|
||||||
|
painter->setFont( boldFont );
|
||||||
if ( oneLiner )
|
if ( oneLiner )
|
||||||
{
|
{
|
||||||
to.setAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
|
to.setAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
|
||||||
|
Reference in New Issue
Block a user