mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 00:24:12 +02:00
* Mark-up tracks in the sidebar when hovered.
This commit is contained in:
@@ -263,6 +263,12 @@ SourceDelegate::paintCollection( QPainter* painter, const QStyleOptionViewItem&
|
||||
m_lockRects.remove( index );
|
||||
}
|
||||
|
||||
if ( m_trackHovered == index )
|
||||
{
|
||||
QFont font = painter->font();
|
||||
font.setUnderline( true );
|
||||
painter->setFont( font );
|
||||
}
|
||||
textRect.adjust( 0, 0, 0, 2 );
|
||||
text = painter->fontMetrics().elidedText( desc, Qt::ElideRight, textRect.width() - 8 );
|
||||
QTextOption to( Qt::AlignVCenter );
|
||||
@@ -626,6 +632,22 @@ SourceDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QSt
|
||||
const QRect trackRect = m_trackRects[ index ];
|
||||
const QMouseEvent* ev = static_cast< QMouseEvent* >( event );
|
||||
hoveringTrack = trackRect.contains( ev->pos() );
|
||||
|
||||
if ( hoveringTrack )
|
||||
{
|
||||
if ( m_trackHovered != index )
|
||||
{
|
||||
m_trackHovered = index;
|
||||
QMetaObject::invokeMethod( m_parent, "update", Qt::QueuedConnection, Q_ARG( QModelIndex, index ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( !hoveringTrack )
|
||||
{
|
||||
if ( m_trackHovered.isValid() )
|
||||
QMetaObject::invokeMethod( m_parent, "update", Qt::QueuedConnection, Q_ARG( QModelIndex, m_trackHovered ) );
|
||||
|
||||
m_trackHovered = QPersistentModelIndex();
|
||||
}
|
||||
|
||||
bool lockRectContainsClick = false, headphonesRectContainsClick = false;
|
||||
|
@@ -78,6 +78,7 @@ private:
|
||||
QMap< int, QString > m_dropTypeTextMap;
|
||||
QMap< int, QPixmap > m_dropTypeImageMap;
|
||||
|
||||
mutable QPersistentModelIndex m_trackHovered;
|
||||
mutable QHash< QPersistentModelIndex, QRect > m_trackRects;
|
||||
mutable QHash< QPersistentModelIndex, QRect > m_headphoneRects;
|
||||
mutable QHash< QPersistentModelIndex, QRect > m_lockRects;
|
||||
|
Reference in New Issue
Block a user