1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 19:30:21 +02:00

Move WhatsHot viewpage into its own plugin

This commit is contained in:
Uwe L. Korn
2014-06-29 21:23:34 +01:00
parent 8bc19507b4
commit 8536ed2622
9 changed files with 70 additions and 55 deletions

View File

@@ -163,7 +163,6 @@ set( libGuiSources
widgets/SourceTreePopupDialog.cpp
widgets/StatsGauge.cpp
widgets/ToggleButton.cpp
widgets/WhatsHotWidget.cpp
widgets/infowidgets/SourceInfoWidget.cpp
widgets/infowidgets/ArtistInfoWidget.cpp
widgets/infowidgets/AlbumInfoWidget.cpp
@@ -389,7 +388,6 @@ set( libUI ${libUI}
widgets/PlaylistTypeSelectorDialog.ui
widgets/NewPlaylistWidget.ui
widgets/SearchWidget.ui
widgets/WhatsHotWidget.ui
widgets/NewReleasesWidget.ui
widgets/infowidgets/SourceInfoWidget.ui
widgets/infowidgets/ArtistInfoWidget.ui

View File

@@ -47,7 +47,6 @@
#include "playlist/dynamic/widgets/DynamicWidget.h"
#include "widgets/NewReleasesWidget.h"
#include "widgets/WhatsHotWidget.h"
#include "widgets/infowidgets/SourceInfoWidget.h"
#include "widgets/infowidgets/ArtistInfoWidget.h"
#include "widgets/infowidgets/AlbumInfoWidget.h"
@@ -79,7 +78,6 @@ ViewManager::instance()
ViewManager::ViewManager( QObject* parent )
: QObject( parent )
, m_widget( new QWidget() )
, m_whatsHotWidget( 0 )
, m_newReleasesWidget( 0 )
, m_recentPlaysWidget( 0 )
, m_inboxWidget( 0 )
@@ -127,7 +125,6 @@ ViewManager::ViewManager( QObject* parent )
ViewManager::~ViewManager()
{
delete m_whatsHotWidget;
delete m_newReleasesWidget;
delete m_recentPlaysWidget;
delete m_inboxWidget;
@@ -398,19 +395,6 @@ ViewManager::playlistInterfaceChanged( Tomahawk::playlistinterface_ptr interface
}
Tomahawk::ViewPage*
ViewManager::showWhatsHotPage()
{
if ( !m_whatsHotWidget )
{
m_whatsHotWidget = new WhatsHotWidget();
m_whatsHotWidget->fetchData();
}
return show( m_whatsHotWidget );
}
Tomahawk::ViewPage*
ViewManager::showNewReleasesPage()
{
@@ -850,13 +834,6 @@ ViewManager::showCurrentTrack()
}
Tomahawk::ViewPage*
ViewManager::whatsHotWidget() const
{
return m_whatsHotWidget;
}
Tomahawk::ViewPage*
ViewManager::newReleasesWidget() const
{

View File

@@ -57,7 +57,6 @@ class SourceInfoWidget;
class InfoBar;
class TrackInfoWidget;
class NewReleasesWidget;
class WhatsHotWidget;
class QPushButton;
class InboxModel;
@@ -92,7 +91,6 @@ public:
Tomahawk::ViewPage* show( Tomahawk::ViewPage* page );
Tomahawk::ViewPage* whatsHotWidget() const;
Tomahawk::ViewPage* newReleasesWidget() const;
Tomahawk::ViewPage* recentPlaysWidget() const;
Tomahawk::ViewPage* superCollectionView() const;
@@ -139,7 +137,6 @@ signals:
public slots:
Tomahawk::ViewPage* showSuperCollection();
Tomahawk::ViewPage* showWhatsHotPage();
Tomahawk::ViewPage* showNewReleasesPage();
Tomahawk::ViewPage* showRecentPlaysPage();
Tomahawk::ViewPage* showInboxPage();
@@ -193,7 +190,6 @@ private:
TreeModel* m_superCollectionModel;
TreeWidget* m_superCollectionView;
QueueView* m_queue;
WhatsHotWidget* m_whatsHotWidget;
NewReleasesWidget* m_newReleasesWidget;
Tomahawk::ViewPage* m_recentPlaysWidget;
Tomahawk::ViewPage* m_inboxWidget;

View File

@@ -33,7 +33,7 @@ namespace Tomahawk
into their respective tomahawk types. Move this object to a thread
and listen to the result signals.
*/
class ChartDataLoader : public QObject
class DLLEXPORT ChartDataLoader : public QObject
{
Q_OBJECT
public:

View File

@@ -312,11 +312,6 @@ SourcesModel::appendGroups()
boost::bind( &ViewManager::superCollectionView, ViewManager::instance() ) );
sc->setSortValue( 4 );*/
GenericPageItem* hot = new GenericPageItem( this, m_browse, tr( "Charts" ), ImageRegistry::instance()->icon( RESPATH "images/charts.svg" ),
boost::bind( &ViewManager::showWhatsHotPage, ViewManager::instance() ),
boost::bind( &ViewManager::whatsHotWidget, ViewManager::instance() ) );
hot->setSortValue( 5 );
GenericPageItem* newReleases = new GenericPageItem( this, m_browse, tr( "New Releases" ), ImageRegistry::instance()->icon( RESPATH "images/new-releases.svg" ),
boost::bind( &ViewManager::showNewReleasesPage, ViewManager::instance() ),
boost::bind( &ViewManager::newReleasesWidget, ViewManager::instance() ) );

View File

@@ -0,0 +1,10 @@
tomahawk_add_plugin(whatshot
TYPE viewpage
EXPORT_MACRO TOMAHAWK_VIEWPAGE_EXPORT_PRO
SOURCES
WhatsHotWidget.cpp
UI
WhatsHotWidget.ui
LINK_LIBRARIES
tomahawk-widgets
)

View File

@@ -4,6 +4,7 @@
* Copyright 2011, Leo Franchi <lfranchi@kde.org>
* Copyright 2011, Jeff Mitchell <jeff@tomahawk-player.org>
* Copyright 2012, Hugo Lindström <hugolm84@gmail.com>
* Copyright 2014, Uwe L. Korn <uwelk@xhochy.com>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -25,9 +26,8 @@
#include "ViewManager.h"
#include "SourceList.h"
#include "TomahawkSettings.h"
#include "RecentPlaylistsModel.h"
#include "ChartDataLoader.h"
#include "MetaPlaylistInterface.h"
#include "Pipeline.h"
#include "audio/AudioEngine.h"
#include "playlist/dynamic/GeneratorInterface.h"
@@ -35,9 +35,9 @@
#include "playlist/PlaylistModel.h"
#include "playlist/TreeProxyModel.h"
#include "playlist/PlaylistChartItemDelegate.h"
#include "widgets/ChartDataLoader.h"
#include "utils/TomahawkUtilsGui.h"
#include "utils/Logger.h"
#include "Pipeline.h"
#include "utils/AnimatedSpinner.h"
#include <QPainter>
@@ -50,6 +50,7 @@
#define HISTORY_RESOLVING_TIMEOUT 2500
using namespace Tomahawk;
using namespace Tomahawk::Widgets;
static QString s_whatsHotIdentifier = QString( "WhatsHotWidget" );
@@ -119,6 +120,8 @@ WhatsHotWidget::WhatsHotWidget( QWidget* parent )
ui->stackLeft->setCurrentIndex( 2 );
m_spinner = new AnimatedSpinner( ui->albumsView );
m_spinner->fadeIn();
fetchData();
}
@@ -622,3 +625,14 @@ WhatsHotWidget::chartAlbumsLoaded( ChartDataLoader* loader, const QList< album_p
m_workers.remove( loader );
loader->deleteLater();
}
WhatsHot::WhatsHot( QWidget* parent )
{
Q_UNUSED( parent )
}
WhatsHot::~WhatsHot()
{
}

View File

@@ -3,6 +3,7 @@
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2011, Leo Franchi <lfranchi@kde.org>
* Copyright 2011, Jeff Mitchell <jeff@tomahawk-player.org>
* Copyright 2014, Uwe L. Korn <uwelk@xhochy.com>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,13 +24,10 @@
#include "PlaylistInterface.h"
#include "infosystem/InfoSystem.h"
#include "ViewPage.h"
#include "../ViewPageDllMacro.h"
#include "ViewPagePlugin.h"
#include "ViewPageLazyLoader.h"
#include "DllMacro.h"
#include <QWidget>
#include <QListWidgetItem>
#include <QStyledItemDelegate>
class QSortFilterProxyModel;
class QStandardItemModel;
@@ -39,6 +37,7 @@ class PlaylistModel;
class TreeProxyModel;
class PlayableModel;
class AnimatedSpinner;
namespace Ui
{
class WhatsHotWidget;
@@ -51,11 +50,17 @@ namespace Tomahawk
class ChartDataLoader;
}
namespace Tomahawk
{
namespace Widgets
{
/**
* \class
* \brief The tomahawk page that shows music charts.
*/
class DLLEXPORT WhatsHotWidget : public QWidget, public Tomahawk::ViewPage
class DLLEXPORT WhatsHotWidget : public QWidget
{
Q_OBJECT
@@ -63,16 +68,9 @@ public:
WhatsHotWidget( QWidget* parent = 0 );
~WhatsHotWidget();
virtual QWidget* widget() { return this; }
virtual Tomahawk::playlistinterface_ptr playlistInterface() const;
virtual QString title() const { return tr( "Charts" ); }
virtual QString description() const { return QString(); }
virtual bool showInfoBar() const { return false; }
virtual bool isBeingPlayed() const;
virtual bool jumpToCurrentTrack();
Tomahawk::playlistinterface_ptr playlistInterface() const;
bool isBeingPlayed() const;
bool jumpToCurrentTrack();
protected:
void changeEvent( QEvent* e );
@@ -125,4 +123,31 @@ private:
friend class Tomahawk::ChartsPlaylistInterface;
};
const QString WHATSHOT_VIEWPAGE_NAME = "whatshot";
class TOMAHAWK_VIEWPAGE_EXPORT WhatsHot : public Tomahawk::ViewPageLazyLoader< WhatsHotWidget >
{
Q_OBJECT
Q_INTERFACES( Tomahawk::ViewPagePlugin )
Q_PLUGIN_METADATA( IID "org.tomahawk-player.Player.ViewPagePlugin" )
public:
WhatsHot( QWidget* parent = 0 );
virtual ~WhatsHot();
const QString defaultName() Q_DECL_OVERRIDE { return WHATSHOT_VIEWPAGE_NAME; }
QString title() const Q_DECL_OVERRIDE { return tr( "Charts" ); }
QString description() const Q_DECL_OVERRIDE { return QString(); }
const QString pixmapPath() const Q_DECL_OVERRIDE { return ( RESPATH "images/charts.svg" ); }
int sortValue() Q_DECL_OVERRIDE { return 5; }
bool showInfoBar() const Q_DECL_OVERRIDE { return false; }
};
} // Widgets
} // Tomahawk
#endif // WHATSHOTWIDGET_H