1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-13 17:43:59 +02:00

Show speaker icon for any playing playlist

This commit is contained in:
Leo Franchi
2011-10-21 12:06:21 -04:00
parent e1c6e83b98
commit 98d939a81b
14 changed files with 110 additions and 9 deletions

View File

@@ -22,7 +22,8 @@
#include "database/databasecommand_genericselect.h" #include "database/databasecommand_genericselect.h"
#include "database/database.h" #include "database/database.h"
#include "utils/tomahawkutils.h" #include "utils/tomahawkutils.h"
#include <sourcelist.h> #include "sourcelist.h"
#include "audio/audioengine.h"
using namespace Tomahawk; using namespace Tomahawk;
@@ -54,6 +55,19 @@ CustomPlaylistView::CustomPlaylistView( CustomPlaylistView::PlaylistType type, c
CustomPlaylistView::~CustomPlaylistView() CustomPlaylistView::~CustomPlaylistView()
{} {}
bool
CustomPlaylistView::isBeingPlayed() const
{
return AudioEngine::instance()->currentTrackPlaylist() == playlistInterface();
}
bool
CustomPlaylistView::jumpToCurrentTrack()
{
return PlaylistView::jumpToCurrentTrack();
}
void void
CustomPlaylistView::generateTracks() CustomPlaylistView::generateTracks()
{ {

View File

@@ -46,7 +46,10 @@ public:
virtual QPixmap pixmap() const; virtual QPixmap pixmap() const;
virtual QString description() const; virtual QString description() const;
virtual QString longDescription() const; virtual QString longDescription() const;
virtual bool isTemporaryPage() const { return false; } virtual bool isTemporaryPage() const { return false; }
virtual bool isBeingPlayed() const;
virtual bool jumpToCurrentTrack();
private slots: private slots:
void tracksGenerated( QList<Tomahawk::query_ptr> tracks ); void tracksGenerated( QList<Tomahawk::query_ptr> tracks );

View File

@@ -53,6 +53,7 @@ public:
virtual bool jumpToCurrentTrack() = 0; virtual bool jumpToCurrentTrack() = 0;
virtual bool isTemporaryPage() const { return false; } virtual bool isTemporaryPage() const { return false; }
virtual bool isBeingPlayed() const { return false; }
virtual bool canAutoUpdate() const { return false; } virtual bool canAutoUpdate() const { return false; }
virtual void setAutoUpdate( bool ) {} virtual void setAutoUpdate( bool ) {}

View File

@@ -19,6 +19,7 @@
#include "AlbumInfoWidget.h" #include "AlbumInfoWidget.h"
#include "ui_AlbumInfoWidget.h" #include "ui_AlbumInfoWidget.h"
#include "audio/audioengine.h"
#include "viewmanager.h" #include "viewmanager.h"
#include "database/database.h" #include "database/database.h"
#include "playlist/treemodel.h" #include "playlist/treemodel.h"
@@ -117,6 +118,18 @@ AlbumInfoWidget::onLoadingFinished()
m_button->show(); m_button->show();
} }
bool
AlbumInfoWidget::isBeingPlayed() const
{
if ( ui->albumsView->playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() )
return true;
if ( ui->tracksView->playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() )
return true;
return false;
}
void void
AlbumInfoWidget::load( const album_ptr& album ) AlbumInfoWidget::load( const album_ptr& album )

View File

@@ -75,6 +75,7 @@ public:
virtual bool showStatsBar() const { return false; } virtual bool showStatsBar() const { return false; }
virtual bool jumpToCurrentTrack() { return false; } virtual bool jumpToCurrentTrack() { return false; }
virtual bool isBeingPlayed() const;
signals: signals:
void longDescriptionChanged( const QString& description ); void longDescriptionChanged( const QString& description );

View File

@@ -19,6 +19,7 @@
#include "ArtistInfoWidget.h" #include "ArtistInfoWidget.h"
#include "ui_ArtistInfoWidget.h" #include "ui_ArtistInfoWidget.h"
#include "audio/audioengine.h"
#include "viewmanager.h" #include "viewmanager.h"
#include "playlist/treemodel.h" #include "playlist/treemodel.h"
#include "playlist/playlistmodel.h" #include "playlist/playlistmodel.h"
@@ -125,6 +126,36 @@ ArtistInfoWidget::onLoadingFinished()
m_button->show(); m_button->show();
} }
bool
ArtistInfoWidget::isBeingPlayed() const
{
if ( ui->albums->playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() )
return true;
if ( ui->relatedArtists->playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() )
return true;
if ( ui->topHits->playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() )
return true;
return false;
}
bool
ArtistInfoWidget::jumpToCurrentTrack()
{
if ( ui->albums->jumpToCurrentTrack() )
return true;
if ( ui->relatedArtists->jumpToCurrentTrack() )
return true;
if ( ui->topHits->jumpToCurrentTrack() )
return true;
return false;
}
void void
ArtistInfoWidget::load( const artist_ptr& artist ) ArtistInfoWidget::load( const artist_ptr& artist )

