1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-21 00:09:47 +01:00

Show headphone icon as on for the local source if you are listening along to someone

This commit is contained in:
Leo Franchi 2011-09-22 22:34:26 -04:00
parent 624c05bdf4
commit efbbdf1e72
2 changed files with 15 additions and 11 deletions

View File

@ -203,7 +203,7 @@ CollectionItem::icon() const
void
CollectionItem::latchedOff( const source_ptr& from, const source_ptr& to )
{
if ( from->isLocal() && m_source == to )
if ( from->isLocal() && ( m_source == to || m_source == from ) )
{
m_latchedOn = false;
emit updated();
@ -213,7 +213,7 @@ CollectionItem::latchedOff( const source_ptr& from, const source_ptr& to )
void
CollectionItem::latchedOn( const source_ptr& from, const source_ptr& to )
{
if ( from->isLocal() && m_source == to )
if ( from->isLocal() && ( m_source == to || m_source == from ) )
{
m_latchedOn = true;
emit updated();

View File

@ -186,7 +186,7 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
textRect = option.rect.adjusted( iconRect.width() + 8, painter->fontMetrics().height() + 6, -figWidth - 24, -4 );
painter->setFont( normal );
if ( isPlaying )
if ( isPlaying || ( !colItem->source().isNull() && colItem->source()->isLocal() ) )
{
// Show a listen icon
QPixmap pm;
@ -194,15 +194,19 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
{
// Currently listening along
pm = m_headphonesOn;
} else {
} else if ( !colItem->source()->isLocal() ) {
pm = m_headphonesOff;
}
QRect pmRect = textRect;
pmRect.setTop( pmRect.bottom() - painter->fontMetrics().height() );
pmRect.setRight( pmRect.left() + pmRect.height() );
// tDebug() << "DOING HEADPHONES RECT:" << pmRect;
painter->drawPixmap( pmRect, pm.scaledToHeight( pmRect.height(), Qt::SmoothTransformation ) );
textRect.adjust( pmRect.width() + 3, 0, 0, 0 );
if ( !pm.isNull() )
{
QRect pmRect = textRect;
pmRect.setTop( pmRect.bottom() - painter->fontMetrics().height() - 3 );
pmRect.setRight( pmRect.left() + pmRect.height() );
// tDebug() << "DOING HEADPHONES RECT:" << pmRect;
painter->drawPixmap( pmRect, pm.scaledToHeight( pmRect.height(), Qt::SmoothTransformation ) );
textRect.adjust( pmRect.width() + 3, 0, 0, 0 );
}
}
text = painter->fontMetrics().elidedText( desc, Qt::ElideRight, textRect.width() );
QTextOption to( Qt::AlignBottom );
@ -401,7 +405,7 @@ SourceDelegate::editorEvent ( QEvent* event, QAbstractItemModel* model, const QS
{
CollectionItem* colItem = qobject_cast< CollectionItem* >( index.data( SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >() );
Q_ASSERT( colItem );
if ( !colItem->source().isNull() && !colItem->source()->currentTrack().isNull() )
if ( !colItem->source().isNull() && !colItem->source()->currentTrack().isNull() && !colItem->source()->isLocal() )
{
QMouseEvent* ev = static_cast< QMouseEvent* >( event );