diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index f5b34a695..d61ceba05 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -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 diff --git a/src/libtomahawk/ViewManager.cpp b/src/libtomahawk/ViewManager.cpp index f33c8039d..3a29e9b27 100644 --- a/src/libtomahawk/ViewManager.cpp +++ b/src/libtomahawk/ViewManager.cpp @@ -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 { diff --git a/src/libtomahawk/ViewManager.h b/src/libtomahawk/ViewManager.h index 0a7ad623f..1351f0817 100644 --- a/src/libtomahawk/ViewManager.h +++ b/src/libtomahawk/ViewManager.h @@ -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; diff --git a/src/libtomahawk/widgets/ChartDataLoader.h b/src/libtomahawk/widgets/ChartDataLoader.h index e8afa80bb..8644044d1 100644 --- a/src/libtomahawk/widgets/ChartDataLoader.h +++ b/src/libtomahawk/widgets/ChartDataLoader.h @@ -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: diff --git a/src/tomahawk/sourcetree/SourcesModel.cpp b/src/tomahawk/sourcetree/SourcesModel.cpp index b1f40bbc9..81b74be9a 100644 --- a/src/tomahawk/sourcetree/SourcesModel.cpp +++ b/src/tomahawk/sourcetree/SourcesModel.cpp @@ -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() ) ); diff --git a/src/viewpages/whatshot/CMakeLists.txt b/src/viewpages/whatshot/CMakeLists.txt new file mode 100644 index 000000000..74dea6008 --- /dev/null +++ b/src/viewpages/whatshot/CMakeLists.txt @@ -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 +) diff --git a/src/libtomahawk/widgets/WhatsHotWidget.cpp b/src/viewpages/whatshot/WhatsHotWidget.cpp similarity index 98% rename from src/libtomahawk/widgets/WhatsHotWidget.cpp rename to src/viewpages/whatshot/WhatsHotWidget.cpp index 3c012c60f..69e72d2fc 100644 --- a/src/libtomahawk/widgets/WhatsHotWidget.cpp +++ b/src/viewpages/whatshot/WhatsHotWidget.cpp @@ -4,6 +4,7 @@ * Copyright 2011, Leo Franchi * Copyright 2011, Jeff Mitchell * Copyright 2012, Hugo Lindström + * Copyright 2014, Uwe L. Korn * * 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 @@ -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() +{ +} diff --git a/src/libtomahawk/widgets/WhatsHotWidget.h b/src/viewpages/whatshot/WhatsHotWidget.h similarity index 74% rename from src/libtomahawk/widgets/WhatsHotWidget.h rename to src/viewpages/whatshot/WhatsHotWidget.h index ea90c309b..71ee7aa3e 100644 --- a/src/libtomahawk/widgets/WhatsHotWidget.h +++ b/src/viewpages/whatshot/WhatsHotWidget.h @@ -3,6 +3,7 @@ * Copyright 2010-2011, Christian Muehlhaeuser * Copyright 2011, Leo Franchi * Copyright 2011, Jeff Mitchell + * Copyright 2014, Uwe L. Korn * * 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 -#include -#include 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 diff --git a/src/libtomahawk/widgets/WhatsHotWidget.ui b/src/viewpages/whatshot/WhatsHotWidget.ui similarity index 100% rename from src/libtomahawk/widgets/WhatsHotWidget.ui rename to src/viewpages/whatshot/WhatsHotWidget.ui