mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-15 10:33:59 +02:00
Merge pull request #211 from tomahawk-player/networkactivityplugin
Pluginify NetworkActivity
This commit is contained in:
@@ -4,22 +4,16 @@ set(TOMAHAWK_WIDGETS_LIBRARY_TARGET tomahawk-widgets)
|
||||
list(APPEND ${TOMAHAWK_WIDGETS_LIBRARY_TARGET}_SOURCES
|
||||
PlaylistDelegate.cpp
|
||||
PlaylistWidget.cpp
|
||||
|
||||
# ViewPages
|
||||
NetworkActivityWidget.cpp
|
||||
NetworkActivityWorker.cpp
|
||||
SocialPlaylistWidget.cpp
|
||||
)
|
||||
|
||||
list(APPEND ${TOMAHAWK_WIDGETS_LIBRARY_TARGET}_UI
|
||||
NetworkActivityWidget.ui
|
||||
SocialPlaylistWidget.ui
|
||||
)
|
||||
|
||||
tomahawk_add_library(${TOMAHAWK_WIDGETS_LIBRARY_TARGET}
|
||||
SOURCES ${${TOMAHAWK_WIDGETS_LIBRARY_TARGET}_SOURCES}
|
||||
UI ${${TOMAHAWK_WIDGETS_LIBRARY_TARGET}_UI}
|
||||
QT5_MODULES Concurrent
|
||||
EXPORT TomahawkLibraryDepends
|
||||
VERSION ${TOMAHAWK_VERSION_SHORT}
|
||||
)
|
||||
|
@@ -35,11 +35,13 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual ~ViewPageLazyLoader()
|
||||
{
|
||||
delete m_widget;
|
||||
}
|
||||
|
||||
|
||||
virtual T* widget()
|
||||
{
|
||||
if( !m_widget )
|
||||
@@ -49,6 +51,32 @@ public:
|
||||
}
|
||||
|
||||
|
||||
virtual playlistinterface_ptr playlistInterface() const
|
||||
{
|
||||
if( m_widget )
|
||||
return m_widget->playlistInterface();
|
||||
|
||||
return playlistinterface_ptr();
|
||||
}
|
||||
|
||||
|
||||
virtual bool isBeingPlayed() const
|
||||
{
|
||||
if( m_widget && m_widget->isBeingPlayed() )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
virtual bool jumpToCurrentTrack()
|
||||
{
|
||||
if( m_widget && m_widget->jumpToCurrentTrack() )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
T* m_widget;
|
||||
};
|
||||
|
@@ -29,10 +29,6 @@
|
||||
#include "SourceList.h"
|
||||
#include "TomahawkSqlQuery.h"
|
||||
|
||||
#ifndef ENABLE_HEADLESS
|
||||
#include "ViewManager.h"
|
||||
#endif
|
||||
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlDriver>
|
||||
|
||||
|
@@ -28,7 +28,6 @@
|
||||
#include "Database.h"
|
||||
#include "DatabaseImpl.h"
|
||||
#include "PlaylistEntry.h"
|
||||
#include "ViewManager.h"
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
@@ -720,10 +720,6 @@ defaultPixmap( ImageType type, ImageMode mode, const QSize& size )
|
||||
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/outbox.svg", size );
|
||||
break;
|
||||
|
||||
case NetworkActivity:
|
||||
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/network-activity.svg", size );
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@@ -22,8 +22,6 @@
|
||||
|
||||
#include "../../viewpages/dashboard/Dashboard.h"
|
||||
|
||||
#include <libtomahawk-widgets/NetworkActivityWidget.h>
|
||||
|
||||
#include "sourcetree/items/ScriptCollectionItem.h"
|
||||
#include "sourcetree/items/SourceTreeItem.h"
|
||||
#include "sourcetree/items/SourceItem.h"
|
||||
@@ -340,13 +338,6 @@ SourcesModel::appendGroups()
|
||||
|
||||
endInsertRows();
|
||||
|
||||
ViewManager::instance()->addDynamicPage("network_activity",
|
||||
tr( "Network Activity" ),
|
||||
TomahawkUtils::defaultPixmap( TomahawkUtils::NetworkActivity, TomahawkUtils::Original ),
|
||||
boost::lambda::bind( boost::lambda::new_ptr< Tomahawk::Widgets::NetworkActivityWidget >() ),
|
||||
2
|
||||
);
|
||||
|
||||
QHash< QString, ViewPagePlugin* > plugins = Tomahawk::Utils::PluginLoader( "viewpage" ).loadPlugins< ViewPagePlugin >();
|
||||
foreach ( ViewPagePlugin* plugin, plugins.values() )
|
||||
{
|
||||
|
@@ -200,20 +200,20 @@ DashboardWidget::~DashboardWidget()
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::playlistinterface_ptr
|
||||
Dashboard::playlistInterface() const
|
||||
playlistinterface_ptr
|
||||
DashboardWidget::playlistInterface() const
|
||||
{
|
||||
return m_widget->m_playlistInterface;
|
||||
return m_playlistInterface;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Dashboard::jumpToCurrentTrack()
|
||||
DashboardWidget::jumpToCurrentTrack()
|
||||
{
|
||||
if ( m_widget->ui->tracksView->jumpToCurrentTrack() )
|
||||
if ( ui->tracksView->jumpToCurrentTrack() )
|
||||
return true;
|
||||
|
||||
if ( m_widget->ui->additionsView->jumpToCurrentTrack() )
|
||||
if ( ui->additionsView->jumpToCurrentTrack() )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -221,12 +221,12 @@ Dashboard::jumpToCurrentTrack()
|
||||
|
||||
|
||||
bool
|
||||
Dashboard::isBeingPlayed() const
|
||||
DashboardWidget::isBeingPlayed() const
|
||||
{
|
||||
if ( m_widget->ui->additionsView->isBeingPlayed() )
|
||||
if ( ui->additionsView->isBeingPlayed() )
|
||||
return true;
|
||||
|
||||
return AudioEngine::instance()->currentTrackPlaylist() == m_widget->ui->tracksView->playlistInterface();
|
||||
return AudioEngine::instance()->currentTrackPlaylist() == ui->tracksView->playlistInterface();
|
||||
}
|
||||
|
||||
|
||||
|
@@ -61,6 +61,10 @@ public:
|
||||
DashboardWidget( QWidget* parent = 0 );
|
||||
virtual ~DashboardWidget();
|
||||
|
||||
virtual bool isBeingPlayed() const;
|
||||
virtual playlistinterface_ptr playlistInterface() const;
|
||||
virtual bool jumpToCurrentTrack();
|
||||
|
||||
public slots:
|
||||
void updatePlaylists();
|
||||
void updateRecentAdditions();
|
||||
@@ -92,8 +96,6 @@ public:
|
||||
Dashboard( QWidget* parent = 0 );
|
||||
virtual ~Dashboard();
|
||||
|
||||
virtual Tomahawk::playlistinterface_ptr playlistInterface() const;
|
||||
|
||||
virtual const QString defaultName() { return DASHBOARD_VIEWPAGE_NAME; }
|
||||
virtual QString title() const { return tr( "Dashboard" ); }
|
||||
virtual QString description() const { return tr( "An overview of your recent activity" ); }
|
||||
@@ -102,9 +104,6 @@ public:
|
||||
virtual int sortValue() { return 1; }
|
||||
|
||||
virtual bool showInfoBar() const { return true; }
|
||||
virtual bool isBeingPlayed() const;
|
||||
|
||||
virtual bool jumpToCurrentTrack();
|
||||
};
|
||||
|
||||
|
||||
|
13
src/viewpages/networkactivity/CMakeLists.txt
Normal file
13
src/viewpages/networkactivity/CMakeLists.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
tomahawk_add_plugin(networkactivity
|
||||
TYPE viewpage
|
||||
EXPORT_MACRO TOMAHAWK_VIEWPAGE_EXPORT_PRO
|
||||
SOURCES
|
||||
NetworkActivity.cpp
|
||||
NetworkActivityWidget.cpp
|
||||
NetworkActivityWorker.cpp
|
||||
UI
|
||||
NetworkActivityWidget.ui
|
||||
QT5_MODULES Concurrent
|
||||
LINK_LIBRARIES
|
||||
tomahawk-widgets
|
||||
)
|
21
src/viewpages/networkactivity/NetworkActivity.cpp
Normal file
21
src/viewpages/networkactivity/NetworkActivity.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2013, 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
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include "NetworkActivity.h"
|
||||
|
||||
Q_EXPORT_PLUGIN2( ViewPagePlugin, Tomahawk::Widgets::NetworkActivity )
|
68
src/viewpages/networkactivity/NetworkActivity.h
Normal file
68
src/viewpages/networkactivity/NetworkActivity.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2013, 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
|
||||
* 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 NETWORKACTIVITY_H
|
||||
#define NETWORKACTIVITY_H
|
||||
|
||||
#include "NetworkActivityWidget.h"
|
||||
|
||||
#include "ViewPage.h"
|
||||
#include "ViewPageLazyLoader.h"
|
||||
|
||||
#include "../ViewPageDllMacro.h"
|
||||
|
||||
class AnimatedSpinner;
|
||||
class PlaylistModel;
|
||||
class QModelIndex;
|
||||
class QStandardItemModel;
|
||||
class QSortFilterProxyModel;
|
||||
namespace Ui
|
||||
{
|
||||
class NetworkActivityWidget;
|
||||
}
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
namespace Widgets
|
||||
{
|
||||
|
||||
class NetworkActivityWidgetPrivate;
|
||||
|
||||
class TOMAHAWK_VIEWPAGE_EXPORT NetworkActivity : public Tomahawk::ViewPageLazyLoader< NetworkActivityWidget >
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES( Tomahawk::ViewPagePlugin )
|
||||
|
||||
public:
|
||||
NetworkActivity() {}
|
||||
virtual ~NetworkActivity() {}
|
||||
|
||||
virtual const QString defaultName() { return QLatin1String( "networkactivity" ); }
|
||||
virtual QString title() const { return tr( "Network Activity" ); }
|
||||
virtual QString description() const { return tr( "Listening activity among your friends" ); }
|
||||
virtual const QString pixmapPath() const { return ( RESPATH "images/network-activity.svg" ); }
|
||||
virtual bool showInfoBar() const { return true; }
|
||||
|
||||
virtual int sortValue() { return 2; }
|
||||
};
|
||||
|
||||
} // Widgets
|
||||
|
||||
} // Tomahawk
|
||||
|
||||
#endif // NETWORKACTIVITY_H
|
@@ -18,6 +18,8 @@
|
||||
|
||||
#include "NetworkActivityWidget_p.h"
|
||||
|
||||
#include "libtomahawk-widgets/PlaylistDelegate.h"
|
||||
|
||||
#include "audio/AudioEngine.h"
|
||||
#include "database/Database.h"
|
||||
#include "database/DatabaseCommand_NetworkCharts.h"
|
||||
@@ -38,7 +40,6 @@
|
||||
#include "widgets/RecentlyPlayedPlaylistsModel.h"
|
||||
#include "MetaPlaylistInterface.h"
|
||||
#include "Pipeline.h"
|
||||
#include "PlaylistDelegate.h"
|
||||
#include "ViewManager.h"
|
||||
|
||||
#include <QDateTime>
|
||||
@@ -275,15 +276,6 @@ NetworkActivityWidget::playlistInterface() const
|
||||
}
|
||||
|
||||
|
||||
QPixmap
|
||||
NetworkActivityWidget::pixmap() const
|
||||
{
|
||||
return TomahawkUtils::defaultPixmap( TomahawkUtils::NetworkActivity,
|
||||
TomahawkUtils::Original,
|
||||
TomahawkUtils::DpiScaler::scaled( this, 80, 80 ) );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
NetworkActivityWidget::isBeingPlayed() const
|
||||
{
|
@@ -21,7 +21,7 @@
|
||||
|
||||
#include "ViewPage.h"
|
||||
|
||||
#include "WidgetsDllMacro.h"
|
||||
#include "../ViewPageDllMacro.h"
|
||||
|
||||
class AnimatedSpinner;
|
||||
class PlaylistModel;
|
||||
@@ -40,7 +40,7 @@ namespace Widgets
|
||||
|
||||
class NetworkActivityWidgetPrivate;
|
||||
|
||||
class TOMAHAWK_WIDGETS_EXPORT NetworkActivityWidget : public QWidget, public Tomahawk::ViewPage
|
||||
class TOMAHAWK_VIEWPAGE_EXPORT NetworkActivityWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -57,22 +57,15 @@ public:
|
||||
NetworkActivityWidget(QWidget* parent = 0);
|
||||
~NetworkActivityWidget();
|
||||
|
||||
virtual QWidget* widget() { return this; }
|
||||
virtual Tomahawk::playlistinterface_ptr playlistInterface() const;
|
||||
|
||||
virtual QString title() const { return tr( "Network Activity" ); }
|
||||
virtual QString description() const { return QString("Listening activity among your friends"); }
|
||||
virtual QPixmap pixmap() const;
|
||||
|
||||
virtual bool showInfoBar() const { return true; }
|
||||
virtual bool isBeingPlayed() const;
|
||||
|
||||
virtual bool jumpToCurrentTrack();
|
||||
|
||||
static const uint numberOfHotPlaylists = 3;
|
||||
static const uint numberOfTrendingArtists = 3;
|
||||
static const uint numberOfTrendingTracks = 3;
|
||||
static const uint numberOfNetworkChartEntries = 20;
|
||||
|
||||
// ViewPageWidget interface
|
||||
virtual Tomahawk::playlistinterface_ptr playlistInterface() const;
|
||||
virtual bool isBeingPlayed() const;
|
||||
virtual bool jumpToCurrentTrack();
|
||||
|
||||
protected:
|
||||
QScopedPointer<NetworkActivityWidgetPrivate> d_ptr;
|
@@ -190,7 +190,7 @@
|
||||
<customwidget>
|
||||
<class>Tomahawk::Widgets::PlaylistWidget</class>
|
||||
<extends>QListWidget</extends>
|
||||
<header>PlaylistWidget.h</header>
|
||||
<header>libtomahawk-widgets/PlaylistWidget.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Tomahawk::Breadcrumb</class>
|
Reference in New Issue
Block a user