Skip to content

Commit

Permalink
* Always set the correct foreground / background colors for QueryLabel.
Browse files Browse the repository at this point in the history
  • Loading branch information
muesli committed Jan 20, 2013
1 parent 2f9b607 commit bce56f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 37 deletions.
40 changes: 9 additions & 31 deletions src/libtomahawk/widgets/QueryLabel.cpp
Expand Up @@ -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;

Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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() );
Expand All @@ -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 )
{
Expand All @@ -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() );
Expand All @@ -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() ) )
{
Expand All @@ -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() );
Expand Down
6 changes: 0 additions & 6 deletions src/libtomahawk/widgets/QueryLabel.h
Expand Up @@ -74,9 +74,6 @@ Q_OBJECT
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 );

Expand Down Expand Up @@ -136,9 +133,6 @@ private slots:
Qt::Alignment m_align;
Qt::TextElideMode m_mode;

bool m_useCustomPen;
QPen m_textPen;

DisplayType m_hoverType;
QRect m_hoverArea;
QPoint m_dragPos;
Expand Down

0 comments on commit bce56f2

Please sign in to comment.