mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-04 21:27:58 +02:00
Show headphone icon as on for the local source if you are listening along to someone
This commit is contained in:
@@ -203,7 +203,7 @@ CollectionItem::icon() const
|
|||||||
void
|
void
|
||||||
CollectionItem::latchedOff( const source_ptr& from, const source_ptr& to )
|
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;
|
m_latchedOn = false;
|
||||||
emit updated();
|
emit updated();
|
||||||
@@ -213,7 +213,7 @@ CollectionItem::latchedOff( const source_ptr& from, const source_ptr& to )
|
|||||||
void
|
void
|
||||||
CollectionItem::latchedOn( const source_ptr& from, const source_ptr& to )
|
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;
|
m_latchedOn = true;
|
||||||
emit updated();
|
emit updated();
|
||||||
|
@@ -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 );
|
textRect = option.rect.adjusted( iconRect.width() + 8, painter->fontMetrics().height() + 6, -figWidth - 24, -4 );
|
||||||
painter->setFont( normal );
|
painter->setFont( normal );
|
||||||
if ( isPlaying )
|
if ( isPlaying || ( !colItem->source().isNull() && colItem->source()->isLocal() ) )
|
||||||
{
|
{
|
||||||
// Show a listen icon
|
// Show a listen icon
|
||||||
QPixmap pm;
|
QPixmap pm;
|
||||||
@@ -194,16 +194,20 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
|
|||||||
{
|
{
|
||||||
// Currently listening along
|
// Currently listening along
|
||||||
pm = m_headphonesOn;
|
pm = m_headphonesOn;
|
||||||
} else {
|
} else if ( !colItem->source()->isLocal() ) {
|
||||||
pm = m_headphonesOff;
|
pm = m_headphonesOff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !pm.isNull() )
|
||||||
|
{
|
||||||
QRect pmRect = textRect;
|
QRect pmRect = textRect;
|
||||||
pmRect.setTop( pmRect.bottom() - painter->fontMetrics().height() );
|
pmRect.setTop( pmRect.bottom() - painter->fontMetrics().height() - 3 );
|
||||||
pmRect.setRight( pmRect.left() + pmRect.height() );
|
pmRect.setRight( pmRect.left() + pmRect.height() );
|
||||||
// tDebug() << "DOING HEADPHONES RECT:" << pmRect;
|
// tDebug() << "DOING HEADPHONES RECT:" << pmRect;
|
||||||
painter->drawPixmap( pmRect, pm.scaledToHeight( pmRect.height(), Qt::SmoothTransformation ) );
|
painter->drawPixmap( pmRect, pm.scaledToHeight( pmRect.height(), Qt::SmoothTransformation ) );
|
||||||
textRect.adjust( pmRect.width() + 3, 0, 0, 0 );
|
textRect.adjust( pmRect.width() + 3, 0, 0, 0 );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
text = painter->fontMetrics().elidedText( desc, Qt::ElideRight, textRect.width() );
|
text = painter->fontMetrics().elidedText( desc, Qt::ElideRight, textRect.width() );
|
||||||
QTextOption to( Qt::AlignBottom );
|
QTextOption to( Qt::AlignBottom );
|
||||||
painter->drawText( textRect, text, to );
|
painter->drawText( textRect, text, to );
|
||||||
@@ -401,7 +405,7 @@ SourceDelegate::editorEvent ( QEvent* event, QAbstractItemModel* model, const QS
|
|||||||
{
|
{
|
||||||
CollectionItem* colItem = qobject_cast< CollectionItem* >( index.data( SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >() );
|
CollectionItem* colItem = qobject_cast< CollectionItem* >( index.data( SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >() );
|
||||||
Q_ASSERT( colItem );
|
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 );
|
QMouseEvent* ev = static_cast< QMouseEvent* >( event );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user