mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-01 03:40:16 +02:00
Merge pull request #209 from tomahawk-player/viewpageplugins
ViewPagePlugins
This commit is contained in:
@@ -15,6 +15,7 @@ add_subdirectory( libtomahawk-widgets )
|
|||||||
# plugins
|
# plugins
|
||||||
add_subdirectory( accounts )
|
add_subdirectory( accounts )
|
||||||
add_subdirectory( infoplugins )
|
add_subdirectory( infoplugins )
|
||||||
|
add_subdirectory( viewpages )
|
||||||
|
|
||||||
|
|
||||||
# application
|
# application
|
||||||
|
@@ -6,14 +6,12 @@ list(APPEND ${TOMAHAWK_WIDGETS_LIBRARY_TARGET}_SOURCES
|
|||||||
PlaylistWidget.cpp
|
PlaylistWidget.cpp
|
||||||
|
|
||||||
# ViewPages
|
# ViewPages
|
||||||
Dashboard.cpp
|
|
||||||
NetworkActivityWidget.cpp
|
NetworkActivityWidget.cpp
|
||||||
NetworkActivityWorker.cpp
|
NetworkActivityWorker.cpp
|
||||||
SocialPlaylistWidget.cpp
|
SocialPlaylistWidget.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND ${TOMAHAWK_WIDGETS_LIBRARY_TARGET}_UI
|
list(APPEND ${TOMAHAWK_WIDGETS_LIBRARY_TARGET}_UI
|
||||||
Dashboard.ui
|
|
||||||
NetworkActivityWidget.ui
|
NetworkActivityWidget.ui
|
||||||
SocialPlaylistWidget.ui
|
SocialPlaylistWidget.ui
|
||||||
)
|
)
|
||||||
|
@@ -38,7 +38,6 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#include "WidgetsDllMacro.h"
|
#include "WidgetsDllMacro.h"
|
||||||
#include "Dashboard.h"
|
|
||||||
|
|
||||||
|
|
||||||
class PlayableModel;
|
class PlayableModel;
|
||||||
|
@@ -18,6 +18,8 @@ set( libGuiSources
|
|||||||
DropJob.cpp
|
DropJob.cpp
|
||||||
GlobalActionManager.cpp
|
GlobalActionManager.cpp
|
||||||
ViewPage.cpp
|
ViewPage.cpp
|
||||||
|
ViewPageLazyLoader.cpp
|
||||||
|
ViewPagePlugin.cpp
|
||||||
ViewManager.cpp
|
ViewManager.cpp
|
||||||
LatchManager.cpp
|
LatchManager.cpp
|
||||||
TomahawkSettingsGui.cpp
|
TomahawkSettingsGui.cpp
|
||||||
|
@@ -873,16 +873,39 @@ ViewManager::dynamicPageWidget( const QString& pageName ) const
|
|||||||
if( m_dynamicPages.contains( pageName ) )
|
if( m_dynamicPages.contains( pageName ) )
|
||||||
return m_dynamicPages.value( pageName );
|
return m_dynamicPages.value( pageName );
|
||||||
|
|
||||||
|
if( m_dynamicPagePlugins.contains( pageName ) )
|
||||||
|
return m_dynamicPagePlugins.value( pageName ).data();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ViewManager::addDynamicPage( Tomahawk::ViewPagePlugin* viewPage, const QString& pageName )
|
||||||
|
{
|
||||||
|
const QString pageId = !pageName.isEmpty() ? pageName : viewPage->defaultName();
|
||||||
|
|
||||||
|
tLog() << Q_FUNC_INFO << "Trying to add " << pageId;
|
||||||
|
|
||||||
|
if( m_dynamicPages.contains( pageId ) || m_dynamicPagePlugins.contains( pageId ) )
|
||||||
|
{
|
||||||
|
tLog() << "Not adding a second ViewPage with name " << pageName;
|
||||||
|
Q_ASSERT( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
m_dynamicPagePlugins.insert( pageId, viewPage );
|
||||||
|
|
||||||
|
// HACK: rather emit the viewpage itself ...
|
||||||
|
emit viewPageAdded( pageId, viewPage->title(), viewPage->pixmap(), viewPage->sortValue() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ViewManager::addDynamicPage( const QString& pageName, const QString& text, const QIcon& icon, boost::function<Tomahawk::ViewPage*()> instanceLoader, int sortValue )
|
ViewManager::addDynamicPage( const QString& pageName, const QString& text, const QIcon& icon, boost::function<Tomahawk::ViewPage*()> instanceLoader, int sortValue )
|
||||||
{
|
{
|
||||||
tLog() << Q_FUNC_INFO << "Trying to add " << pageName;
|
tLog() << Q_FUNC_INFO << "Trying to add " << pageName;
|
||||||
|
|
||||||
if( m_dynamicPages.contains( pageName ) )
|
if( m_dynamicPages.contains( pageName ) || m_dynamicPagePlugins.contains( pageName ) )
|
||||||
{
|
{
|
||||||
tLog() << "Not adding a second ViewPage with name " << pageName;
|
tLog() << "Not adding a second ViewPage with name " << pageName;
|
||||||
Q_ASSERT( false );
|
Q_ASSERT( false );
|
||||||
@@ -898,7 +921,7 @@ ViewManager::showDynamicPage( const QString& pageName )
|
|||||||
{
|
{
|
||||||
tLog() << Q_FUNC_INFO << "pageName: " << pageName;
|
tLog() << Q_FUNC_INFO << "pageName: " << pageName;
|
||||||
|
|
||||||
if( !m_dynamicPages.contains( pageName ) )
|
if( !m_dynamicPages.contains( pageName ) && !m_dynamicPagePlugins.contains( pageName ) )
|
||||||
{
|
{
|
||||||
if( !m_dynamicPagesInstanceLoaders.contains( pageName ) )
|
if( !m_dynamicPagesInstanceLoaders.contains( pageName ) )
|
||||||
{
|
{
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
#include "PlaylistInterface.h"
|
#include "PlaylistInterface.h"
|
||||||
#include "playlist/QueueView.h"
|
#include "playlist/QueueView.h"
|
||||||
#include "ViewPage.h"
|
#include "ViewPage.h"
|
||||||
|
#include "ViewPagePlugin.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
@@ -115,6 +116,8 @@ public:
|
|||||||
|
|
||||||
FlexibleView* createPageForList( const QString& title, const QList< Tomahawk::query_ptr >& queries );
|
FlexibleView* createPageForList( const QString& title, const QList< Tomahawk::query_ptr >& queries );
|
||||||
|
|
||||||
|
void addDynamicPage( Tomahawk::ViewPagePlugin* viewPage, const QString& pageName = QString() );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void filterAvailable( bool b );
|
void filterAvailable( bool b );
|
||||||
|
|
||||||
@@ -196,6 +199,7 @@ private:
|
|||||||
InboxModel* m_inboxModel;
|
InboxModel* m_inboxModel;
|
||||||
|
|
||||||
QHash< QString, Tomahawk::ViewPage* > m_dynamicPages;
|
QHash< QString, Tomahawk::ViewPage* > m_dynamicPages;
|
||||||
|
QHash< QString, QPointer< Tomahawk::ViewPagePlugin > > m_dynamicPagePlugins;
|
||||||
QHash< QString, boost::function< Tomahawk::ViewPage*() > > m_dynamicPagesInstanceLoaders;
|
QHash< QString, boost::function< Tomahawk::ViewPage*() > > m_dynamicPagesInstanceLoaders;
|
||||||
|
|
||||||
QList< Tomahawk::collection_ptr > m_superCollections;
|
QList< Tomahawk::collection_ptr > m_superCollections;
|
||||||
|
19
src/libtomahawk/ViewPageLazyLoader.cpp
Normal file
19
src/libtomahawk/ViewPageLazyLoader.cpp
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2013, Dominik Schmidt <domme@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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ViewPageLazyLoader.h"
|
58
src/libtomahawk/ViewPageLazyLoader.h
Normal file
58
src/libtomahawk/ViewPageLazyLoader.h
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2013, Dominik Schmidt <domme@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 VIEWPAGELAZYLOADER_H
|
||||||
|
#define VIEWPAGELAZYLOADER_H
|
||||||
|
|
||||||
|
#include "ViewPagePlugin.h"
|
||||||
|
|
||||||
|
#include "DllMacro.h"
|
||||||
|
|
||||||
|
namespace Tomahawk
|
||||||
|
{
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
class ViewPageLazyLoader : public ViewPagePlugin
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ViewPageLazyLoader<T>()
|
||||||
|
: m_widget( 0 )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~ViewPageLazyLoader()
|
||||||
|
{
|
||||||
|
delete m_widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual T* widget()
|
||||||
|
{
|
||||||
|
if( !m_widget )
|
||||||
|
m_widget = new T();
|
||||||
|
|
||||||
|
return m_widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
T* m_widget;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // ns
|
||||||
|
|
||||||
|
#endif //VIEWPAGELAZYLOADER_H
|
56
src/libtomahawk/ViewPagePlugin.cpp
Normal file
56
src/libtomahawk/ViewPagePlugin.cpp
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2013, Dominik Schmidt <domme@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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ViewPagePlugin.h"
|
||||||
|
|
||||||
|
#include "utils/TomahawkUtilsGui.h"
|
||||||
|
#include "utils/DpiScaler.h"
|
||||||
|
#include "utils/ImageRegistry.h"
|
||||||
|
|
||||||
|
Tomahawk::ViewPagePlugin::ViewPagePlugin(QObject* parent)
|
||||||
|
: QObject( parent )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Tomahawk::ViewPagePlugin::~ViewPagePlugin()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
Tomahawk::ViewPagePlugin::sortValue()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QPixmap
|
||||||
|
Tomahawk::ViewPagePlugin::pixmap() const
|
||||||
|
{
|
||||||
|
// TODO: use DpiScaler here
|
||||||
|
return ImageRegistry::instance()->pixmap( pixmapPath(), QSize( 256, 256 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const QString
|
||||||
|
Tomahawk::ViewPagePlugin::pixmapPath() const
|
||||||
|
{
|
||||||
|
return ( RESPATH "icons/tomahawk-icon-256x256.png" );
|
||||||
|
}
|
60
src/libtomahawk/ViewPagePlugin.h
Normal file
60
src/libtomahawk/ViewPagePlugin.h
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2013, Dominik Schmidt <domme@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 VIEWPAGEPLUGIN_H
|
||||||
|
#define VIEWPAGEPLUGIN_H
|
||||||
|
|
||||||
|
#include "ViewPage.h"
|
||||||
|
|
||||||
|
#include "DllMacro.h"
|
||||||
|
|
||||||
|
namespace Tomahawk
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
class DLLEXPORT ViewPagePlugin : public QObject, public ViewPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
ViewPagePlugin( QObject* parent = 0 );
|
||||||
|
virtual ~ViewPagePlugin();
|
||||||
|
|
||||||
|
virtual const QString defaultName() = 0;
|
||||||
|
virtual int sortValue();
|
||||||
|
|
||||||
|
// pixmap() by default returns a scaled instance of pixmapPath
|
||||||
|
virtual QPixmap pixmap() const;
|
||||||
|
virtual const QString pixmapPath() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void nameChanged( const QString& );
|
||||||
|
void descriptionChanged( const QString& );
|
||||||
|
void descriptionChanged( const Tomahawk::artist_ptr& artist );
|
||||||
|
void descriptionChanged( const Tomahawk::album_ptr& album );
|
||||||
|
void longDescriptionChanged( const QString& );
|
||||||
|
void pixmapChanged( const QPixmap& );
|
||||||
|
void destroyed( QWidget* widget );
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // ns
|
||||||
|
|
||||||
|
Q_DECLARE_INTERFACE( Tomahawk::ViewPagePlugin, "tomahawk.ViewPage/1.0" )
|
||||||
|
|
||||||
|
#endif //VIEWPAGEPLUGIN_H
|
@@ -20,8 +20,9 @@
|
|||||||
|
|
||||||
#include "sourcetree/SourcesModel.h"
|
#include "sourcetree/SourcesModel.h"
|
||||||
|
|
||||||
|
#include "../../viewpages/dashboard/Dashboard.h"
|
||||||
|
|
||||||
#include <libtomahawk-widgets/NetworkActivityWidget.h>
|
#include <libtomahawk-widgets/NetworkActivityWidget.h>
|
||||||
#include <libtomahawk-widgets/Dashboard.h>
|
|
||||||
|
|
||||||
#include "sourcetree/items/ScriptCollectionItem.h"
|
#include "sourcetree/items/ScriptCollectionItem.h"
|
||||||
#include "sourcetree/items/SourceTreeItem.h"
|
#include "sourcetree/items/SourceTreeItem.h"
|
||||||
@@ -44,6 +45,7 @@
|
|||||||
#include "playlist/dynamic/widgets/DynamicWidget.h"
|
#include "playlist/dynamic/widgets/DynamicWidget.h"
|
||||||
#include "utils/ImageRegistry.h"
|
#include "utils/ImageRegistry.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
#include "utils/PluginLoader.h"
|
||||||
|
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
@@ -338,24 +340,29 @@ SourcesModel::appendGroups()
|
|||||||
|
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
|
||||||
// addDynamicPage takes care of begin/endInsertRows itself
|
|
||||||
ViewManager::instance()->addDynamicPage( "dashboard",
|
|
||||||
tr( "Dashboard" ),
|
|
||||||
ImageRegistry::instance()->icon( RESPATH "images/dashboard.svg" ),
|
|
||||||
boost::lambda::bind( boost::lambda::new_ptr< Tomahawk::Widgets::Dashboard >() ),
|
|
||||||
1
|
|
||||||
);
|
|
||||||
|
|
||||||
//HACK: this may not belong here, but adding the pages probably doesn't belong here either
|
|
||||||
//TODO: find a good place for this
|
|
||||||
ViewManager::instance()->showDynamicPage("dashboard");
|
|
||||||
|
|
||||||
ViewManager::instance()->addDynamicPage("network_activity",
|
ViewManager::instance()->addDynamicPage("network_activity",
|
||||||
tr( "Network Activity" ),
|
tr( "Network Activity" ),
|
||||||
TomahawkUtils::defaultPixmap( TomahawkUtils::NetworkActivity, TomahawkUtils::Original ),
|
TomahawkUtils::defaultPixmap( TomahawkUtils::NetworkActivity, TomahawkUtils::Original ),
|
||||||
boost::lambda::bind( boost::lambda::new_ptr< Tomahawk::Widgets::NetworkActivityWidget >() ),
|
boost::lambda::bind( boost::lambda::new_ptr< Tomahawk::Widgets::NetworkActivityWidget >() ),
|
||||||
2
|
2
|
||||||
);
|
);
|
||||||
|
|
||||||
|
QHash< QString, QObject* > plugins = Tomahawk::Utils::PluginLoader( "viewpage" ).loadPlugins();
|
||||||
|
foreach ( QObject* plugin, plugins.values() )
|
||||||
|
{
|
||||||
|
Tomahawk::ViewPagePlugin* viewPagePlugin = qobject_cast< ViewPagePlugin* >( plugin );
|
||||||
|
if ( viewPagePlugin )
|
||||||
|
{
|
||||||
|
tDebug() << Q_FUNC_INFO << "Loaded viewpage plugin:" << plugins.key( plugin );
|
||||||
|
ViewManager::instance()->addDynamicPage( viewPagePlugin );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tDebug() << Q_FUNC_INFO << "Loaded invalid plugin:" << plugins.key( plugin );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewManager::instance()->showDynamicPage( Tomahawk::Widgets::DASHBOARD_VIEWPAGE_NAME );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
7
src/viewpages/CMakeLists.txt
Normal file
7
src/viewpages/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
file(GLOB SUBDIRECTORIES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*")
|
||||||
|
foreach(SUBDIRECTORY ${SUBDIRECTORIES})
|
||||||
|
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}" AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/CMakeLists.txt")
|
||||||
|
add_subdirectory(${SUBDIRECTORY})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
33
src/viewpages/ViewPageDllMacro.h
Normal file
33
src/viewpages/ViewPageDllMacro.h
Normal 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 ACCOUNTDLLMACRO_H
|
||||||
|
#define ACCOUNTDLLMACRO_H
|
||||||
|
|
||||||
|
#include <QtCore/qglobal.h>
|
||||||
|
|
||||||
|
#ifndef TOMAHAWK_VIEWPAGE_EXPORT
|
||||||
|
# if defined (TOMAHAWK_VIEWPAGE_EXPORT_PRO)
|
||||||
|
# define TOMAHAWK_VIEWPAGE_EXPORT Q_DECL_EXPORT
|
||||||
|
# else
|
||||||
|
# define TOMAHAWK_VIEWPAGE_EXPORT Q_DECL_IMPORT
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
10
src/viewpages/dashboard/CMakeLists.txt
Normal file
10
src/viewpages/dashboard/CMakeLists.txt
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
tomahawk_add_plugin(dashboard
|
||||||
|
TYPE viewpage
|
||||||
|
EXPORT_MACRO TOMAHAWK_VIEWPAGE_EXPORT_PRO
|
||||||
|
SOURCES
|
||||||
|
Dashboard.cpp
|
||||||
|
UI
|
||||||
|
DashboardWidget.ui
|
||||||
|
LINK_LIBRARIES
|
||||||
|
tomahawk-widgets
|
||||||
|
)
|
@@ -19,7 +19,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Dashboard.h"
|
#include "Dashboard.h"
|
||||||
#include "ui_Dashboard.h"
|
#include "ui_DashboardWidget.h"
|
||||||
|
|
||||||
|
#include "libtomahawk-widgets/PlaylistDelegate.h"
|
||||||
|
|
||||||
#include "ViewManager.h"
|
#include "ViewManager.h"
|
||||||
#include "SourceList.h"
|
#include "SourceList.h"
|
||||||
@@ -27,7 +29,6 @@
|
|||||||
#include "widgets/RecentPlaylistsModel.h"
|
#include "widgets/RecentPlaylistsModel.h"
|
||||||
#include "widgets/RecentlyPlayedPlaylistsModel.h"
|
#include "widgets/RecentlyPlayedPlaylistsModel.h"
|
||||||
#include "MetaPlaylistInterface.h"
|
#include "MetaPlaylistInterface.h"
|
||||||
#include "PlaylistDelegate.h"
|
|
||||||
#include "audio/AudioEngine.h"
|
#include "audio/AudioEngine.h"
|
||||||
#include "playlist/AlbumModel.h"
|
#include "playlist/AlbumModel.h"
|
||||||
#include "playlist/RecentlyPlayedModel.h"
|
#include "playlist/RecentlyPlayedModel.h"
|
||||||
@@ -52,8 +53,19 @@ using namespace Tomahawk::Widgets;
|
|||||||
|
|
||||||
|
|
||||||
Dashboard::Dashboard( QWidget* parent )
|
Dashboard::Dashboard( QWidget* parent )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Dashboard::~Dashboard()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DashboardWidget::DashboardWidget( QWidget* parent )
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
, ui( new Ui::Dashboard )
|
, ui( new Ui::DashboardWidget )
|
||||||
{
|
{
|
||||||
QWidget* widget = new QWidget;
|
QWidget* widget = new QWidget;
|
||||||
ui->setupUi( widget );
|
ui->setupUi( widget );
|
||||||
@@ -182,7 +194,7 @@ Dashboard::Dashboard( QWidget* parent )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Dashboard::~Dashboard()
|
DashboardWidget::~DashboardWidget()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
@@ -191,17 +203,17 @@ Dashboard::~Dashboard()
|
|||||||
Tomahawk::playlistinterface_ptr
|
Tomahawk::playlistinterface_ptr
|
||||||
Dashboard::playlistInterface() const
|
Dashboard::playlistInterface() const
|
||||||
{
|
{
|
||||||
return m_playlistInterface;
|
return m_widget->m_playlistInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Dashboard::jumpToCurrentTrack()
|
Dashboard::jumpToCurrentTrack()
|
||||||
{
|
{
|
||||||
if ( ui->tracksView->jumpToCurrentTrack() )
|
if ( m_widget->ui->tracksView->jumpToCurrentTrack() )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if ( ui->additionsView->jumpToCurrentTrack() )
|
if ( m_widget->ui->additionsView->jumpToCurrentTrack() )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -211,15 +223,15 @@ Dashboard::jumpToCurrentTrack()
|
|||||||
bool
|
bool
|
||||||
Dashboard::isBeingPlayed() const
|
Dashboard::isBeingPlayed() const
|
||||||
{
|
{
|
||||||
if ( ui->additionsView->isBeingPlayed() )
|
if ( m_widget->ui->additionsView->isBeingPlayed() )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return AudioEngine::instance()->currentTrackPlaylist() == ui->tracksView->playlistInterface();
|
return AudioEngine::instance()->currentTrackPlaylist() == m_widget->ui->tracksView->playlistInterface();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Dashboard::onSourcesReady()
|
DashboardWidget::onSourcesReady()
|
||||||
{
|
{
|
||||||
foreach ( const source_ptr& source, SourceList::instance()->sources() )
|
foreach ( const source_ptr& source, SourceList::instance()->sources() )
|
||||||
onSourceAdded( source );
|
onSourceAdded( source );
|
||||||
@@ -229,21 +241,21 @@ Dashboard::onSourcesReady()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Dashboard::onSourceAdded( const Tomahawk::source_ptr& source )
|
DashboardWidget::onSourceAdded( const Tomahawk::source_ptr& source )
|
||||||
{
|
{
|
||||||
connect( source->dbCollection().data(), SIGNAL( changed() ), SLOT( updateRecentAdditions() ), Qt::UniqueConnection );
|
connect( source->dbCollection().data(), SIGNAL( changed() ), SLOT( updateRecentAdditions() ), Qt::UniqueConnection );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Dashboard::updateRecentAdditions()
|
DashboardWidget::updateRecentAdditions()
|
||||||
{
|
{
|
||||||
m_recentAlbumsModel->addFilteredCollection( collection_ptr(), 20, DatabaseCommand_AllAlbums::ModificationTime, true );
|
m_recentAlbumsModel->addFilteredCollection( collection_ptr(), 20, DatabaseCommand_AllAlbums::ModificationTime, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Dashboard::updatePlaylists()
|
DashboardWidget::updatePlaylists()
|
||||||
{
|
{
|
||||||
int num = ui->playlistWidget->model()->rowCount( QModelIndex() );
|
int num = ui->playlistWidget->model()->rowCount( QModelIndex() );
|
||||||
if ( num == 0 )
|
if ( num == 0 )
|
||||||
@@ -257,7 +269,7 @@ Dashboard::updatePlaylists()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Dashboard::onPlaylistActivated( const QModelIndex& item )
|
DashboardWidget::onPlaylistActivated( const QModelIndex& item )
|
||||||
{
|
{
|
||||||
Tomahawk::playlist_ptr pl = item.data( RecentlyPlayedPlaylistsModel::PlaylistRole ).value< Tomahawk::playlist_ptr >();
|
Tomahawk::playlist_ptr pl = item.data( RecentlyPlayedPlaylistsModel::PlaylistRole ).value< Tomahawk::playlist_ptr >();
|
||||||
if ( Tomahawk::dynplaylist_ptr dynplaylist = pl.dynamicCast< Tomahawk::DynamicPlaylist >() )
|
if ( Tomahawk::dynplaylist_ptr dynplaylist = pl.dynamicCast< Tomahawk::DynamicPlaylist >() )
|
||||||
@@ -268,7 +280,7 @@ Dashboard::onPlaylistActivated( const QModelIndex& item )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Dashboard::changeEvent( QEvent* e )
|
DashboardWidget::changeEvent( QEvent* e )
|
||||||
{
|
{
|
||||||
QWidget::changeEvent( e );
|
QWidget::changeEvent( e );
|
||||||
switch ( e->type() )
|
switch ( e->type() )
|
||||||
@@ -283,9 +295,4 @@ Dashboard::changeEvent( QEvent* e )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QPixmap
|
Q_EXPORT_PLUGIN2( ViewPagePlugin, Dashboard )
|
||||||
Dashboard::pixmap() const
|
|
||||||
{
|
|
||||||
return ImageRegistry::instance()->pixmap( RESPATH "images/dashboard.svg",
|
|
||||||
TomahawkUtils::DpiScaler::scaled( this, 80, 80 ) );
|
|
||||||
}
|
|
@@ -20,19 +20,20 @@
|
|||||||
#ifndef DASHBOARD_H
|
#ifndef DASHBOARD_H
|
||||||
#define DASHBOARD_H
|
#define DASHBOARD_H
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QListWidgetItem>
|
|
||||||
#include <QStyledItemDelegate>
|
|
||||||
|
|
||||||
#include "PlaylistInterface.h"
|
#include "PlaylistInterface.h"
|
||||||
|
|
||||||
#include "Query.h"
|
#include "Query.h"
|
||||||
#include "Source.h"
|
#include "Source.h"
|
||||||
#include "ViewPage.h"
|
#include "ViewPagePlugin.h"
|
||||||
|
#include "ViewPageLazyLoader.h"
|
||||||
|
|
||||||
#include "utils/TomahawkUtilsGui.h"
|
#include "utils/TomahawkUtilsGui.h"
|
||||||
|
|
||||||
#include "WidgetsDllMacro.h"
|
#include <QWidget>
|
||||||
|
#include <QListWidgetItem>
|
||||||
|
#include <QStyledItemDelegate>
|
||||||
|
|
||||||
|
#include "../ViewPageDllMacro.h"
|
||||||
|
|
||||||
class AlbumModel;
|
class AlbumModel;
|
||||||
class RecentlyPlayedModel;
|
class RecentlyPlayedModel;
|
||||||
@@ -41,7 +42,7 @@ class BasicHeader;
|
|||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
class Dashboard;
|
class DashboardWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Tomahawk
|
namespace Tomahawk
|
||||||
@@ -49,31 +50,16 @@ namespace Tomahawk
|
|||||||
namespace Widgets
|
namespace Widgets
|
||||||
{
|
{
|
||||||
|
|
||||||
class TOMAHAWK_WIDGETS_EXPORT Dashboard : public QWidget, public Tomahawk::ViewPage
|
|
||||||
|
class DashboardWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
friend class Dashboard;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Dashboard( QWidget* parent = 0 );
|
DashboardWidget( QWidget* parent = 0 );
|
||||||
virtual ~Dashboard();
|
virtual ~DashboardWidget();
|
||||||
|
|
||||||
virtual QWidget* widget() { return this; }
|
|
||||||
virtual Tomahawk::playlistinterface_ptr playlistInterface() const;
|
|
||||||
|
|
||||||
virtual QString title() const { return tr( "Dashboard" ); }
|
|
||||||
virtual QString description() const { return tr( "An overview of your recent activity" ); }
|
|
||||||
virtual QPixmap pixmap() const;
|
|
||||||
|
|
||||||
virtual bool showInfoBar() const { return true; }
|
|
||||||
virtual bool isBeingPlayed() const;
|
|
||||||
|
|
||||||
virtual bool jumpToCurrentTrack();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void changeEvent( QEvent* e );
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void destroyed( QWidget* widget );
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updatePlaylists();
|
void updatePlaylists();
|
||||||
@@ -84,14 +70,44 @@ private slots:
|
|||||||
void onSourceAdded( const Tomahawk::source_ptr& source );
|
void onSourceAdded( const Tomahawk::source_ptr& source );
|
||||||
void onPlaylistActivated( const QModelIndex& );
|
void onPlaylistActivated( const QModelIndex& );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void changeEvent( QEvent* e );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::Dashboard *ui;
|
Ui::DashboardWidget *ui;
|
||||||
|
|
||||||
RecentlyPlayedModel* m_tracksModel;
|
RecentlyPlayedModel* m_tracksModel;
|
||||||
AlbumModel* m_recentAlbumsModel;
|
AlbumModel* m_recentAlbumsModel;
|
||||||
Tomahawk::playlistinterface_ptr m_playlistInterface;
|
Tomahawk::playlistinterface_ptr m_playlistInterface;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const QString DASHBOARD_VIEWPAGE_NAME = "dashboard";
|
||||||
|
|
||||||
|
class TOMAHAWK_VIEWPAGE_EXPORT Dashboard : public Tomahawk::ViewPageLazyLoader< DashboardWidget >
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_INTERFACES( Tomahawk::ViewPagePlugin )
|
||||||
|
|
||||||
|
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" ); }
|
||||||
|
virtual const QString pixmapPath() const { return ( RESPATH "images/dashboard.svg" ); }
|
||||||
|
|
||||||
|
virtual int sortValue() { return 1; }
|
||||||
|
|
||||||
|
virtual bool showInfoBar() const { return true; }
|
||||||
|
virtual bool isBeingPlayed() const;
|
||||||
|
|
||||||
|
virtual bool jumpToCurrentTrack();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
}; // Widgets
|
}; // Widgets
|
||||||
}; // Tomahawk
|
}; // Tomahawk
|
||||||
#endif // DASHBOARD_H
|
#endif // DASHBOARD_H
|
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>Dashboard</class>
|
<class>DashboardWidget</class>
|
||||||
<widget class="QWidget" name="Dashboard">
|
<widget class="QWidget" name="DashboardWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
@@ -298,7 +298,7 @@
|
|||||||
<customwidget>
|
<customwidget>
|
||||||
<class>Tomahawk::Widgets::PlaylistWidget</class>
|
<class>Tomahawk::Widgets::PlaylistWidget</class>
|
||||||
<extends>QListWidget</extends>
|
<extends>QListWidget</extends>
|
||||||
<header>PlaylistWidget.h</header>
|
<header>libtomahawk-widgets/PlaylistWidget.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
Reference in New Issue
Block a user