View File

@@ -76,7 +76,8 @@ public:
virtual bool isTemporaryPage() const { return true; } virtual bool isTemporaryPage() const { return true; }
virtual bool showStatsBar() const { return false; } virtual bool showStatsBar() const { return false; }
virtual bool jumpToCurrentTrack() { return false; } virtual bool jumpToCurrentTrack();
virtual bool isBeingPlayed() const;
signals: signals:
void longDescriptionChanged( const QString& description ); void longDescriptionChanged( const QString& description );

View File

@@ -1,6 +1,7 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> === /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
* *
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org> * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2011, Leo Franchi <lfranchi@kde.org>
* *
* Tomahawk is free software: you can redistribute it and/or modify * Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -98,6 +99,12 @@ WelcomeWidget::~WelcomeWidget()
delete ui; delete ui;
} }
bool
WelcomeWidget::isBeingPlayed() const
{
return AudioEngine::instance()->currentTrackPlaylist() == ui->tracksView->playlistInterface();
}
void void
WelcomeWidget::updateRecentTracks() WelcomeWidget::updateRecentTracks()

View File

@@ -93,6 +93,7 @@ public:
virtual bool showInfoBar() const { return false; } virtual bool showInfoBar() const { return false; }
virtual bool jumpToCurrentTrack() { return false; } virtual bool jumpToCurrentTrack() { return false; }
virtual bool isBeingPlayed() const;
protected: protected:
void changeEvent( QEvent* e ); void changeEvent( QEvent* e );

View File

