1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-09 15:47:38 +02:00

Add What's Hot page with corresponding widget.

This commit is contained in:
Casey Link
2011-08-21 12:56:41 -05:00
parent 97d62b06c1
commit a4a3c4fb17
10 changed files with 348 additions and 0 deletions

BIN
data/images/whats-hot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

@@ -85,6 +85,7 @@
<file>data/images/automatic-playlist.png</file>
<file>data/images/station.png</file>
<file>data/images/new-additions.png</file>
<file>data/images/whats-hot.png</file>
<file>data/images/loved_playlist.png</file>
<file>data/images/dashboard.png</file>
<file>data/stylesheets/topbar-radiobuttons.css</file>

View File

@@ -181,6 +181,7 @@ set( libSources
widgets/playlisttypeselectordlg.cpp
widgets/welcomewidget.cpp
widgets/welcomeplaylistmodel.cpp
widgets/whatshotwidget.cpp
widgets/overlaywidget.cpp
widgets/HeaderLabel.cpp
widgets/SocialPlaylistWidget.cpp
@@ -360,6 +361,7 @@ set( libHeaders
widgets/SeekSlider.h
widgets/playlisttypeselectordlg.h
widgets/welcomewidget.h
widgets/whatshotwidget.h
widgets/welcomeplaylistmodel.h
widgets/overlaywidget.h
widgets/HeaderLabel.h
@@ -387,6 +389,7 @@ set( libUI ${libUI}
widgets/newplaylistwidget.ui
widgets/searchwidget.ui
widgets/welcomewidget.ui
widgets/whatshotwidget.ui
widgets/SocialPlaylistWidget.ui
widgets/infowidgets/sourceinfowidget.ui
widgets/infowidgets/ArtistInfoWidget.ui

View File

@@ -44,6 +44,7 @@
#include "dynamic/widgets/DynamicWidget.h"
#include "widgets/welcomewidget.h"
#include "widgets/whatshotwidget.h"
#include "widgets/infowidgets/sourceinfowidget.h"
#include "widgets/infowidgets/ArtistInfoWidget.h"
#include "widgets/infowidgets/AlbumInfoWidget.h"
@@ -69,6 +70,7 @@ ViewManager::ViewManager( QObject* parent )
: QObject( parent )
, m_widget( new QWidget() )
, m_welcomeWidget( new WelcomeWidget() )
, m_whatsHotWidget( new WhatsHotWidget() )
, m_currentMode( PlaylistInterface::Tree )
{
s_instance = this;
@@ -426,6 +428,13 @@ ViewManager::showWelcomePage()
return show( m_welcomeWidget );
}
Tomahawk::ViewPage*
ViewManager::showWhatsHotPage()
{
return show( m_whatsHotWidget );
}
void
ViewManager::setTableMode()

View File

@@ -27,6 +27,7 @@
#include "playlistinterface.h"
#include "viewpage.h"
#include "widgets/welcomewidget.h"
#include "widgets/whatshotwidget.h"
#include "dllmacro.h"
@@ -51,6 +52,7 @@ class SourceInfoWidget;
class InfoBar;
class TopBar;
class WelcomeWidget;
class WhatsHotWidget;
class QPushButton;
namespace Tomahawk
@@ -83,6 +85,7 @@ public:
Tomahawk::ViewPage* show( Tomahawk::ViewPage* page );
Tomahawk::ViewPage* welcomeWidget() const { return m_welcomeWidget; }
Tomahawk::ViewPage* whatsHotWidget() const { return m_whatsHotWidget; }
ArtistView* superCollectionView() const { return m_superCollectionView; }
/// Get the view page for the given item. Not pretty...
@@ -120,6 +123,7 @@ signals:
public slots:
Tomahawk::ViewPage* showSuperCollection();
Tomahawk::ViewPage* showWelcomePage();
Tomahawk::ViewPage* showWhatsHotPage();
void showCurrentTrack();
// Returns the shown viewpage
@@ -184,6 +188,7 @@ private:
TreeModel* m_superCollectionModel;
ArtistView* m_superCollectionView;
WelcomeWidget* m_welcomeWidget;
WhatsHotWidget* m_whatsHotWidget;
QList< Tomahawk::collection_ptr > m_superCollections;

View File

@@ -0,0 +1,163 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@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 "whatshotwidget.h"
#include "ui_whatshotwidget.h"
#include <QPainter>
#include "viewmanager.h"
#include "sourcelist.h"
#include "tomahawksettings.h"
#include "welcomeplaylistmodel.h"
#include "audio/audioengine.h"
#include "playlist/playlistmodel.h"
#include "widgets/overlaywidget.h"
#include "utils/tomahawkutils.h"
#include "utils/logger.h"
#include <dynamic/GeneratorInterface.h>
#define HISTORY_TRACK_ITEMS 25
#define HISTORY_PLAYLIST_ITEMS 10
#define HISTORY_RESOLVING_TIMEOUT 2500
using namespace Tomahawk;
static QString s_whatsHotIdentifier = QString( "WhatsHotWidget" );
WhatsHotWidget::WhatsHotWidget( QWidget* parent )
: QWidget( parent )
, ui( new Ui::WhatsHotWidget )
{
tDebug() << "WhatsHot: Hello world!";
ui->setupUi( this );
ui->tracksView->setFrameShape( QFrame::NoFrame );
ui->tracksView->setAttribute( Qt::WA_MacShowFocusRect, 0 );
TomahawkUtils::unmarginLayout( layout() );
TomahawkUtils::unmarginLayout( ui->verticalLayout_2->layout() );
m_tracksModel = new PlaylistModel( ui->tracksView );
m_tracksModel->setStyle( TrackModel::ShortWithAvatars );
ui->tracksView->overlay()->setEnabled( false );
ui->tracksView->setPlaylistModel( m_tracksModel );
ui->tracksView->setHeaderHidden( true );
ui->tracksView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
m_artistsModel = new TreeModel( ui->artistsView);
m_artistsModel->setColumnStyle( TreeModel::TrackOnly );
ui->artistsView->setTreeModel( m_artistsModel );
ui->artistsView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
ui->artistsView->header()->setVisible( false );
m_timer = new QTimer( this );
connect( m_timer, SIGNAL( timeout() ), SLOT( checkQueries() ) );
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
Tomahawk::InfoSystem::InfoCriteriaHash artistInfo;
Tomahawk::InfoSystem::InfoRequestData requestData;
requestData.caller = s_whatsHotIdentifier;
requestData.customData = QVariantMap();
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( artistInfo );
requestData.type = Tomahawk::InfoSystem::InfoChartArtists;
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
tDebug() << "WhatsHot: requested InfoChartArtists";
}
WhatsHotWidget::~WhatsHotWidget()
{
delete ui;
}
void
WhatsHotWidget::checkQueries()
{
m_timer->stop();
// m_tracksModel->ensureResolved();
}
void
WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
{
if ( requestData.caller != s_whatsHotIdentifier )
{
// tDebug() << "Info of wrong type or not with our identifier";
return;
}
tDebug() << "WhatsHot: got something...";
QVariantMap returnedData = output.value< QVariantMap >();
switch ( requestData.type )
{
case InfoSystem::InfoChartArtists:
{
const QStringList artists = returnedData["artists"].toStringList();
tDebug() << "WhatsHot: got artists! " << artists.size();
tDebug() << artists;
foreach ( const QString& artist, artists )
{
m_artistsModel->addArtists( Artist::get( artist ) );
}
break;
}
default:
return;
}
}
void
WhatsHotWidget::infoSystemFinished( QString target )
{
Q_UNUSED( target );
}
void
WhatsHotWidget::changeEvent( QEvent* e )
{
QWidget::changeEvent( e );
switch ( e->type() )
{
case QEvent::LanguageChange:
ui->retranslateUi( this );
break;
default:
break;
}
}

View File

@@ -0,0 +1,86 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@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 WHATSHOTWIDGET_H
#define WHATSHOTWIDGET_H
#include <QWidget>
#include <QListWidgetItem>
#include <QStyledItemDelegate>
#include "playlistinterface.h"
#include "infosystem/infosystem.h"
#include "playlist.h"
#include "result.h"
#include "viewpage.h"
#include "utils/tomahawkutils.h"
#include "dllmacro.h"
class TreeModel;
class PlaylistModel;
class OverlayWidget;
namespace Ui
{
class WhatsHotWidget;
}
class DLLEXPORT WhatsHotWidget : public QWidget, public Tomahawk::ViewPage
{
Q_OBJECT
public:
WhatsHotWidget( QWidget* parent = 0 );
~WhatsHotWidget();
virtual QWidget* widget() { return this; }
virtual Tomahawk::PlaylistInterface* playlistInterface() const { return 0; }
virtual QString title() const { return tr( "What's Hot" ); }
virtual QString description() const { return QString(); }
virtual bool showStatsBar() const { return false; }
virtual bool showInfoBar() const { return false; }
virtual bool jumpToCurrentTrack() { return false; }
protected:
void changeEvent( QEvent* e );
signals:
void destroyed( QWidget* widget );
public slots:
private slots:
void checkQueries();
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
void infoSystemFinished( QString target );
private:
Ui::WhatsHotWidget *ui;
PlaylistModel* m_tracksModel;
TreeModel* m_artistsModel;
QTimer* m_timer;
};
#endif // WHATSHOTWIDGET_H

View File

@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WhatsHotWidget</class>
<widget class="QWidget" name="WhatsHotWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>875</width>
<height>513</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="HeaderLabel" name="label_3">
<property name="text">
<string>Top Tracks</string>
</property>
</widget>
</item>
<item>
<widget class="PlaylistView" name="tracksView">
<property name="minimumSize">
<size>
<width>320</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="HeaderLabel" name="label_4">
<property name="text">
<string>Top Artists</string>
</property>
</widget>
</item>
<item>
<widget class="ArtistView" name="artistsView">
<property name="minimumSize">
<size>
<width>320</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>HeaderLabel</class>
<extends>QLabel</extends>
<header location="global">widgets/HeaderLabel.h</header>
</customwidget>
<customwidget>
<class>PlaylistView</class>
<extends>QTreeView</extends>
<header>playlist/playlistview.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -44,6 +44,7 @@ CollectionItem::CollectionItem( SourcesModel* mdl, SourceTreeItem* parent, cons
, m_sourceInfoPage( 0 )
, m_coolPlaylistsPage( 0 )
, m_lovedTracksPage( 0 )
, m_whatsHotPage( 0 )
{
m_lovedTracksItem = new GenericPageItem( model(), this, ( m_source.isNull() ? tr( "Top Loved Tracks" ) : tr( "Loved Tracks" ) ), QIcon( RESPATH "images/loved_playlist.png" ),
boost::bind( &CollectionItem::lovedTracksClicked, this ),
@@ -62,6 +63,13 @@ CollectionItem::CollectionItem( SourcesModel* mdl, SourceTreeItem* parent, cons
);
recent->setSortValue( -300 );
GenericPageItem* hot = new GenericPageItem( model(), this, tr( "What's Hot" ), QIcon( RESPATH "images/whats-hot.png" ),
boost::bind( &ViewManager::showWhatsHotPage, ViewManager::instance() ),
boost::bind( &ViewManager::whatsHotWidget, ViewManager::instance() )
);
hot->setSortValue( -300 );
// TODO finish implementing and making pretty
// m_coolPlaylistsItem = new GenericPageItem( model(), this, tr( "Cool Stuff" ), QIcon( RESPATH "images/new-additions.png" ),
// boost::bind( &CollectionItem::coolPlaylistsClicked, this ),

View File

@@ -86,6 +86,7 @@ private:
Tomahawk::ViewPage* m_sourceInfoPage;
Tomahawk::ViewPage* m_coolPlaylistsPage;
Tomahawk::ViewPage* m_lovedTracksPage;
Tomahawk::ViewPage* m_whatsHotPage;
};