mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 07:49:42 +01:00
Prep for headphones-on-avatar
This commit is contained in:
parent
08e4da1c8a
commit
6c0d984990
@ -29,6 +29,7 @@
|
||||
#include "playlist/customplaylistview.h"
|
||||
#include "source.h"
|
||||
#include "temporarypageitem.h"
|
||||
#include <sourcelist.h>
|
||||
|
||||
/// CollectionItem
|
||||
|
||||
@ -39,6 +40,7 @@ CollectionItem::CollectionItem( SourcesModel* mdl, SourceTreeItem* parent, cons
|
||||
, m_source( source )
|
||||
, m_playlists( 0 )
|
||||
, m_stations( 0 )
|
||||
, m_latchedOn( false )
|
||||
, m_sourceInfoItem( 0 )
|
||||
, m_coolPlaylistsItem( 0 )
|
||||
, m_lovedTracksItem()
|
||||
@ -118,6 +120,8 @@ CollectionItem::CollectionItem( SourcesModel* mdl, SourceTreeItem* parent, cons
|
||||
connect( source.data(), SIGNAL( stateChanged() ), this, SIGNAL( updated() ) );
|
||||
connect( source.data(), SIGNAL( offline() ), this, SIGNAL( updated() ) );
|
||||
connect( source.data(), SIGNAL( online() ), this, SIGNAL( updated() ) );
|
||||
connect( SourceList::instance(), SIGNAL( sourceLatchedOn( Tomahawk::source_ptr, Tomahawk::source_ptr ) ), this, SLOT( latchedOn( Tomahawk::source_ptr, Tomahawk::source_ptr ) ) );
|
||||
connect( SourceList::instance(), SIGNAL( sourceLatchedOff( Tomahawk::source_ptr, Tomahawk::source_ptr ) ), this, SLOT( latchedOff( Tomahawk::source_ptr, Tomahawk::source_ptr ) ) );
|
||||
|
||||
connect( source->collection().data(), SIGNAL( playlistsAdded( QList<Tomahawk::playlist_ptr> ) ),
|
||||
SLOT( onPlaylistsAdded( QList<Tomahawk::playlist_ptr> ) ), Qt::QueuedConnection );
|
||||
@ -196,6 +200,26 @@ CollectionItem::icon() const
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CollectionItem::latchedOff( const source_ptr& from, const source_ptr& to )
|
||||
{
|
||||
if ( from->isLocal() && m_source == to )
|
||||
{
|
||||
m_latchedOn = false;
|
||||
emit updated();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CollectionItem::latchedOn( const source_ptr& from, const source_ptr& to )
|
||||
{
|
||||
if ( from->isLocal() && m_source == to )
|
||||
{
|
||||
m_latchedOn = true;
|
||||
emit updated();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CollectionItem::playlistsAddedInternal( SourceTreeItem* parent, const QList< dynplaylist_ptr >& playlists )
|
||||
|
@ -42,6 +42,8 @@ public:
|
||||
virtual int peerSortValue() const;
|
||||
virtual int IDValue() const;
|
||||
|
||||
virtual bool localLatchedOn() const { return m_latchedOn; }
|
||||
|
||||
Tomahawk::source_ptr source() const;
|
||||
|
||||
CategoryItem* stationsCategory() const { return m_stations; }
|
||||
@ -57,6 +59,9 @@ private slots:
|
||||
void onStationsAdded( const QList<Tomahawk::dynplaylist_ptr>& stations );
|
||||
void onStationDeleted( const Tomahawk::dynplaylist_ptr& stations );
|
||||
|
||||
void latchedOn( const Tomahawk::source_ptr&, const Tomahawk::source_ptr& );
|
||||
void latchedOff( const Tomahawk::source_ptr&, const Tomahawk::source_ptr& );
|
||||
|
||||
void requestExpanding();
|
||||
|
||||
void tempPageActivated( Tomahawk::ViewPage* );
|
||||
@ -79,6 +84,7 @@ private:
|
||||
QPixmap m_superCol, m_defaultAvatar;
|
||||
CategoryItem* m_playlists;
|
||||
CategoryItem* m_stations;
|
||||
bool m_latchedOn;
|
||||
|
||||
QList< TemporaryPageItem* > m_tempItems;
|
||||
GenericPageItem* m_sourceInfoItem;
|
||||
|
@ -53,13 +53,15 @@ SourceDelegate::SourceDelegate( QAbstractItemView* parent )
|
||||
m_dropTypeTextMap.insert( 3, tr( "Local" ) );
|
||||
m_dropTypeTextMap.insert( 4, tr( "Top 10" ) );
|
||||
|
||||
m_dropTypeImageMap.insert( 0, QPixmap( ":/data/images/drop-song.png" ).scaledToWidth( 32, Qt::SmoothTransformation ) );
|
||||
m_dropTypeImageMap.insert( 1, QPixmap( ":/data/images/drop-album.png" ).scaledToWidth( 32, Qt::SmoothTransformation ) );
|
||||
m_dropTypeImageMap.insert( 2, QPixmap( ":/data/images/drop-all-songs.png" ).scaledToHeight( 32, Qt::SmoothTransformation ) );
|
||||
m_dropTypeImageMap.insert( 3, QPixmap( ":/data/images/drop-local-songs.png" ).scaledToWidth( 32, Qt::SmoothTransformation ) );
|
||||
m_dropTypeImageMap.insert( 4, QPixmap( ":/data/images/drop-top-songs.png" ).scaledToWidth( 32, Qt::SmoothTransformation ) );
|
||||
m_dropTypeImageMap.insert( 0, QPixmap( RESPATH "images/drop-song.png" ).scaledToWidth( 32, Qt::SmoothTransformation ) );
|
||||
m_dropTypeImageMap.insert( 1, QPixmap( RESPATH "images/drop-album.png" ).scaledToWidth( 32, Qt::SmoothTransformation ) );
|
||||
m_dropTypeImageMap.insert( 2, QPixmap( RESPATH "images/drop-all-songs.png" ).scaledToHeight( 32, Qt::SmoothTransformation ) );
|
||||
m_dropTypeImageMap.insert( 3, QPixmap( RESPATH "images/drop-local-songs.png" ).scaledToWidth( 32, Qt::SmoothTransformation ) );
|
||||
m_dropTypeImageMap.insert( 4, QPixmap( RESPATH "images/drop-top-songs.png" ).scaledToWidth( 32, Qt::SmoothTransformation ) );
|
||||
|
||||
m_dropMimeData = new QMimeData();
|
||||
|
||||
m_headphones.load( RESPATH "images/headphones.png" );
|
||||
}
|
||||
|
||||
|
||||
@ -156,7 +158,16 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
|
||||
QRect iconRect = option.rect.adjusted( 4, 6, -option.rect.width() + option.rect.height() - 12 + 4, -6 );
|
||||
|
||||
QPixmap avatar = colItem->icon().pixmap( iconRect.size() );
|
||||
painter->drawPixmap( iconRect, avatar.scaledToHeight( iconRect.height(), Qt::SmoothTransformation ) );
|
||||
if ( index.data( SourcesModel::LatchedOnRole ).toBool() && !m_headphones.isNull() )
|
||||
{
|
||||
// Draw headphones around the source
|
||||
painter->drawPixmap( iconRect, avatar.scaledToHeight( iconRect.height(), Qt::SmoothTransformation ) );
|
||||
// painter->drawPixmap( iconRect, m_headphones.scaledToHeight( iconRect.height(), Qt::SmoothTransformation ) );
|
||||
// QRect inHeadphones = iconRect.adjusted( 5, 10, -5, 0);
|
||||
// painter->drawPixmap( inHeadphones, avatar.scaledToHeight( inHeadphones.height(), Qt::SmoothTransformation ) );
|
||||
}
|
||||
else
|
||||
painter->drawPixmap( iconRect, avatar.scaledToHeight( iconRect.height(), Qt::SmoothTransformation ) );
|
||||
|
||||
if ( ( option.state & QStyle::State_Selected ) == QStyle::State_Selected )
|
||||
{
|
||||
|
@ -59,6 +59,7 @@ private:
|
||||
QMimeData *m_dropMimeData;
|
||||
mutable SourceTreeItem::DropType m_hoveredDropType; // Hack to keep easily track of the current highlighted DropType in paint()
|
||||
QMap< QModelIndex, AnimationHelper* > m_expandedMap;
|
||||
QPixmap m_headphones;
|
||||
|
||||
QMap< int, SourceTreeItem::DropType > m_dropTypeMap;
|
||||
QMap< int, QString > m_dropTypeTextMap;
|
||||
|
@ -110,6 +110,15 @@ SourcesModel::data( const QModelIndex& index, int role ) const
|
||||
return itemFromIndex( index )->peerSortValue();
|
||||
case SourcesModel::IDRole:
|
||||
return itemFromIndex( index )->IDValue();
|
||||
case SourcesModel::LatchedOnRole:
|
||||
{
|
||||
if ( itemFromIndex( index )->type() == Collection )
|
||||
{
|
||||
CollectionItem* cItem = qobject_cast< CollectionItem* >( itemFromIndex( index ) );
|
||||
return cItem->localLatchedOn();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -64,7 +64,8 @@ public:
|
||||
SourceTreeItemRole = Qt::UserRole + 10,
|
||||
SourceTreeItemTypeRole = Qt::UserRole + 11,
|
||||
SortRole = Qt::UserRole + 12,
|
||||
IDRole = Qt::UserRole + 13
|
||||
IDRole = Qt::UserRole + 13,
|
||||
LatchedOnRole = Qt::UserRole + 14
|
||||
};
|
||||
|
||||
SourcesModel( QObject* parent = 0 );
|
||||
|
Loading…
x
Reference in New Issue
Block a user