mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 15:59:42 +01:00
Allow artist pages to have a random/repeat mode
This commit is contained in:
parent
af5211aada
commit
4ad6b2bebf
@ -447,6 +447,7 @@ set( libHeaders
|
||||
widgets/SocialPlaylistWidget.h
|
||||
widgets/infowidgets/sourceinfowidget.h
|
||||
widgets/infowidgets/ArtistInfoWidget.h
|
||||
widgets/infowidgets/ArtistInfoWidget_p.h
|
||||
widgets/infowidgets/AlbumInfoWidget.h
|
||||
widgets/Breadcrumb.h
|
||||
widgets/BreadcrumbButton.h
|
||||
|
@ -88,6 +88,12 @@ AlbumInfoWidget::~AlbumInfoWidget()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
PlaylistInterface*
|
||||
AlbumInfoWidget::playlistInterface() const
|
||||
{
|
||||
return ui->tracksView->playlistInterface();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AlbumInfoWidget::onModeToggle()
|
||||
|
@ -64,7 +64,7 @@ public:
|
||||
void load( const Tomahawk::album_ptr& album );
|
||||
|
||||
virtual QWidget* widget() { return this; }
|
||||
virtual Tomahawk::PlaylistInterface* playlistInterface() const { return 0; }
|
||||
virtual Tomahawk::PlaylistInterface* playlistInterface() const;
|
||||
|
||||
virtual QString title() const { return m_title; }
|
||||
virtual QString description() const { return m_description; }
|
||||
|
@ -17,12 +17,14 @@
|
||||
*/
|
||||
|
||||
#include "ArtistInfoWidget.h"
|
||||
#include "ArtistInfoWidget_p.h"
|
||||
#include "ui_ArtistInfoWidget.h"
|
||||
|
||||
#include "audio/audioengine.h"
|
||||
#include "viewmanager.h"
|
||||
#include "playlist/treemodel.h"
|
||||
#include "playlist/playlistmodel.h"
|
||||
#include "playlist/treeproxymodel.h"
|
||||
|
||||
#include "database/databasecommand_alltracks.h"
|
||||
#include "database/databasecommand_allalbums.h"
|
||||
@ -45,6 +47,8 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
|
||||
{
|
||||
ui->setupUi( this );
|
||||
|
||||
m_plInterface = new MetaPlaylistInterface( this );
|
||||
|
||||
ui->albums->setFrameShape( QFrame::NoFrame );
|
||||
ui->albums->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
||||
ui->relatedArtists->setFrameShape( QFrame::NoFrame );
|
||||
@ -93,9 +97,16 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
|
||||
|
||||
ArtistInfoWidget::~ArtistInfoWidget()
|
||||
{
|
||||
delete m_plInterface;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
PlaylistInterface*
|
||||
ArtistInfoWidget::playlistInterface() const
|
||||
{
|
||||
return m_plInterface;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ArtistInfoWidget::onModeToggle()
|
||||
|
@ -47,6 +47,8 @@ namespace Ui
|
||||
class ArtistInfoWidget;
|
||||
}
|
||||
|
||||
class MetaPlaylistInterface;
|
||||
|
||||
class DLLEXPORT ArtistInfoWidget : public QWidget, public Tomahawk::ViewPage
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -66,7 +68,7 @@ public:
|
||||
void load( const Tomahawk::artist_ptr& artist );
|
||||
|
||||
virtual QWidget* widget() { return this; }
|
||||
virtual Tomahawk::PlaylistInterface* playlistInterface() const { return 0; }
|
||||
virtual Tomahawk::PlaylistInterface* playlistInterface() const;
|
||||
|
||||
virtual QString title() const { return m_title; }
|
||||
virtual QString description() const { return m_description; }
|
||||
@ -103,6 +105,7 @@ private:
|
||||
TreeModel* m_relatedModel;
|
||||
TreeModel* m_albumsModel;
|
||||
PlaylistModel* m_topHitsModel;
|
||||
MetaPlaylistInterface* m_plInterface;
|
||||
|
||||
OverlayButton* m_button;
|
||||
|
||||
@ -111,6 +114,8 @@ private:
|
||||
QString m_longDescription;
|
||||
QString m_infoId;
|
||||
QPixmap m_pixmap;
|
||||
|
||||
friend class MetaPlaylistInterface;
|
||||
};
|
||||
|
||||
#endif // ARTISTINFOWIDGET_H
|
||||
|
106
src/libtomahawk/widgets/infowidgets/ArtistInfoWidget_p.h
Normal file
106
src/libtomahawk/widgets/infowidgets/ArtistInfoWidget_p.h
Normal file
@ -0,0 +1,106 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2011, 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef ARTISTINFOWIDGET_P_H
|
||||
#define ARTISTINFOWIDGET_P_H
|
||||
|
||||
#include "ArtistInfoWidget.h"
|
||||
#include "ui_ArtistInfoWidget.h"
|
||||
#include "playlistinterface.h"
|
||||
#include "treeproxymodel.h"
|
||||
#include "result.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class MetaPlaylistInterface : public QObject, public Tomahawk::PlaylistInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MetaPlaylistInterface( ArtistInfoWidget* w )
|
||||
: PlaylistInterface( this )
|
||||
, m_w( w )
|
||||
{
|
||||
connect( m_w->ui->albums->proxyModel(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ),
|
||||
SLOT( anyRepeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ) );
|
||||
connect( m_w->ui->relatedArtists->proxyModel(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ),
|
||||
SLOT( anyRepeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ) );
|
||||
connect( m_w->ui->topHits->proxyModel(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ),
|
||||
SLOT( anyRepeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ) );
|
||||
|
||||
connect( m_w->ui->albums->proxyModel(), SIGNAL( shuffleModeChanged( bool ) ),
|
||||
SLOT( anyShuffleChanged( bool ) ) );
|
||||
connect( m_w->ui->relatedArtists->proxyModel(), SIGNAL( shuffleModeChanged( bool ) ),
|
||||
SLOT( anyShuffleChanged( bool ) ) );
|
||||
connect( m_w->ui->topHits->proxyModel(), SIGNAL( shuffleModeChanged( bool ) ),
|
||||
SLOT( anyShuffleChanged( bool ) ) );
|
||||
}
|
||||
virtual ~MetaPlaylistInterface() {}
|
||||
|
||||
|
||||
// Any one is fine, we keep them all synched
|
||||
virtual RepeatMode repeatMode() const { return m_w->ui->albums->proxyModel()->repeatMode(); }
|
||||
|
||||
virtual bool shuffled() const { return m_w->ui->albums->proxyModel()->shuffled(); }
|
||||
|
||||
// Do nothing
|
||||
virtual Tomahawk::result_ptr currentItem() const { return Tomahawk::result_ptr(); }
|
||||
virtual Tomahawk::result_ptr siblingItem( int ) { return Tomahawk::result_ptr(); }
|
||||
virtual int trackCount() const { return 0; }
|
||||
virtual QList< Tomahawk::query_ptr > tracks() { return QList< Tomahawk::query_ptr >(); }
|
||||
virtual int unfilteredTrackCount() const { return 0; }
|
||||
|
||||
public slots:
|
||||
virtual void setRepeatMode( RepeatMode mode )
|
||||
{
|
||||
m_w->ui->albums->proxyModel()->setRepeatMode( mode );
|
||||
m_w->ui->relatedArtists->proxyModel()->setRepeatMode( mode );
|
||||
m_w->ui->topHits->proxyModel()->setRepeatMode( mode );
|
||||
}
|
||||
|
||||
virtual void setShuffled( bool enabled )
|
||||
{
|
||||
m_w->ui->albums->proxyModel()->setShuffled( enabled );
|
||||
m_w->ui->relatedArtists->proxyModel()->setShuffled( enabled );
|
||||
m_w->ui->topHits->proxyModel()->setShuffled( enabled );
|
||||
}
|
||||
|
||||
signals:
|
||||
void repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode );
|
||||
void shuffleModeChanged( bool enabled );
|
||||
|
||||
void trackCountChanged( unsigned int tracks );
|
||||
void sourceTrackCountChanged( unsigned int tracks );
|
||||
void nextTrackReady();
|
||||
|
||||
private slots:
|
||||
void anyRepeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode )
|
||||
{
|
||||
emit repeatModeChanged( mode );
|
||||
}
|
||||
|
||||
void anyShuffleChanged( bool enabled )
|
||||
{
|
||||
emit shuffleModeChanged( enabled );
|
||||
}
|
||||
|
||||
private:
|
||||
ArtistInfoWidget* m_w;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user