@@ -1,6 +1,7 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> === /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
* *
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org> * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2011, Leo Franchi <lfranchi@kde.org>
* *
* Tomahawk is free software: you can redistribute it and/or modify * Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -29,6 +30,7 @@
#include "RecentPlaylistsModel.h" #include "RecentPlaylistsModel.h"
#include "audio/audioengine.h" #include "audio/audioengine.h"
#include "dynamic/GeneratorInterface.h"
#include "playlist/playlistmodel.h" #include "playlist/playlistmodel.h"
#include "playlist/treeproxymodel.h" #include "playlist/treeproxymodel.h"
#include "widgets/overlaywidget.h" #include "widgets/overlaywidget.h"
@@ -36,7 +38,6 @@
#include "widgets/kbreadcrumbselectionmodel.h" #include "widgets/kbreadcrumbselectionmodel.h"
#include "utils/tomahawkutils.h" #include "utils/tomahawkutils.h"
#include "utils/logger.h" #include "utils/logger.h"
#include <dynamic/GeneratorInterface.h>
#include <pipeline.h> #include <pipeline.h>
#define HISTORY_TRACK_ITEMS 25 #define HISTORY_TRACK_ITEMS 25
@@ -99,6 +100,7 @@ WhatsHotWidget::WhatsHotWidget( QWidget* parent )
connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) ); connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
connect( AudioEngine::instance(), SIGNAL( playlistChanged( Tomahawk::PlaylistInterface* ) ), this, SLOT( playlistChanged( Tomahawk::PlaylistInterface* ) ) );
QTimer::singleShot( 0, this, SLOT( fetchData() ) ); QTimer::singleShot( 0, this, SLOT( fetchData() ) );
} }
@@ -109,6 +111,31 @@ WhatsHotWidget::~WhatsHotWidget()
} }
bool
WhatsHotWidget::isBeingPlayed() const
{
if ( AudioEngine::instance()->currentTrackPlaylist() == ui->artistsViewLeft->playlistInterface() )
return true;
if ( AudioEngine::instance()->currentTrackPlaylist() == ui->tracksViewLeft->playlistInterface() )
return true;
return false;
}
bool
WhatsHotWidget::jumpToCurrentTrack()
{
if ( ui->artistsViewLeft->jumpToCurrentTrack() )
return true;
if ( ui->tracksViewLeft->jumpToCurrentTrack() )
return true;
return false;
}
void void
WhatsHotWidget::fetchData() WhatsHotWidget::fetchData()
{ {

View File

@@ -65,7 +65,8 @@ public:
virtual bool showStatsBar() const { return false; } virtual bool showStatsBar() const { return false; }
virtual bool showInfoBar() const { return false; } virtual bool showInfoBar() const { return false; }
virtual bool jumpToCurrentTrack() { return false; } virtual bool jumpToCurrentTrack();
virtual bool isBeingPlayed() const;
protected: protected:
void changeEvent( QEvent* e ); void changeEvent( QEvent* e );
@@ -80,7 +81,6 @@ private slots:
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output ); void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
void infoSystemFinished( QString target ); void infoSystemFinished( QString target );
void leftCrumbIndexChanged( QModelIndex ); void leftCrumbIndexChanged( QModelIndex );
private: private:
void setLeftViewArtists( TreeModel* artistModel ); void setLeftViewArtists( TreeModel* artistModel );
void setLeftViewAlbums( AlbumModel* albumModel ); void setLeftViewAlbums( AlbumModel* albumModel );

View File

@@ -85,9 +85,8 @@ GenericPageItem::setText( const QString &text )
bool bool
GenericPageItem::isBeingPlayed() const GenericPageItem::isBeingPlayed() const
{ {
if ( dynamic_cast< PlaylistInterface* >( m_get() ) ) if ( m_get() )
{ return m_get()->isBeingPlayed();
return AudioEngine::instance()->currentTrackPlaylist() == dynamic_cast< PlaylistInterface* >( m_get() );
}
return false; return false;
} }

View File

@@ -20,6 +20,7 @@
#define TEMPORARYPAGEITEM_H #define TEMPORARYPAGEITEM_H
#include "items/sourcetreeitem.h" #include "items/sourcetreeitem.h"
#include "viewpage.h"
class TemporaryPageItem : public SourceTreeItem class TemporaryPageItem : public SourceTreeItem
{ {
@@ -35,6 +36,7 @@ public:
void removeFromList(); void removeFromList();
Tomahawk::ViewPage* page() const { return m_page; } Tomahawk::ViewPage* page() const { return m_page; }
virtual bool isBeingPlayed() const { return m_page->isBeingPlayed(); }
private: private:
Tomahawk::ViewPage* m_page; Tomahawk::ViewPage* m_page;

View File

@@ -140,6 +140,7 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
const bool playable = ( type == SourcesModel::StaticPlaylist || const bool playable = ( type == SourcesModel::StaticPlaylist ||
type == SourcesModel::AutomaticPlaylist || type == SourcesModel::AutomaticPlaylist ||
type == SourcesModel::Station || type == SourcesModel::Station ||
type == SourcesModel::TemporaryPage ||
type == SourcesModel::GenericPage ); type == SourcesModel::GenericPage );
if ( playable && item->isBeingPlayed() ) if ( playable && item->isBeingPlayed() )