mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-13 20:39:57 +01:00
Draw a speaker next to the currently playing playlist
This commit is contained in:
parent
2d439ed959
commit
4a63606c84
BIN
data/images/now-playing-speaker-dark.png
Normal file
BIN
data/images/now-playing-speaker-dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
@ -13,6 +13,7 @@
|
||||
<file>data/images/track-placeholder.png</file>
|
||||
<file>data/images/now-playing-panel.png</file>
|
||||
<file>data/images/now-playing-speaker.png</file>
|
||||
<file>data/images/now-playing-speaker-dark.png</file>
|
||||
<file>data/images/pause-pressed.png</file>
|
||||
<file>data/images/pause-rest.png</file>
|
||||
<file>data/images/play-pressed.png</file>
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "utils/tomahawkutils.h"
|
||||
#include "utils/logger.h"
|
||||
#include "viewmanager.h"
|
||||
#include "audio/audioengine.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
@ -81,3 +82,12 @@ GenericPageItem::setText( const QString &text )
|
||||
emit updated();
|
||||
}
|
||||
|
||||
bool
|
||||
GenericPageItem::isBeingPlayed() const
|
||||
{
|
||||
if ( dynamic_cast< PlaylistInterface* >( m_get() ) )
|
||||
{
|
||||
return AudioEngine::instance()->currentTrackPlaylist() == dynamic_cast< PlaylistInterface* >( m_get() );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ public:
|
||||
virtual bool willAcceptDrag( const QMimeData* data ) const;
|
||||
virtual QIcon icon() const;
|
||||
virtual int peerSortValue() const { return m_sortValue; } // How to sort relative to peers in the tree.
|
||||
virtual bool isBeingPlayed() const;
|
||||
|
||||
void setText( const QString& text );
|
||||
void setSortValue( int value ) { m_sortValue = value; }
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "utils/logger.h"
|
||||
#include "dropjob.h"
|
||||
#include "source.h"
|
||||
#include "audio/audioengine.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
@ -96,6 +97,14 @@ PlaylistItem::IDValue() const
|
||||
return m_playlist->createdOn();
|
||||
}
|
||||
|
||||
bool
|
||||
PlaylistItem::isBeingPlayed() const
|
||||
{
|
||||
if ( ViewManager::instance()->pageForPlaylist( m_playlist ) )
|
||||
return AudioEngine::instance()->currentTrackPlaylist() == ViewManager::instance()->pageForPlaylist( m_playlist )->playlistInterface();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Qt::ItemFlags
|
||||
PlaylistItem::flags() const
|
||||
@ -419,3 +428,11 @@ DynamicPlaylistItem::activateCurrent()
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool
|
||||
DynamicPlaylistItem::isBeingPlayed() const
|
||||
{
|
||||
if ( ViewManager::instance()->pageForDynPlaylist( m_dynplaylist ) )
|
||||
return AudioEngine::instance()->currentTrackPlaylist() == ViewManager::instance()->pageForDynPlaylist( m_dynplaylist )->playlistInterface();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,7 @@ public:
|
||||
virtual bool setData(const QVariant& v, bool role);
|
||||
virtual int peerSortValue() const;
|
||||
virtual int IDValue() const;
|
||||
virtual bool isBeingPlayed() const;
|
||||
|
||||
virtual SourceTreeItem* activateCurrent();
|
||||
|
||||
@ -74,6 +75,7 @@ public:
|
||||
virtual QIcon icon() const;
|
||||
|
||||
virtual SourceTreeItem* activateCurrent();
|
||||
virtual bool isBeingPlayed() const;
|
||||
|
||||
private slots:
|
||||
void onDynamicPlaylistLoaded( Tomahawk::DynamicPlaylistRevision revision );
|
||||
|
@ -68,6 +68,7 @@ public:
|
||||
virtual DropTypes supportedDropTypes( const QMimeData* mimeData ) const { Q_UNUSED( mimeData ); return DropTypesNone; }
|
||||
virtual void setDropType( DropType type ) { m_dropType = type; }
|
||||
virtual DropType dropType() const { return m_dropType; }
|
||||
virtual bool isBeingPlayed() const { return false; }
|
||||
|
||||
/// don't call me unless you are a sourcetreeitem. i prefer this to making everyone a friend
|
||||
void beginRowsAdded( int from, int to ) { emit beginChildRowsAdded( from, to ); }
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <QApplication>
|
||||
#include <QPainter>
|
||||
#include <QMouseEvent>
|
||||
#include <audio/audioengine.h>
|
||||
|
||||
#define TREEVIEW_INDENT_ADD -7
|
||||
|
||||
@ -63,6 +64,8 @@ SourceDelegate::SourceDelegate( QAbstractItemView* parent )
|
||||
|
||||
m_headphonesOff.load( RESPATH "images/headphones-off.png" );
|
||||
m_headphonesOn.load( RESPATH "images/headphones-sidebar.png" );
|
||||
m_nowPlayingSpeaker.load( RESPATH "images/now-playing-speaker.png" );
|
||||
m_nowPlayingSpeakerDark.load( RESPATH "images/now-playing-speaker-dark.png" );
|
||||
}
|
||||
|
||||
|
||||
@ -133,6 +136,21 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
|
||||
|
||||
QApplication::style()->drawControl( QStyle::CE_ItemViewItem, &o3, painter );
|
||||
|
||||
// Paint the speaker icon next to the currently-playing playlist
|
||||
const bool playable = ( type == SourcesModel::StaticPlaylist ||
|
||||
type == SourcesModel::AutomaticPlaylist ||
|
||||
type == SourcesModel::Station ||
|
||||
type == SourcesModel::GenericPage );
|
||||
|
||||
if ( playable && item->isBeingPlayed() )
|
||||
{
|
||||
const int iconW = o3.rect.height() - 4;
|
||||
QRect iconRect = QRect( option.rect.x() - iconW - 4, option.rect.y() + 2, iconW, iconW );
|
||||
QPixmap speaker = o3.state & QStyle::State_Selected ? m_nowPlayingSpeaker : m_nowPlayingSpeakerDark;
|
||||
speaker = speaker.scaledToHeight( iconW, Qt::SmoothTransformation );
|
||||
painter->drawPixmap( iconRect, speaker );
|
||||
}
|
||||
|
||||
if ( type == SourcesModel::Collection )
|
||||
{
|
||||
painter->save();
|
||||
|
@ -63,7 +63,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_headphonesOn, m_headphonesOff;
|
||||
QPixmap m_headphonesOn, m_headphonesOff, m_nowPlayingSpeaker, m_nowPlayingSpeakerDark;
|
||||
|
||||
QMap< int, SourceTreeItem::DropType > m_dropTypeMap;
|
||||
QMap< int, QString > m_dropTypeTextMap;
|
||||
|
Loading…
x
Reference in New Issue
Block a user