mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-12 09:04:33 +02:00
TWK-1017: Show now-playing icon next to playlist in flat view mode
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
* Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
|
||||
* Copyright 2010-2012, Leo Franchi <lfranchi@kde.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@@ -27,12 +27,39 @@
|
||||
#include "playlist/TrackView.h"
|
||||
#include "playlist/GridView.h"
|
||||
#include "playlist/PlaylistLargeItemDelegate.h"
|
||||
#include "PlayableProxyModelPlaylistInterface.h"
|
||||
#include "utils/TomahawkUtilsGui.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
class FlexibleViewInterface : public PlayableProxyModelPlaylistInterface {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FlexibleViewInterface( PlayableProxyModel* proxy, FlexibleView* view ) : PlayableProxyModelPlaylistInterface( proxy ), m_view( view ) {}
|
||||
|
||||
virtual bool hasChildInterface( playlistinterface_ptr playlistInterface )
|
||||
{
|
||||
if ( m_view.isNull() )
|
||||
return false;
|
||||
|
||||
if ( m_view.data()->detailedView() && m_view.data()->detailedView()->proxyModel()->playlistInterface() == playlistInterface )
|
||||
return true;
|
||||
|
||||
if ( m_view.data()->gridView() && m_view.data()->gridView()->playlistInterface()->hasChildInterface( playlistInterface ) )
|
||||
return true;
|
||||
|
||||
if ( m_view.data()->trackView() && m_view.data()->trackView()->proxyModel()->playlistInterface() == playlistInterface )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
QWeakPointer<FlexibleView> m_view;
|
||||
};
|
||||
|
||||
FlexibleView::FlexibleView( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, m_header( new FlexibleHeader( this ) )
|
||||
@@ -43,6 +70,8 @@ FlexibleView::FlexibleView( QWidget* parent )
|
||||
{
|
||||
qRegisterMetaType< FlexibleViewMode >( "FlexibleViewMode" );
|
||||
|
||||
m_playlistInterface = playlistinterface_ptr( new FlexibleViewInterface( m_trackView->proxyModel(), this ) );
|
||||
|
||||
PlaylistLargeItemDelegate* del = new PlaylistLargeItemDelegate( PlaylistLargeItemDelegate::LovedTracks, m_trackView, m_trackView->proxyModel() );
|
||||
connect( del, SIGNAL( updateIndex( QModelIndex ) ), m_trackView, SLOT( update( QModelIndex ) ) );
|
||||
m_trackView->setItemDelegate( del );
|
||||
@@ -79,8 +108,12 @@ FlexibleView::setTrackView( TrackView* view )
|
||||
delete m_trackView;
|
||||
}
|
||||
|
||||
if ( view && m_trackView != view )
|
||||
m_playlistInterface = playlistinterface_ptr( new FlexibleViewInterface( view->proxyModel(), this ) );
|
||||
|
||||
m_trackView = view;
|
||||
m_stack->addWidget( view );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -169,7 +202,7 @@ FlexibleView::setCurrentMode( FlexibleViewMode mode )
|
||||
Tomahawk::playlistinterface_ptr
|
||||
FlexibleView::playlistInterface() const
|
||||
{
|
||||
return m_trackView->playlistInterface();
|
||||
return m_playlistInterface;
|
||||
}
|
||||
|
||||
|
||||
@@ -232,3 +265,5 @@ FlexibleView::setPixmap( const QPixmap& pixmap )
|
||||
m_pixmap = pixmap;
|
||||
m_header->setPixmap( pixmap );
|
||||
}
|
||||
|
||||
#include "FlexibleView.moc"
|
||||
|
@@ -29,6 +29,7 @@ class GridView;
|
||||
class TrackView;
|
||||
class PlayableModel;
|
||||
class FlexibleHeader;
|
||||
class FlexibleViewInterface;
|
||||
|
||||
class DLLEXPORT FlexibleView : public QWidget, public Tomahawk::ViewPage
|
||||
{
|
||||
@@ -80,10 +81,14 @@ private:
|
||||
TrackView* m_detailedView;
|
||||
GridView* m_gridView;
|
||||
|
||||
Tomahawk::playlistinterface_ptr m_playlistInterface;
|
||||
|
||||
PlayableModel* m_model;
|
||||
QStackedWidget* m_stack;
|
||||
|
||||
FlexibleViewMode m_mode;
|
||||
|
||||
friend class ::FlexibleViewInterface;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE( FlexibleView::FlexibleViewMode );
|
||||
|
@@ -108,8 +108,13 @@ PlaylistItem::IDValue() const
|
||||
bool
|
||||
PlaylistItem::isBeingPlayed() const
|
||||
{
|
||||
if ( ViewManager::instance()->pageForPlaylist( m_playlist ) )
|
||||
return AudioEngine::instance()->currentTrackPlaylist() == ViewManager::instance()->pageForPlaylist( m_playlist )->playlistInterface();
|
||||
if ( ViewPage* page = ViewManager::instance()->pageForPlaylist( m_playlist ) )
|
||||
{
|
||||
if ( AudioEngine::instance()->currentTrackPlaylist() == page->playlistInterface() )
|
||||
return true;
|
||||
if ( page->playlistInterface()->hasChildInterface( AudioEngine::instance()->currentTrackPlaylist() ) )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user