1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-09-01 01:51:58 +02:00

Move NetworkActivityWidget to libtomahawk-widgets

This commit is contained in:
Dominik Schmidt
2013-06-30 22:06:55 +02:00
parent 1f66489755
commit 62f1fde90a
13 changed files with 183 additions and 41 deletions

View File

@@ -159,7 +159,6 @@ set( libGuiSources
widgets/PlayableCover.cpp
widgets/SocialPlaylistWidget.cpp
widgets/SourceTreePopupDialog.cpp
widgets/NetworkActivityWidget.cpp
widgets/infowidgets/SourceInfoWidget.cpp
widgets/infowidgets/ArtistInfoWidget.cpp
widgets/infowidgets/AlbumInfoWidget.cpp
@@ -379,7 +378,6 @@ set( libUI ${libUI}
widgets/WhatsHotWidget.ui
widgets/NewReleasesWidget.ui
widgets/SocialPlaylistWidget.ui
widgets/NetworkActivityWidget.ui
widgets/infowidgets/SourceInfoWidget.ui
widgets/infowidgets/ArtistInfoWidget.ui
widgets/infowidgets/AlbumInfoWidget.ui
@@ -524,6 +522,8 @@ TARGET_LINK_LIBRARIES( tomahawklib
${LINK_LIBRARIES}
)
add_subdirectory( widgets )
INSTALL( TARGETS tomahawklib
EXPORT TomahawkLibraryDepends
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}

View File

@@ -49,7 +49,6 @@
#include "widgets/NewReleasesWidget.h"
#include "widgets/Dashboard.h"
#include "widgets/WhatsHotWidget.h"
#include "widgets/NetworkActivityWidget.h"
#include "widgets/infowidgets/SourceInfoWidget.h"
#include "widgets/infowidgets/ArtistInfoWidget.h"
#include "widgets/infowidgets/AlbumInfoWidget.h"
@@ -85,7 +84,6 @@ ViewManager::ViewManager( QObject* parent )
, m_newReleasesWidget( 0 )
, m_recentPlaysWidget( 0 )
, m_inboxWidget( 0 )
, m_networkActivityWidget( 0 )
, m_currentPage( 0 )
{
s_instance = this;
@@ -130,7 +128,6 @@ ViewManager::ViewManager( QObject* parent )
ViewManager::~ViewManager()
{
delete m_networkActivityWidget;
delete m_whatsHotWidget;
delete m_newReleasesWidget;
delete m_dashboard;
@@ -495,17 +492,6 @@ ViewManager::showInboxPage()
}
ViewPage *ViewManager::showNetworkActivityPage()
{
if ( !m_networkActivityWidget )
{
m_networkActivityWidget = new NetworkActivityWidget( m_widget );
}
return show( m_networkActivityWidget );
}
void
ViewManager::setFilter( const QString& filter )
{
@@ -896,11 +882,6 @@ ViewManager::inboxWidget() const
return m_inboxWidget;
}
ViewPage *ViewManager::networkActivityWidget() const
{
return m_networkActivityWidget;
}
ViewPage*
ViewManager::dynamicPageWidget( const QString& pageName ) const
@@ -941,7 +922,11 @@ ViewManager::showDynamicPage( const QString& pageName )
Q_ASSERT(false);
return 0;
}
m_dynamicPages.insert( pageName, m_dynamicPagesInstanceLoaders.value( pageName )() );
ViewPage* viewPage = m_dynamicPagesInstanceLoaders.value( pageName )();
Q_ASSERT(viewPage);
m_dynamicPages.insert( pageName, viewPage );
m_dynamicPagesInstanceLoaders.remove( pageName );
}

View File

@@ -60,7 +60,6 @@ class Dashboard;
class WhatsHotWidget;
class QPushButton;
class InboxModel;
class NetworkActivityWidget;
namespace Tomahawk
{
@@ -99,7 +98,6 @@ public:
Tomahawk::ViewPage* recentPlaysWidget() const;
Tomahawk::ViewPage* superCollectionView() const;
Tomahawk::ViewPage* inboxWidget() const;
Tomahawk::ViewPage* networkActivityWidget() const;
Tomahawk::ViewPage* dynamicPageWidget( const QString& pageName ) const;
@@ -145,7 +143,6 @@ public slots:
Tomahawk::ViewPage* showNewReleasesPage();
Tomahawk::ViewPage* showRecentPlaysPage();
Tomahawk::ViewPage* showInboxPage();
Tomahawk::ViewPage* showNetworkActivityPage();
void addDynamicPage( const QString& pageName, const QString& text, const QIcon& icon, boost::function< Tomahawk::ViewPage*() > instanceLoader );
Tomahawk::ViewPage* showDynamicPage( const QString& pageName );
@@ -201,7 +198,6 @@ private:
Tomahawk::ViewPage* m_recentPlaysWidget;
Tomahawk::ViewPage* m_inboxWidget;
InboxModel* m_inboxModel;
NetworkActivityWidget* m_networkActivityWidget;
QHash< QString, Tomahawk::ViewPage* > m_dynamicPages;
QHash< QString, boost::function< Tomahawk::ViewPage*() > > m_dynamicPagesInstanceLoaders;

View File

@@ -39,7 +39,11 @@ class BreadcrumbButton;
* Items that have a DefaultRole set will automatically select the default unless the user has
* made a previous selection, which is saved in the UserSelection role
*/
class Breadcrumb : public QWidget
//HACK: I'm exporting this, so I can move view pages to libtomahawk-widgets one by one
//TODO: In the end this class should go there too (and be made private again?)
#include "../DllMacro.h"
class DLLEXPORT Breadcrumb : public QWidget
{
Q_OBJECT
public:

View File

@@ -0,0 +1,17 @@
set(TOMAHAWK_WIDGETS_LIBRARY_TARGET tomahawk-widgets)
list(APPEND ${TOMAHAWK_WIDGETS_LIBRARY_TARGET}_SOURCES
NetworkActivityWidget.cpp
)
list(APPEND ${TOMAHAWK_WIDGETS_LIBRARY_TARGET}_UI
NetworkActivityWidget.ui
)
tomahawk_add_library(${TOMAHAWK_WIDGETS_LIBRARY_TARGET}
SOURCES ${${TOMAHAWK_WIDGETS_LIBRARY_TARGET}_SOURCES}
UI ${${TOMAHAWK_WIDGETS_LIBRARY_TARGET}_UI}
EXPORT TomahawkLibraryDepends
VERSION ${TOMAHAWK_VERSION_SHORT}
)

View File

@@ -21,6 +21,8 @@
#include "ViewPage.h"
#include "WidgetsDllMacro.h"
class AnimatedSpinner;
class NetworkActivityWidgetPrivate;
class PlaylistModel;
@@ -32,7 +34,7 @@ namespace Ui
class NetworkActivityWidget;
}
class NetworkActivityWidget : public QWidget, public Tomahawk::ViewPage
class TOMAHAWK_WIDGETS_EXPORT NetworkActivityWidget : public QWidget, public Tomahawk::ViewPage
{
Q_OBJECT
public:

View File

@@ -0,0 +1,33 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.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 WIDGETSDLLMACRO_H
#define WIDGETSDLLMACRO_H
#include <QtCore/qglobal.h>
#ifndef TOMAHAWK_WIDGETS_EXPORT
# if defined (tomahawk_widgets_EXPORTS)
# define TOMAHAWK_WIDGETS_EXPORT Q_DECL_EXPORT
# else
# define TOMAHAWK_WIDGETS_EXPORT Q_DECL_IMPORT
# endif
#endif
#endif // WIDGETSDLLMACRO_H

View File

@@ -187,6 +187,7 @@ ENDIF()
TARGET_LINK_LIBRARIES( tomahawk
${LINK_LIBRARIES}
${TOMAHAWK_WIDGETS_LIBRARIES}
${TOMAHAWK_LIBRARIES}
${PHONON_LIBS}
${OS_SPECIFIC_LINK_LIBRARIES}

View File

@@ -20,11 +20,6 @@
#include "sourcetree/SourcesModel.h"
#include <QMimeData>
#include <QSize>
#include <boost/bind.hpp>
#include "sourcetree/items/ScriptCollectionItem.h"
#include "sourcetree/items/SourceTreeItem.h"
#include "sourcetree/items/SourceItem.h"
@@ -38,6 +33,7 @@
#include "collection/Collection.h"
#include "Source.h"
#include "ViewManager.h"
#include "widgets/NetworkActivityWidget.h"
#include "GlobalActionManager.h"
#include "DropJob.h"
#include "items/PlaylistItems.h"
@@ -47,6 +43,13 @@
#include "utils/ImageRegistry.h"
#include "utils/Logger.h"
#include <QMimeData>
#include <QSize>
#include <boost/bind.hpp>
#include <boost/lambda/construct.hpp>
#include <boost/lambda/bind.hpp>
using namespace Tomahawk;
@@ -57,6 +60,7 @@ SourcesModel::SourcesModel( QObject* parent )
{
m_rootItem = new SourceTreeItem( this, 0, Invalid );
connect( ViewManager::instance(), SIGNAL( viewPageAdded( QString, QString, QIcon ) ), SLOT( appendPageItem( QString, QString, QIcon ) ) );
appendGroups();
onSourcesAdded( SourceList::instance()->sources() );
@@ -77,9 +81,6 @@ SourcesModel::SourcesModel( QObject* parent )
this, SLOT( onScriptCollectionAdded( Tomahawk::collection_ptr ) ) );
connect( SourceList::instance(), SIGNAL( scriptCollectionRemoved( Tomahawk::collection_ptr ) ),
this, SLOT( onScriptCollectionRemoved( Tomahawk::collection_ptr ) ) );
connect( ViewManager::instance(), SIGNAL( viewPageAdded( QString, QString, QIcon ) ), SLOT( appendPageItem( QString, QString, QIcon ) ) );
}
@@ -316,11 +317,6 @@ SourcesModel::appendGroups()
LovedTracksItem* loved = new LovedTracksItem( this, m_browse );
loved->setSortValue( 2 );
GenericPageItem* networkActivity = new GenericPageItem( this, m_browse, tr( "Network Activity" ), TomahawkUtils::defaultPixmap( TomahawkUtils::NetworkActivity, TomahawkUtils::Original ),
boost::bind( &ViewManager::showNetworkActivityPage, ViewManager::instance() ),
boost::bind( &ViewManager::networkActivityWidget, ViewManager::instance() ) );
networkActivity->setSortValue( 3 );
GenericPageItem* recent = new GenericPageItem( this, m_browse, tr( "Recently Played" ), ImageRegistry::instance()->icon( RESPATH "images/recently-played.svg" ),
boost::bind( &ViewManager::showRecentPlaysPage, ViewManager::instance() ),
boost::bind( &ViewManager::recentPlaysWidget, ViewManager::instance() ) );
@@ -345,6 +341,13 @@ SourcesModel::appendGroups()
m_cloudGroup = new GroupItem( this, m_rootItem, tr( "Cloud" ), 5 );
endInsertRows();
// addDynamicPage takes care of begin/endInsertRows itself
ViewManager::instance()->addDynamicPage("network_activity",
tr( "Network Activity" ),
TomahawkUtils::defaultPixmap( TomahawkUtils::NetworkActivity, TomahawkUtils::Original ),
boost::lambda::bind( boost::lambda::new_ptr< NetworkActivityWidget >() )
);
}
void