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

* Always set the correct foreground / background colors for QueryLabel.

This commit is contained in:
Christian Muehlhaeuser 2013-01-20 06:21:59 +01:00
parent 2f9b6077ac
commit bce56f280e
2 changed files with 9 additions and 37 deletions

View File

@ -90,7 +90,6 @@ QueryLabel::init()
setContentsMargins( 0, 0, 0, 0 );
setMouseTracking( true );
m_useCustomPen = false;
m_align = Qt::AlignLeft | Qt::AlignVCenter;
m_mode = Qt::ElideMiddle;
@ -284,21 +283,6 @@ QueryLabel::setAlignment( Qt::Alignment alignment )
}
void
QueryLabel::setTextPen( const QPen & pen )
{
m_useCustomPen = true;
m_textPen = pen;
}
QPen
QueryLabel::textPen() const
{
return m_textPen;
}
Qt::TextElideMode
QueryLabel::elideMode() const
{
@ -414,19 +398,15 @@ QueryLabel::paintEvent( QPaintEvent* event )
int albumX = m_type & Album ? fm.width( album()->name() ) : 0;
int trackX = m_type & Track ? fm.width( track() ) : 0;
if ( m_useCustomPen )
p.setPen( m_textPen );
if ( m_type & Artist )
{
p.setBrush( palette().window() );
if ( !m_useCustomPen )
p.setPen( palette().color( foregroundRole() ) );
p.setPen( palette().color( foregroundRole() ) );
if ( m_hoverType == Artist )
{
p.setPen( palette().highlightedText().color() );
p.setBrush( palette().highlight() );
p.setBrush( TomahawkUtils::Colors::SELECTION_BACKGROUND );
p.setPen( TomahawkUtils::Colors::SELECTION_FOREGROUND );
}
p.drawText( r, m_align, artist()->name() );
@ -435,8 +415,7 @@ QueryLabel::paintEvent( QPaintEvent* event )
if ( m_type & Album && !album()->name().isEmpty() )
{
p.setBrush( palette().window() );
if ( !m_useCustomPen )
p.setPen( palette().color( foregroundRole() ) );
p.setPen( palette().color( foregroundRole() ) );
if ( m_type & Artist )
{
@ -445,8 +424,8 @@ QueryLabel::paintEvent( QPaintEvent* event )
}
if ( m_hoverType == Album )
{
p.setPen( palette().highlightedText().color() );
p.setBrush( palette().highlight() );
p.setBrush( TomahawkUtils::Colors::SELECTION_BACKGROUND );
p.setPen( TomahawkUtils::Colors::SELECTION_FOREGROUND );
}
p.drawText( r, m_align, album()->name() );
@ -455,8 +434,7 @@ QueryLabel::paintEvent( QPaintEvent* event )
if ( m_type & Track )
{
p.setBrush( palette().window() );
if ( !m_useCustomPen )
p.setPen( palette().color( foregroundRole() ) );
p.setPen( palette().color( foregroundRole() ) );
if ( m_type & Artist || ( m_type & Album && !album()->name().isEmpty() ) )
{
@ -465,8 +443,8 @@ QueryLabel::paintEvent( QPaintEvent* event )
}
if ( m_hoverType == Track )
{
p.setPen( palette().highlightedText().color() );
p.setBrush( palette().highlight() );
p.setBrush( TomahawkUtils::Colors::SELECTION_BACKGROUND );
p.setPen( TomahawkUtils::Colors::SELECTION_FOREGROUND );
}
p.drawText( r, m_align, track() );

View File

@ -74,9 +74,6 @@ public:
Qt::TextElideMode elideMode() const;
void setElideMode( Qt::TextElideMode mode );
void setTextPen( const QPen& );
QPen textPen() const;
void setExtraContentsMargins( int left, int top, int right, int bottom );
void setJumpLinkVisible( bool visible );
@ -136,9 +133,6 @@ private:
Qt::Alignment m_align;
Qt::TextElideMode m_mode;
bool m_useCustomPen;
QPen m_textPen;
DisplayType m_hoverType;
QRect m_hoverArea;
QPoint m_dragPos;