mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 06:07:37 +02:00
Draw small text with highlighted color in large delegate if selected
This commit is contained in:
@@ -99,7 +99,7 @@ PlaylistLargeItemDelegate::prepareStyleOption( QStyleOptionViewItemV4* option, c
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistLargeItemDelegate::drawRichText( QPainter* painter, const QRect& rect, int flags, QTextDocument& text ) const
|
PlaylistLargeItemDelegate::drawRichText( QPainter* painter, const QStyleOptionViewItem& option, const QRect& rect, int flags, QTextDocument& text ) const
|
||||||
{
|
{
|
||||||
text.setPageSize( QSize( rect.width(), QWIDGETSIZE_MAX ) );
|
text.setPageSize( QSize( rect.width(), QWIDGETSIZE_MAX ) );
|
||||||
QAbstractTextDocumentLayout* layout = text.documentLayout();
|
QAbstractTextDocumentLayout* layout = text.documentLayout();
|
||||||
@@ -112,6 +112,10 @@ PlaylistLargeItemDelegate::drawRichText( QPainter* painter, const QRect& rect, i
|
|||||||
y += ( rect.height() - height ) / 2;
|
y += ( rect.height() - height ) / 2;
|
||||||
|
|
||||||
QAbstractTextDocumentLayout::PaintContext context;
|
QAbstractTextDocumentLayout::PaintContext context;
|
||||||
|
|
||||||
|
if ( option.state & QStyle::State_Selected )
|
||||||
|
context.palette.setColor( QPalette::Text, option.palette.color( QPalette::HighlightedText ) );
|
||||||
|
else
|
||||||
context.palette.setColor( QPalette::Text, painter->pen().color() );
|
context.palette.setColor( QPalette::Text, painter->pen().color() );
|
||||||
|
|
||||||
painter->save();
|
painter->save();
|
||||||
@@ -235,7 +239,7 @@ PlaylistLargeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
|
|||||||
if ( textDoc.idealWidth() > leftRect.width() )
|
if ( textDoc.idealWidth() > leftRect.width() )
|
||||||
textDoc.setHtml( item->query()->socialActionDescription( "Love", Query::Short ) );
|
textDoc.setHtml( item->query()->socialActionDescription( "Love", Query::Short ) );
|
||||||
|
|
||||||
drawRichText( painter, leftRect, Qt::AlignBottom, textDoc );
|
drawRichText( painter, option, leftRect, Qt::AlignBottom, textDoc );
|
||||||
|
|
||||||
if ( duration > 0 )
|
if ( duration > 0 )
|
||||||
{
|
{
|
||||||
|
@@ -59,7 +59,7 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void prepareStyleOption( QStyleOptionViewItemV4* option, const QModelIndex& index, PlayableItem* item ) const;
|
void prepareStyleOption( QStyleOptionViewItemV4* option, const QModelIndex& index, PlayableItem* item ) const;
|
||||||
void drawRichText( QPainter* painter, const QRect& rect, int flags, QTextDocument& text ) const;
|
void drawRichText( QPainter* painter, const QStyleOptionViewItem& option, const QRect& rect, int flags, QTextDocument& text ) const;
|
||||||
|
|
||||||
QTextOption m_topOption;
|
QTextOption m_topOption;
|
||||||
QTextOption m_centerRightOption;
|
QTextOption m_centerRightOption;
|
||||||
|
Reference in New Issue
Block a user