1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-04-21 00:12:06 +02:00

* Hopefully improved sidebar delegate.

This commit is contained in:
Christian Muehlhaeuser 2013-05-14 11:50:09 +02:00
parent 85236c5c62
commit 5ddd730c4c

View File

@ -224,9 +224,12 @@ SourceDelegate::paintCollection( QPainter* painter, const QStyleOptionViewItem&
painter->drawPixmap( iconRect, avatar );
if ( ( option.state & QStyle::State_Selected ) == QStyle::State_Selected )
QColor descColor = option.palette.color( QPalette::Text ).lighter( 180 );
if ( type == SourcesModel::ScriptCollection && //you cannot select a non-script collection anyway
option.state.testFlag( QStyle::State_Selected ) )
{
painter->setPen( option.palette.color( QPalette::HighlightedText ) );
descColor = option.palette.color( QPalette::HighlightedText );
}
QRect textRect = option.rect.adjusted( iconRect.width() + 8, 6, -figWidth - ( figWidth ? 28 : 0 ), 0 );
@ -237,13 +240,6 @@ SourceDelegate::paintCollection( QPainter* painter, const QStyleOptionViewItem&
painter->drawText( textRect, text, to );
}
QColor descColor = option.palette.color( QPalette::Text ).lighter( 180 );
if ( type == SourcesModel::ScriptCollection && //you cannot select a non-script collection anyway
option.state.testFlag( QStyle::State_Selected ) )
{
descColor = option.palette.color( QPalette::HighlightedText );
}
painter->setFont( normal );
textRect = option.rect.adjusted( iconRect.width() + 8, option.rect.height() / 2, -figWidth - ( figWidth ? 24 : 0 ), -6 );
@ -446,7 +442,7 @@ SourceDelegate::paintGroup( QPainter* painter, const QStyleOptionViewItem& optio
void
SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
{
QStyleOptionViewItem o = option;
QStyleOptionViewItemV4 o = option;
QStyleOptionViewItemV4 o3 = option;
painter->save();
@ -462,7 +458,6 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
if ( ( option.state & QStyle::State_MouseOver ) == QStyle::State_MouseOver )
{
o.state |= QStyle::State_MouseOver;
o3.state |= QStyle::State_MouseOver;
}
if ( ( option.state & QStyle::State_Open ) == QStyle::State_Open )
@ -476,19 +471,16 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
{
if ( type == SourcesModel::ScriptCollection )
o.state |= QStyle::State_Selected;
o3.state |= QStyle::State_Selected;
}
else
{
o3.state &= ~QStyle::State_Selected;
}
o.palette.setColor( QPalette::Text, o.palette.color( QPalette::HighlightedText ) );
o3.palette.setColor( QPalette::Text, o.palette.color( QPalette::HighlightedText ) );
}
}
initStyleOption( &o3, index );
o3.icon = QIcon();
o3.text.clear();
// shrink the indentations
{
int indentMult = 0;