mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-20 07:52:30 +02:00
Merge pull request #209 from tomahawk-player/viewpageplugins
ViewPagePlugins
This commit is contained in:
commit
96dc4a07e5
@ -15,6 +15,7 @@ add_subdirectory( libtomahawk-widgets )
|
||||
# plugins
|
||||
add_subdirectory( accounts )
|
||||
add_subdirectory( infoplugins )
|
||||
add_subdirectory( viewpages )
|
||||
|
||||
|
||||
# application
|
||||
|
@ -6,14 +6,12 @@ list(APPEND ${TOMAHAWK_WIDGETS_LIBRARY_TARGET}_SOURCES
|
||||
PlaylistWidget.cpp
|
||||
|
||||
# ViewPages
|
||||
Dashboard.cpp
|
||||
NetworkActivityWidget.cpp
|
||||
NetworkActivityWorker.cpp
|
||||
SocialPlaylistWidget.cpp
|
||||
)
|
||||
|
||||
list(APPEND ${TOMAHAWK_WIDGETS_LIBRARY_TARGET}_UI
|
||||
Dashboard.ui
|
||||
NetworkActivityWidget.ui
|
||||
SocialPlaylistWidget.ui
|
||||
)
|
||||
|
@ -38,7 +38,6 @@
|
||||
#include <QWidget>
|
||||
|
||||
#include "WidgetsDllMacro.h"
|
||||
#include "Dashboard.h"
|
||||
|
||||
|
||||
class PlayableModel;
|
||||
|
@ -18,6 +18,8 @@ set( libGuiSources
|
||||
DropJob.cpp
|
||||
GlobalActionManager.cpp
|
||||
ViewPage.cpp
|
||||
ViewPageLazyLoader.cpp
|
||||
ViewPagePlugin.cpp
|
||||
ViewManager.cpp
|
||||
LatchManager.cpp
|
||||
TomahawkSettingsGui.cpp
|
||||
|
@ -873,16 +873,39 @@ ViewManager::dynamicPageWidget( const QString& pageName ) const
|
||||
if( m_dynamicPages.contains( pageName ) )
|
||||
return m_dynamicPages.value( pageName );
|
||||
|
||||
if( m_dynamicPagePlugins.contains( pageName ) )
|
||||
return m_dynamicPagePlugins.value( pageName ).data();
|
||||
|
||||
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
|
||||
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;
|
||||
|
||||
if( m_dynamicPages.contains( pageName ) )
|
||||
if( m_dynamicPages.contains( pageName ) || m_dynamicPagePlugins.contains( pageName ) )
|
||||
{
|
||||
tLog() << "Not adding a second ViewPage with name " << pageName;
|
||||
Q_ASSERT( false );
|
||||
@ -898,7 +921,7 @@ ViewManager::showDynamicPage( const QString& 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 ) )
|
||||
{
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "PlaylistInterface.h"
|
||||
#include "playlist/QueueView.h"
|
||||
#include "ViewPage.h"
|
||||
#include "ViewPagePlugin.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QHash>
|
||||
@ -115,6 +116,8 @@ public:
|
||||
|
||||
FlexibleView* createPageForList( const QString& title, const QList< Tomahawk::query_ptr >& queries );
|
||||
|
||||
void addDynamicPage( Tomahawk::ViewPagePlugin* viewPage, const QString& pageName = QString() );
|
||||
|
||||
signals:
|
||||
void filterAvailable( bool b );
|
||||
|
||||
@ -196,6 +199,7 @@ private:
|
||||
InboxModel* m_inboxModel;
|
||||
|
||||
QHash< QString, Tomahawk::ViewPage* > m_dynamicPages;
|
||||
QHash< QString, QPointer< Tomahawk::ViewPagePlugin > > m_dynamicPagePlugins;
|
||||
QHash< QString, boost::function< Tomahawk::ViewPage*() > > m_dynamicPagesInstanceLoaders;
|
||||
|
||||
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 "../../viewpages/dashboard/Dashboard.h"
|
||||
|
||||
#include <libtomahawk-widgets/NetworkActivityWidget.h>
|
||||
#include <libtomahawk-widgets/Dashboard.h>
|
||||
|
||||
#include "sourcetree/items/ScriptCollectionItem.h"
|
||||
#include "sourcetree/items/SourceTreeItem.h"
|
||||
@ -44,6 +45,7 @@
|
||||
#include "playlist/dynamic/widgets/DynamicWidget.h"
|
||||
#include "utils/ImageRegistry.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/PluginLoader.h"
|
||||
|
||||
#include <QMimeData>
|
||||
#include <QSize>
|
||||
@ -338,24 +340,29 @@ SourcesModel::appendGroups()
|
||||
|
||||
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",
|
||||
tr( "Network Activity" ),
|
||||
TomahawkUtils::defaultPixmap( TomahawkUtils::NetworkActivity, TomahawkUtils::Original ),
|
||||
boost::lambda::bind( boost::lambda::new_ptr< Tomahawk::Widgets::NetworkActivityWidget >() ),
|
||||
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
|
||||
|
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 "ui_Dashboard.h"
|
||||
#include "ui_DashboardWidget.h"
|
||||
|
||||
#include "libtomahawk-widgets/PlaylistDelegate.h"
|
||||
|
||||
#include "ViewManager.h"
|
||||
#include "SourceList.h"
|
||||
@ -27,7 +29,6 @@
|
||||
#include "widgets/RecentPlaylistsModel.h"
|
||||
#include "widgets/RecentlyPlayedPlaylistsModel.h"
|
||||
#include "MetaPlaylistInterface.h"
|
||||
#include "PlaylistDelegate.h"
|
||||
#include "audio/AudioEngine.h"
|
||||
#include "playlist/AlbumModel.h"
|
||||
#include "playlist/RecentlyPlayedModel.h"
|
||||
@ -52,8 +53,19 @@ using namespace Tomahawk::Widgets;
|
||||
|
||||
|
||||
Dashboard::Dashboard( QWidget* parent )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Dashboard::~Dashboard()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
DashboardWidget::DashboardWidget( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, ui( new Ui::Dashboard )
|
||||
, ui( new Ui::DashboardWidget )
|
||||
{
|
||||
QWidget* widget = new QWidget;
|
||||
ui->setupUi( widget );
|
||||
@ -182,7 +194,7 @@ Dashboard::Dashboard( QWidget* parent )
|
||||
}
|
||||
|
||||
|
||||
Dashboard::~Dashboard()
|
||||
DashboardWidget::~DashboardWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
@ -191,17 +203,17 @@ Dashboard::~Dashboard()
|
||||
Tomahawk::playlistinterface_ptr
|
||||
Dashboard::playlistInterface() const
|
||||
{
|
||||
return m_playlistInterface;
|
||||
return m_widget->m_playlistInterface;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Dashboard::jumpToCurrentTrack()
|
||||
{
|
||||
if ( ui->tracksView->jumpToCurrentTrack() )
|
||||
if ( m_widget->ui->tracksView->jumpToCurrentTrack() )
|
||||
return true;
|
||||
|
||||
if ( ui->additionsView->jumpToCurrentTrack() )
|
||||
if ( m_widget->ui->additionsView->jumpToCurrentTrack() )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@ -211,15 +223,15 @@ Dashboard::jumpToCurrentTrack()
|
||||
bool
|
||||
Dashboard::isBeingPlayed() const
|
||||
{
|
||||
if ( ui->additionsView->isBeingPlayed() )
|
||||
if ( m_widget->ui->additionsView->isBeingPlayed() )
|
||||
return true;
|
||||
|
||||
return AudioEngine::instance()->currentTrackPlaylist() == ui->tracksView->playlistInterface();
|
||||
return AudioEngine::instance()->currentTrackPlaylist() == m_widget->ui->tracksView->playlistInterface();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Dashboard::onSourcesReady()
|
||||
DashboardWidget::onSourcesReady()
|
||||
{
|
||||
foreach ( const source_ptr& source, SourceList::instance()->sources() )
|
||||
onSourceAdded( source );
|
||||
@ -229,21 +241,21 @@ Dashboard::onSourcesReady()
|
||||
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Dashboard::updateRecentAdditions()
|
||||
DashboardWidget::updateRecentAdditions()
|
||||
{
|
||||
m_recentAlbumsModel->addFilteredCollection( collection_ptr(), 20, DatabaseCommand_AllAlbums::ModificationTime, true );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Dashboard::updatePlaylists()
|
||||
DashboardWidget::updatePlaylists()
|
||||
{
|
||||
int num = ui->playlistWidget->model()->rowCount( QModelIndex() );
|
||||
if ( num == 0 )
|
||||
@ -257,7 +269,7 @@ Dashboard::updatePlaylists()
|
||||
|
||||
|
||||
void
|
||||
Dashboard::onPlaylistActivated( const QModelIndex& item )
|
||||
DashboardWidget::onPlaylistActivated( const QModelIndex& item )
|
||||
{
|
||||
Tomahawk::playlist_ptr pl = item.data( RecentlyPlayedPlaylistsModel::PlaylistRole ).value< Tomahawk::playlist_ptr >();
|
||||
if ( Tomahawk::dynplaylist_ptr dynplaylist = pl.dynamicCast< Tomahawk::DynamicPlaylist >() )
|
||||
@ -268,7 +280,7 @@ Dashboard::onPlaylistActivated( const QModelIndex& item )
|
||||
|
||||
|
||||
void
|
||||
Dashboard::changeEvent( QEvent* e )
|
||||
DashboardWidget::changeEvent( QEvent* e )
|
||||
{
|
||||
QWidget::changeEvent( e );
|
||||
switch ( e->type() )
|
||||
@ -283,9 +295,4 @@ Dashboard::changeEvent( QEvent* e )
|
||||
}
|
||||
|
||||
|
||||
QPixmap
|
||||
Dashboard::pixmap() const
|
||||
{
|
||||
return ImageRegistry::instance()->pixmap( RESPATH "images/dashboard.svg",
|
||||
TomahawkUtils::DpiScaler::scaled( this, 80, 80 ) );
|
||||
}
|
||||
Q_EXPORT_PLUGIN2( ViewPagePlugin, Dashboard )
|
@ -20,19 +20,20 @@
|
||||
#ifndef DASHBOARD_H
|
||||
#define DASHBOARD_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QListWidgetItem>
|
||||
#include <QStyledItemDelegate>
|
||||
|
||||
#include "PlaylistInterface.h"
|
||||
|
||||
#include "Query.h"
|
||||
#include "Source.h"
|
||||
#include "ViewPage.h"
|
||||
#include "ViewPagePlugin.h"
|
||||
#include "ViewPageLazyLoader.h"
|
||||
|
||||
#include "utils/TomahawkUtilsGui.h"
|
||||
|
||||
#include "WidgetsDllMacro.h"
|
||||
#include <QWidget>
|
||||
#include <QListWidgetItem>
|
||||
#include <QStyledItemDelegate>
|
||||
|
||||
#include "../ViewPageDllMacro.h"
|
||||
|
||||
class AlbumModel;
|
||||
class RecentlyPlayedModel;
|
||||
@ -41,7 +42,7 @@ class BasicHeader;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class Dashboard;
|
||||
class DashboardWidget;
|
||||
}
|
||||
|
||||
namespace Tomahawk
|
||||
@ -49,31 +50,16 @@ namespace Tomahawk
|
||||
namespace Widgets
|
||||
{
|
||||
|
||||
class TOMAHAWK_WIDGETS_EXPORT Dashboard : public QWidget, public Tomahawk::ViewPage
|
||||
|
||||
class DashboardWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
friend class Dashboard;
|
||||
|
||||
public:
|
||||
Dashboard( QWidget* parent = 0 );
|
||||
virtual ~Dashboard();
|
||||
|
||||
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 );
|
||||
DashboardWidget( QWidget* parent = 0 );
|
||||
virtual ~DashboardWidget();
|
||||
|
||||
public slots:
|
||||
void updatePlaylists();
|
||||
@ -84,14 +70,44 @@ private slots:
|
||||
void onSourceAdded( const Tomahawk::source_ptr& source );
|
||||
void onPlaylistActivated( const QModelIndex& );
|
||||
|
||||
protected:
|
||||
void changeEvent( QEvent* e );
|
||||
|
||||
private:
|
||||
Ui::Dashboard *ui;
|
||||
Ui::DashboardWidget *ui;
|
||||
|
||||
RecentlyPlayedModel* m_tracksModel;
|
||||
AlbumModel* m_recentAlbumsModel;
|
||||
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
|
||||
}; // Tomahawk
|
||||
#endif // DASHBOARD_H
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Dashboard</class>
|
||||
<widget class="QWidget" name="Dashboard">
|
||||
<class>DashboardWidget</class>
|
||||
<widget class="QWidget" name="DashboardWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@ -298,7 +298,7 @@
|
||||
<customwidget>
|
||||
<class>Tomahawk::Widgets::PlaylistWidget</class>
|
||||
<extends>QListWidget</extends>
|
||||
<header>PlaylistWidget.h</header>
|
||||
<header>libtomahawk-widgets/PlaylistWidget.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
Loading…
x
Reference in New Issue
Block a user