1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-11 00:24:12 +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

@@ -316,6 +316,7 @@ IF( NOT APPLE )
ENDIF( NOT APPLE ) ENDIF( NOT APPLE )
SET( TOMAHAWK_LIBRARIES tomahawklib ) SET( TOMAHAWK_LIBRARIES tomahawklib )
SET( TOMAHAWK_WIDGETS_LIBRARIES tomahawk-widgets )
ADD_SUBDIRECTORY( thirdparty ) ADD_SUBDIRECTORY( thirdparty )
ADD_SUBDIRECTORY( src ) ADD_SUBDIRECTORY( src )

View File

@@ -276,6 +276,8 @@ Section "Tomahawk Player" SEC_TOMAHAWK_PLAYER
File "${INSTALL_PATH}\bin\tomahawk_crash_reporter.exe" File "${INSTALL_PATH}\bin\tomahawk_crash_reporter.exe"
File "${INSTALL_PATH}\bin\libtomahawk.dll" File "${INSTALL_PATH}\bin\libtomahawk.dll"
File "${INSTALL_PATH}\bin\libtomahawk-widgets.dll"
; plugins ; plugins
File "${INSTALL_PATH}\lib\libtomahawk_*_*.dll" File "${INSTALL_PATH}\lib\libtomahawk_*_*.dll"
!endif !endif
@@ -286,6 +288,8 @@ Section "Tomahawk Player" SEC_TOMAHAWK_PLAYER
File "${BUILD_PATH}\tomahawk_crash_reporter.exe" File "${BUILD_PATH}\tomahawk_crash_reporter.exe"
File "${BUILD_PATH}\libtomahawk.dll" File "${BUILD_PATH}\libtomahawk.dll"
File "${BUILD_PATH}\libtomahawk-widgets.dll"
; plugins ; plugins
File "${BUILD_PATH}\libtomahawk_*_*.dll" File "${BUILD_PATH}\libtomahawk_*_*.dll"
!endif !endif

94
TomahawkAddLibrary.cmake Normal file
View File

