1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-09-09 21:50:58 +02: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 a6ffa5afee
commit 165e1cf8b5
2 changed files with 9 additions and 37 deletions

View File

@@ -88,7 +88,6 @@ QueryLabel::init()
setContentsMargins( 0, 0, 0, 0 );
setMouseTracking( true );
m_useCustomPen = false;
m_align = Qt::AlignLeft | Qt::AlignVCenter;
m_mode = Qt::ElideMiddle;
@@ -282,21 +281,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
{
@@ -412,19 +396,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() );
@@ -433,8 +413,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 )
{
@@ -443,8 +422,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() );
@@ -453,8 +432,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() ) )
{
@@ -463,8 +441,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;