mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 06:07:37 +02:00
* Fixed unbalanced QPainter save / restore.
This commit is contained in:
@@ -29,9 +29,9 @@ SettingsListDelegate::SettingsListDelegate(QObject *parent) :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SettingsListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
void SettingsListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
|
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
QStyleOptionViewItemV4 opt = option;
|
QStyleOptionViewItemV4 opt = option;
|
||||||
@@ -42,7 +42,6 @@ void SettingsListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
|||||||
// On mac draw our own selection rect as we don't get one from osx (around the whole icon or around just text)
|
// On mac draw our own selection rect as we don't get one from osx (around the whole icon or around just text)
|
||||||
if ( opt.state & QStyle::State_Selected )
|
if ( opt.state & QStyle::State_Selected )
|
||||||
{
|
{
|
||||||
painter->save();
|
|
||||||
painter->setRenderHint( QPainter::Antialiasing );
|
painter->setRenderHint( QPainter::Antialiasing );
|
||||||
|
|
||||||
QPainterPath p;
|
QPainterPath p;
|
||||||
@@ -53,8 +52,6 @@ void SettingsListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
|||||||
painter->setPen( border );
|
painter->setPen( border );
|
||||||
painter->drawPath( p );
|
painter->drawPath( p );
|
||||||
painter->fillPath( p, fill );
|
painter->fillPath( p, fill );
|
||||||
|
|
||||||
painter->restore();
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if ( ( option.state & QStyle::State_Selected ) == QStyle::State_Selected )
|
if ( ( option.state & QStyle::State_Selected ) == QStyle::State_Selected )
|
||||||
@@ -63,7 +60,6 @@ void SettingsListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int horizontalOffset = ( option.rect.width() - option.decorationSize.width() ) /2;
|
int horizontalOffset = ( option.rect.width() - option.decorationSize.width() ) /2;
|
||||||
QRect iconRect = option.rect.adjusted( horizontalOffset, 6, -horizontalOffset, -option.rect.height() + 6 + option.decorationSize.height() );
|
QRect iconRect = option.rect.adjusted( horizontalOffset, 6, -horizontalOffset, -option.rect.height() + 6 + option.decorationSize.height() );
|
||||||
QPixmap avatar = index.data( Qt::DecorationRole ).value<QIcon>().pixmap( iconRect.size() );
|
QPixmap avatar = index.data( Qt::DecorationRole ).value<QIcon>().pixmap( iconRect.size() );
|
||||||
|
Reference in New Issue
Block a user