@@ -0,0 +1,94 @@
include( CMakeParseArguments )
function(tomahawk_add_library)
# parse arguments (name needs to be saved before passing ARGN into the macro)
set(NAME ${ARGV0})
set(options NO_INSTALL NO_VERSION)
set(oneValueArgs NAME TYPE EXPORT_MACRO TARGET TARGET_TYPE EXPORT VERSION SOVERSION)
set(multiValueArgs SOURCES UI LINK_LIBRARIES COMPILE_DEFINITIONS)
cmake_parse_arguments(LIBRARY "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(LIBRARY_NAME ${NAME})
# message("*** Arguments for ${LIBRARY_NAME}")
# message("Sources: ${LIBRARY_SOURCES}")
# message("Link libraries: ${LIBRARY_LINK_LIBRARIES}")
# message("UI: ${LIBRARY_UI}")
# message("TARGET_TYPE: ${LIBRARY_TARGET_TYPE}")
# message("EXPORT_MACRO: ${LIBRARY_EXPORT_MACRO}")
# message("NO_INSTALL: ${LIBRARY_NO_INSTALL}")
set(target ${LIBRARY_NAME})
# qt stuff
include_directories(${CMAKE_CURRENT_BINARY_DIR})
if(LIBRARY_UI)
qt_wrap_ui(LIBRARY_UI_SOURCES ${LIBRARY_UI})
list(APPEND LIBRARY_SOURCES ${LIBRARY_UI_SOURCES})
endif()
# add resources from current dir
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/resources.qrc")
qt_add_resources(LIBRARY_RC_SOURCES "resources.qrc")
list(APPEND LIBRARY_SOURCES ${LIBRARY_RC_SOURCES})
unset(LIBRARY_RC_SOURCES)
endif()
# add target
if(LIBRARY_TARGET_TYPE STREQUAL "STATIC")
add_library(${target} STATIC ${LIBRARY_SOURCES})
elseif(LIBRARY_TARGET_TYPE STREQUAL "MODULE")
add_library(${target} MODULE ${LIBRARY_SOURCES})
else() # default
add_library(${target} SHARED ${LIBRARY_SOURCES})
endif()
# HACK: add qt modules - every lib should define its own set of modules
qt5_use_modules(${target} Core Network Widgets Sql Xml DBus)
# definitions - can this be moved into set_target_properties below?
add_definitions(${QT_DEFINITIONS})
set_target_properties(${target} PROPERTIES AUTOMOC TRUE)
if(LIBRARY_EXPORT_MACRO)
set_target_properties(${target} PROPERTIES COMPILE_DEFINITIONS ${LIBRARY_EXPORT_MACRO})
endif()
if(LIBRARY_COMPILE_DEFINITIONS)
# Dear CMake, i hate you! Sincerely, domme
# At least in CMake 2.8.8, you CANNOT set more than one COMPILE_DEFINITIONS value
# only takes the first one if called multiple times or bails out with wrong number of arguments
# when passing in a list, thus i redefine the export macro here in hope it won't mess up other targets
add_definitions( "-D${LIBRARY_EXPORT_MACRO}" )
set_target_properties(${target} PROPERTIES COMPILE_DEFINITIONS ${LIBRARY_COMPILE_DEFINITIONS})
endif()
# add link targets
target_link_libraries(${target} ${TOMAHAWK_LIBRARIES})
if(LIBRARY_LINK_LIBRARIES)
target_link_libraries(${target} ${LIBRARY_LINK_LIBRARIES})
endif()
# add soversion
if(NOT LIBRARY_NO_VERSION)
set_target_properties(${target} PROPERTIES VERSION ${LIBRARY_VERSION})
if(NOT LIBRARY_SOVERSION)
set(LIBRARY_SOVERSION ${LIBRARY_VERSION})
endif()
set_target_properties(${target} PROPERTIES SOVERSION ${LIBRARY_SOVERSION})
endif()
# make installation optional, maybe useful for dummy plugins one day
if(NOT LIBRARY_NO_INSTALL)
include(GNUInstallDirs)
if(NOT LIBRARY_EXPORT)
install(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR})
else()
install(TARGETS ${target} EXPORT ${LIBRARY_EXPORT} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
endif()
endfunction()

View File

@@ -43,5 +43,7 @@ function(tomahawk_add_plugin)
list(APPEND tomahawk_add_library_args "LINK_LIBRARIES" "${PLUGIN_LINK_LIBRARIES}") list(APPEND tomahawk_add_library_args "LINK_LIBRARIES" "${PLUGIN_LINK_LIBRARIES}")
endif() endif()
list(APPEND tomahawk_add_library_args "NO_VERSION")
tomahawk_add_library(${tomahawk_add_library_args}) tomahawk_add_library(${tomahawk_add_library_args})
endfunction() endfunction()

View File

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

View File

@@ -49,7 +49,6 @@
#include "widgets/NewReleasesWidget.h" #include "widgets/NewReleasesWidget.h"
#include "widgets/Dashboard.h" #include "widgets/Dashboard.h"
#include "widgets/WhatsHotWidget.h" #include "widgets/WhatsHotWidget.h"
#include "widgets/NetworkActivityWidget.h"
#include "widgets/infowidgets/SourceInfoWidget.h" #include "widgets/infowidgets/SourceInfoWidget.h"
#include "widgets/infowidgets/ArtistInfoWidget.h" #include "widgets/infowidgets/ArtistInfoWidget.h"
#include "widgets/infowidgets/AlbumInfoWidget.h" #include "widgets/infowidgets/AlbumInfoWidget.h"
@@ -85,7 +84,6 @@ ViewManager::ViewManager( QObject* parent )
, m_newReleasesWidget( 0 ) , m_newReleasesWidget( 0 )
, m_recentPlaysWidget( 0 ) , m_recentPlaysWidget( 0 )
, m_inboxWidget( 0 ) , m_inboxWidget( 0 )
, m_networkActivityWidget( 0 )
, m_currentPage( 0 ) , m_currentPage( 0 )
{ {
s_instance = this; s_instance = this;
@@ -130,7 +128,6 @@ ViewManager::ViewManager( QObject* parent )
ViewManager::~ViewManager() ViewManager::~ViewManager()
{ {
delete m_networkActivityWidget;
delete m_whatsHotWidget; delete m_whatsHotWidget;
delete m_newReleasesWidget; delete m_newReleasesWidget;
delete m_dashboard; 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 void
ViewManager::setFilter( const QString& filter ) ViewManager::setFilter( const QString& filter )
{ {
@@ -896,11 +882,6 @@ ViewManager::inboxWidget() const
return m_inboxWidget; return m_inboxWidget;
} }
ViewPage *ViewManager::networkActivityWidget() const
{
return m_networkActivityWidget;
}
ViewPage* ViewPage*
ViewManager::dynamicPageWidget( const QString& pageName ) const ViewManager::dynamicPageWidget( const QString& pageName ) const
@@ -941,7 +922,11 @@ ViewManager::showDynamicPage( const QString& pageName )
Q_ASSERT(false); Q_ASSERT(false);
return 0; 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 ); m_dynamicPagesInstanceLoaders.remove( pageName );
} }

View File

@@ -60,7 +60,6 @@ class Dashboard;
class WhatsHotWidget; class WhatsHotWidget;
class QPushButton; class QPushButton;
class InboxModel; class InboxModel;
class NetworkActivityWidget;
namespace Tomahawk namespace Tomahawk
{ {
@@ -99,7 +98,6 @@ public:
Tomahawk::ViewPage* recentPlaysWidget() const; Tomahawk::ViewPage* recentPlaysWidget() const;
Tomahawk::ViewPage* superCollectionView() const; Tomahawk::ViewPage* superCollectionView() const;
Tomahawk::ViewPage* inboxWidget() const; Tomahawk::ViewPage* inboxWidget() const;
Tomahawk::ViewPage* networkActivityWidget() const;
Tomahawk::ViewPage* dynamicPageWidget( const QString& pageName ) const; Tomahawk::ViewPage* dynamicPageWidget( const QString& pageName ) const;
@@ -145,7 +143,6 @@ public slots:
Tomahawk::ViewPage* showNewReleasesPage(); Tomahawk::ViewPage* showNewReleasesPage();
Tomahawk::ViewPage* showRecentPlaysPage(); Tomahawk::ViewPage* showRecentPlaysPage();
Tomahawk::ViewPage* showInboxPage(); Tomahawk::ViewPage* showInboxPage();
Tomahawk::ViewPage* showNetworkActivityPage();
void addDynamicPage( const QString& pageName, const QString& text, const QIcon& icon, boost::function< Tomahawk::ViewPage*() > instanceLoader ); void addDynamicPage( const QString& pageName, const QString& text, const QIcon& icon, boost::function< Tomahawk::ViewPage*() > instanceLoader );
Tomahawk::ViewPage* showDynamicPage( const QString& pageName ); Tomahawk::ViewPage* showDynamicPage( const QString& pageName );
@@ -201,7 +198,6 @@ private:
Tomahawk::ViewPage* m_recentPlaysWidget; Tomahawk::ViewPage* m_recentPlaysWidget;
Tomahawk::ViewPage* m_inboxWidget; Tomahawk::ViewPage* m_inboxWidget;
InboxModel* m_inboxModel; InboxModel* m_inboxModel;
NetworkActivityWidget* m_networkActivityWidget;
QHash< QString, Tomahawk::ViewPage* > m_dynamicPages; QHash< QString, Tomahawk::ViewPage* > m_dynamicPages;
QHash< QString, boost::function< Tomahawk::ViewPage*() > > m_dynamicPagesInstanceLoaders; 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 * 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 * 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 Q_OBJECT
public: 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 "ViewPage.h"
#include "WidgetsDllMacro.h"
class AnimatedSpinner; class AnimatedSpinner;
class NetworkActivityWidgetPrivate; class NetworkActivityWidgetPrivate;
class PlaylistModel; class PlaylistModel;
@@ -32,7 +34,7 @@ namespace Ui
class NetworkActivityWidget; class NetworkActivityWidget;
} }
class NetworkActivityWidget : public QWidget, public Tomahawk::ViewPage class TOMAHAWK_WIDGETS_EXPORT NetworkActivityWidget : public QWidget, public Tomahawk::ViewPage
{ {
Q_OBJECT Q_OBJECT
public: 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 TARGET_LINK_LIBRARIES( tomahawk
${LINK_LIBRARIES} ${LINK_LIBRARIES}
${TOMAHAWK_WIDGETS_LIBRARIES}
${TOMAHAWK_LIBRARIES} ${TOMAHAWK_LIBRARIES}
${PHONON_LIBS} ${PHONON_LIBS}
${OS_SPECIFIC_LINK_LIBRARIES} ${OS_SPECIFIC_LINK_LIBRARIES}

View File

@@ -20,11 +20,6 @@
#include "sourcetree/SourcesModel.h" #include "sourcetree/SourcesModel.h"
#include <QMimeData>
#include <QSize>
#include <boost/bind.hpp>
#include "sourcetree/items/ScriptCollectionItem.h" #include "sourcetree/items/ScriptCollectionItem.h"
#include "sourcetree/items/SourceTreeItem.h" #include "sourcetree/items/SourceTreeItem.h"
#include "sourcetree/items/SourceItem.h" #include "sourcetree/items/SourceItem.h"
@@ -38,6 +33,7 @@
#include "collection/Collection.h" #include "collection/Collection.h"
#include "Source.h" #include "Source.h"
#include "ViewManager.h" #include "ViewManager.h"
#include "widgets/NetworkActivityWidget.h"
#include "GlobalActionManager.h" #include "GlobalActionManager.h"
#include "DropJob.h" #include "DropJob.h"
#include "items/PlaylistItems.h" #include "items/PlaylistItems.h"
@@ -47,6 +43,13 @@
#include "utils/ImageRegistry.h" #include "utils/ImageRegistry.h"
#include "utils/Logger.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; using namespace Tomahawk;
@@ -57,6 +60,7 @@ SourcesModel::SourcesModel( QObject* parent )
{ {
m_rootItem = new SourceTreeItem( this, 0, Invalid ); m_rootItem = new SourceTreeItem( this, 0, Invalid );
connect( ViewManager::instance(), SIGNAL( viewPageAdded( QString, QString, QIcon ) ), SLOT( appendPageItem( QString, QString, QIcon ) ) );
appendGroups(); appendGroups();
onSourcesAdded( SourceList::instance()->sources() ); onSourcesAdded( SourceList::instance()->sources() );
@@ -77,9 +81,6 @@ SourcesModel::SourcesModel( QObject* parent )
this, SLOT( onScriptCollectionAdded( Tomahawk::collection_ptr ) ) ); this, SLOT( onScriptCollectionAdded( Tomahawk::collection_ptr ) ) );
connect( SourceList::instance(), SIGNAL( scriptCollectionRemoved( Tomahawk::collection_ptr ) ), connect( SourceList::instance(), SIGNAL( scriptCollectionRemoved( Tomahawk::collection_ptr ) ),
this, SLOT( onScriptCollectionRemoved( 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 ); LovedTracksItem* loved = new LovedTracksItem( this, m_browse );
loved->setSortValue( 2 ); 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" ), 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::showRecentPlaysPage, ViewManager::instance() ),
boost::bind( &ViewManager::recentPlaysWidget, ViewManager::instance() ) ); boost::bind( &ViewManager::recentPlaysWidget, ViewManager::instance() ) );
@@ -345,6 +341,13 @@ SourcesModel::appendGroups()
m_cloudGroup = new GroupItem( this, m_rootItem, tr( "Cloud" ), 5 ); m_cloudGroup = new GroupItem( this, m_rootItem, tr( "Cloud" ), 5 );
endInsertRows(); 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 void