From d49a43709de4eec95b0eb1bc028aee336b0a1b8a Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Fri, 11 Nov 2011 16:57:35 -0500 Subject: [PATCH] Hide red latch headphones on local source if the source you are latched on to goes offline --- src/sourcetree/items/collectionitem.cpp | 17 +++++++++++++++++ src/sourcetree/items/collectionitem.h | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/sourcetree/items/collectionitem.cpp b/src/sourcetree/items/collectionitem.cpp index 2cc950a87..1b33a3265 100644 --- a/src/sourcetree/items/collectionitem.cpp +++ b/src/sourcetree/items/collectionitem.cpp @@ -200,12 +200,28 @@ CollectionItem::icon() const } } +bool +CollectionItem::localLatchedOn() const +{ + // Don't show a listen icon if this is the local collection and we are latched on to someone who went offline + // we are technically still latched on (if they come back online we'll be still listening along) but it's not visible + // in the UI and confusing to the user why the red headphones are still there + + if ( !m_source.isNull() && m_source->isLocal() && + !m_latchedOnTo.isNull() && !m_latchedOnTo->isOnline() ) + return false; + + return m_latchedOn; +} + + void CollectionItem::latchedOff( const source_ptr& from, const source_ptr& to ) { if ( from->isLocal() && ( m_source == to || m_source == from ) ) { m_latchedOn = false; + m_latchedOnTo.clear(); emit updated(); } } @@ -216,6 +232,7 @@ CollectionItem::latchedOn( const source_ptr& from, const source_ptr& to ) if ( from->isLocal() && ( m_source == to || m_source == from ) ) { m_latchedOn = true; + m_latchedOnTo = to; emit updated(); } } diff --git a/src/sourcetree/items/collectionitem.h b/src/sourcetree/items/collectionitem.h index e2ba91e10..41409032c 100644 --- a/src/sourcetree/items/collectionitem.h +++ b/src/sourcetree/items/collectionitem.h @@ -42,7 +42,7 @@ public: virtual int peerSortValue() const; virtual int IDValue() const; - virtual bool localLatchedOn() const { return m_latchedOn; } + virtual bool localLatchedOn() const; Tomahawk::source_ptr source() const; @@ -85,7 +85,9 @@ private: QPixmap m_superCol, m_defaultAvatar; CategoryItem* m_playlists; CategoryItem* m_stations; + bool m_latchedOn; + Tomahawk::source_ptr m_latchedOnTo; QList< TemporaryPageItem* > m_tempItems; GenericPageItem* m_sourceInfoItem;