mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 13:47:26 +02:00
Add lock/unlock icons to toggle realtime listening along
This commit is contained in:
BIN
data/images/closed-padlock.png
Normal file
BIN
data/images/closed-padlock.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
data/images/open-padlock.png
Normal file
BIN
data/images/open-padlock.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
@@ -128,6 +128,8 @@
|
|||||||
<file>data/images/headphones.png</file>
|
<file>data/images/headphones.png</file>
|
||||||
<file>data/images/headphones-off.png</file>
|
<file>data/images/headphones-off.png</file>
|
||||||
<file>data/images/headphones-sidebar.png</file>
|
<file>data/images/headphones-sidebar.png</file>
|
||||||
|
<file>data/images/closed-padlock.png</file>
|
||||||
|
<file>data/images/open-padlock.png</file>
|
||||||
<file>data/images/headphones-bigger.png</file>
|
<file>data/images/headphones-bigger.png</file>
|
||||||
<file>data/images/no-album-no-case.png</file>
|
<file>data/images/no-album-no-case.png</file>
|
||||||
<file>data/images/rdio.png</file>
|
<file>data/images/rdio.png</file>
|
||||||
|
@@ -193,6 +193,16 @@ SourceItem::localLatchedOn() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Tomahawk::PlaylistInterface::LatchMode
|
||||||
|
SourceItem::localLatchMode() const
|
||||||
|
{
|
||||||
|
if ( !m_source.isNull() && !m_source->isLocal() )
|
||||||
|
return m_source->getPlaylistInterface()->latchMode();
|
||||||
|
|
||||||
|
return Tomahawk::PlaylistInterface::StayOnSong;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SourceItem::latchedOff( const source_ptr& from, const source_ptr& to )
|
SourceItem::latchedOff( const source_ptr& from, const source_ptr& to )
|
||||||
{
|
{
|
||||||
@@ -217,6 +227,7 @@ SourceItem::latchedOn( const source_ptr& from, const source_ptr& to )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SourceItem::playlistsAddedInternal( SourceTreeItem* parent, const QList< dynplaylist_ptr >& playlists )
|
SourceItem::playlistsAddedInternal( SourceTreeItem* parent, const QList< dynplaylist_ptr >& playlists )
|
||||||
{
|
{
|
||||||
|
@@ -42,6 +42,7 @@ public:
|
|||||||
virtual int IDValue() const;
|
virtual int IDValue() const;
|
||||||
|
|
||||||
virtual bool localLatchedOn() const;
|
virtual bool localLatchedOn() const;
|
||||||
|
virtual Tomahawk::PlaylistInterface::LatchMode localLatchMode() const;
|
||||||
|
|
||||||
Tomahawk::source_ptr source() const;
|
Tomahawk::source_ptr source() const;
|
||||||
|
|
||||||
|
@@ -66,6 +66,8 @@ SourceDelegate::SourceDelegate( QAbstractItemView* parent )
|
|||||||
|
|
||||||
m_headphonesOff.load( RESPATH "images/headphones-off.png" );
|
m_headphonesOff.load( RESPATH "images/headphones-off.png" );
|
||||||
m_headphonesOn.load( RESPATH "images/headphones-sidebar.png" );
|
m_headphonesOn.load( RESPATH "images/headphones-sidebar.png" );
|
||||||
|
m_realtimeLocked.load( RESPATH "images/closed-padlock.png" );
|
||||||
|
m_realtimeUnlocked.load( RESPATH "images/open-padlock.png" );
|
||||||
m_nowPlayingSpeaker.load( RESPATH "images/now-playing-speaker.png" );
|
m_nowPlayingSpeaker.load( RESPATH "images/now-playing-speaker.png" );
|
||||||
m_nowPlayingSpeakerDark.load( RESPATH "images/now-playing-speaker-dark.png" );
|
m_nowPlayingSpeakerDark.load( RESPATH "images/now-playing-speaker-dark.png" );
|
||||||
}
|
}
|
||||||
@@ -201,23 +203,39 @@ SourceDelegate::paintCollection( QPainter* painter, const QStyleOptionViewItem&
|
|||||||
if ( isPlaying || ( !colItem->source().isNull() && colItem->source()->isLocal() ) )
|
if ( isPlaying || ( !colItem->source().isNull() && colItem->source()->isLocal() ) )
|
||||||
{
|
{
|
||||||
// Show a listen icon
|
// Show a listen icon
|
||||||
QPixmap pm;
|
QPixmap listenAlongPixmap;
|
||||||
|
QPixmap realtimeListeningAlongPixmap;
|
||||||
if ( index.data( SourcesModel::LatchedOnRole ).toBool() )
|
if ( index.data( SourcesModel::LatchedOnRole ).toBool() )
|
||||||
{
|
{
|
||||||
// Currently listening along
|
// Currently listening along
|
||||||
pm = m_headphonesOn;
|
listenAlongPixmap = m_headphonesOn;
|
||||||
|
if ( !colItem->source()->isLocal() )
|
||||||
|
{
|
||||||
|
realtimeListeningAlongPixmap =
|
||||||
|
colItem->source()->getPlaylistInterface()->latchMode() == Tomahawk::PlaylistInterface::RealTime ?
|
||||||
|
m_realtimeLocked : m_realtimeUnlocked;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ( !colItem->source()->isLocal() )
|
else if ( !colItem->source()->isLocal() )
|
||||||
{
|
{
|
||||||
pm = m_headphonesOff;
|
listenAlongPixmap = m_headphonesOff;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !pm.isNull() )
|
if ( !listenAlongPixmap.isNull() )
|
||||||
{
|
{
|
||||||
QRect pmRect = textRect;
|
QRect pmRect = textRect;
|
||||||
pmRect.setTop( pmRect.bottom() - painter->fontMetrics().height() + 3 );
|
pmRect.setTop( pmRect.bottom() - painter->fontMetrics().height() + 3 );
|
||||||
pmRect.setRight( pmRect.left() + pmRect.height() );
|
pmRect.setRight( pmRect.left() + pmRect.height() );
|
||||||
painter->drawPixmap( pmRect, pm.scaledToHeight( pmRect.height(), Qt::SmoothTransformation ) );
|
painter->drawPixmap( pmRect, listenAlongPixmap.scaledToHeight( pmRect.height(), Qt::SmoothTransformation ) );
|
||||||
|
textRect.adjust( pmRect.width() + 3, 0, 0, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !realtimeListeningAlongPixmap.isNull() )
|
||||||
|
{
|
||||||
|
QRect pmRect = textRect;
|
||||||
|
pmRect.setTop( pmRect.bottom() - painter->fontMetrics().height() + 3 );
|
||||||
|
pmRect.setRight( pmRect.left() + pmRect.height() );
|
||||||
|
painter->drawPixmap( pmRect, realtimeListeningAlongPixmap.scaledToHeight( pmRect.height(), Qt::SmoothTransformation ) );
|
||||||
textRect.adjust( pmRect.width() + 3, 0, 0, 0 );
|
textRect.adjust( pmRect.width() + 3, 0, 0, 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -578,15 +596,23 @@ SourceDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QSt
|
|||||||
const int height = fm.height() + 3;
|
const int height = fm.height() + 3;
|
||||||
|
|
||||||
QRect headphonesRect( option.rect.height() + 10, o.rect.bottom() - height, height, height );
|
QRect headphonesRect( option.rect.height() + 10, o.rect.bottom() - height, height, height );
|
||||||
if ( headphonesRect.contains( ev->pos() ) )
|
bool headphonesRectContainsClick = headphonesRect.contains( ev->pos() );
|
||||||
|
QRect lockRect( option.rect.height() + 20, o.rect.bottom() - height, height, height );
|
||||||
|
bool lockRectContainsClick = lockRect.contains( ev->pos() );
|
||||||
|
if ( headphonesRectContainsClick || lockRectContainsClick )
|
||||||
{
|
{
|
||||||
if ( event->type() == QEvent::MouseButtonRelease )
|
if ( event->type() == QEvent::MouseButtonRelease )
|
||||||
{
|
{
|
||||||
if ( index.data( SourcesModel::LatchedOnRole ).toBool() )
|
if ( headphonesRectContainsClick )
|
||||||
// unlatch
|
{
|
||||||
emit latchOff( colItem->source() );
|
if ( index.data( SourcesModel::LatchedOnRole ).toBool() )
|
||||||
else
|
// unlatch
|
||||||
emit latchOn( colItem->source() );
|
emit latchOff( colItem->source() );
|
||||||
|
else
|
||||||
|
emit latchOn( colItem->source() );
|
||||||
|
}
|
||||||
|
else // it's in the lock rect
|
||||||
|
emit toggleRealtimeLatch( colItem->source(), !index.data( SourcesModel::LatchedRealtimeRole ).toBool() );
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -44,6 +44,7 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void latchOn( const Tomahawk::source_ptr& idx );
|
void latchOn( const Tomahawk::source_ptr& idx );
|
||||||
void latchOff( const Tomahawk::source_ptr& idx );
|
void latchOff( const Tomahawk::source_ptr& idx );
|
||||||
|
void toggleRealtimeLatch( const Tomahawk::source_ptr& idx, bool realtime );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
virtual QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
||||||
@@ -69,7 +70,7 @@ private:
|
|||||||
QMimeData *m_dropMimeData;
|
QMimeData *m_dropMimeData;
|
||||||
mutable SourceTreeItem::DropType m_hoveredDropType; // Hack to keep easily track of the current highlighted DropType in paint()
|
mutable SourceTreeItem::DropType m_hoveredDropType; // Hack to keep easily track of the current highlighted DropType in paint()
|
||||||
QMap< QModelIndex, AnimationHelper* > m_expandedMap;
|
QMap< QModelIndex, AnimationHelper* > m_expandedMap;
|
||||||
QPixmap m_headphonesOn, m_headphonesOff, m_nowPlayingSpeaker, m_nowPlayingSpeakerDark;
|
QPixmap m_headphonesOn, m_headphonesOff, m_realtimeLocked, m_realtimeUnlocked, m_nowPlayingSpeaker, m_nowPlayingSpeakerDark;
|
||||||
|
|
||||||
QMap< int, SourceTreeItem::DropType > m_dropTypeMap;
|
QMap< int, SourceTreeItem::DropType > m_dropTypeMap;
|
||||||
QMap< int, QString > m_dropTypeTextMap;
|
QMap< int, QString > m_dropTypeTextMap;
|
||||||
|
@@ -127,6 +127,15 @@ SourcesModel::data( const QModelIndex& index, int role ) const
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
case SourcesModel::LatchedRealtimeRole:
|
||||||
|
{
|
||||||
|
if ( itemFromIndex( index )->type() == Collection )
|
||||||
|
{
|
||||||
|
SourceItem* cItem = qobject_cast< SourceItem* >( itemFromIndex( index ) );
|
||||||
|
return cItem->localLatchMode() == Tomahawk::PlaylistInterface::RealTime;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@@ -70,7 +70,8 @@ public:
|
|||||||
SourceTreeItemTypeRole = Qt::UserRole + 11,
|
SourceTreeItemTypeRole = Qt::UserRole + 11,
|
||||||
SortRole = Qt::UserRole + 12,
|
SortRole = Qt::UserRole + 12,
|
||||||
IDRole = Qt::UserRole + 13,
|
IDRole = Qt::UserRole + 13,
|
||||||
LatchedOnRole = Qt::UserRole + 14
|
LatchedOnRole = Qt::UserRole + 14,
|
||||||
|
LatchedRealtimeRole = Qt::UserRole + 15
|
||||||
};
|
};
|
||||||
|
|
||||||
SourcesModel( QObject* parent = 0 );
|
SourcesModel( QObject* parent = 0 );
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include "sourcesproxymodel.h"
|
#include "sourcesproxymodel.h"
|
||||||
|
|
||||||
#include <QTreeView>
|
#include <QtGui/QTreeView>
|
||||||
|
|
||||||
#include "sourcelist.h"
|
#include "sourcelist.h"
|
||||||
#include "sourcesmodel.h"
|
#include "sourcesmodel.h"
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
#ifndef SOURCESPROXYMODEL_H
|
#ifndef SOURCESPROXYMODEL_H
|
||||||
#define SOURCESPROXYMODEL_H
|
#define SOURCESPROXYMODEL_H
|
||||||
|
|
||||||
#include <QSortFilterProxyModel>
|
#include <QtGui/QSortFilterProxyModel>
|
||||||
|
|
||||||
class SourcesModel;
|
class SourcesModel;
|
||||||
|
|
||||||
|
@@ -86,6 +86,7 @@ SourceTreeView::SourceTreeView( QWidget* parent )
|
|||||||
m_delegate = new SourceDelegate( this );
|
m_delegate = new SourceDelegate( this );
|
||||||
connect( m_delegate, SIGNAL( latchOn( Tomahawk::source_ptr ) ), SLOT( latchOnOrCatchUp( Tomahawk::source_ptr ) ) );
|
connect( m_delegate, SIGNAL( latchOn( Tomahawk::source_ptr ) ), SLOT( latchOnOrCatchUp( Tomahawk::source_ptr ) ) );
|
||||||
connect( m_delegate, SIGNAL( latchOff( Tomahawk::source_ptr ) ), SLOT( latchOff( Tomahawk::source_ptr ) ) );
|
connect( m_delegate, SIGNAL( latchOff( Tomahawk::source_ptr ) ), SLOT( latchOff( Tomahawk::source_ptr ) ) );
|
||||||
|
connect( m_delegate, SIGNAL( toggleRealtimeLatch( Tomahawk::source_ptr, bool ) ), m_latchManager, SLOT( latchModeChangeRequest( Tomahawk::source_ptr,bool ) ) );
|
||||||
|
|
||||||
setItemDelegate( m_delegate );
|
setItemDelegate( m_delegate );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user