1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-01 03:40:16 +02:00

* Update recent additions on welcome page whenever a collection changes.

This commit is contained in:
Christian Muehlhaeuser
2011-11-23 04:18:14 +01:00
parent ddfe32eec3
commit 34fab0f210
2 changed files with 12 additions and 10 deletions

View File

@@ -33,7 +33,7 @@
#include "widgets/overlaywidget.h" #include "widgets/overlaywidget.h"
#include "utils/tomahawkutils.h" #include "utils/tomahawkutils.h"
#include "utils/logger.h" #include "utils/logger.h"
#include <dynamic/GeneratorInterface.h> #include "dynamic/GeneratorInterface.h"
#include "RecentlyPlayedPlaylistsModel.h" #include "RecentlyPlayedPlaylistsModel.h"
#define HISTORY_TRACK_ITEMS 25 #define HISTORY_TRACK_ITEMS 25
@@ -48,9 +48,8 @@ WelcomeWidget::WelcomeWidget( QWidget* parent )
, ui( new Ui::WelcomeWidget ) , ui( new Ui::WelcomeWidget )
{ {
ui->setupUi( this ); ui->setupUi( this );
ui->splitter_2->setStretchFactor( 0, 3 );
ui->splitter_2->setStretchFactor( 0, 2 ); ui->splitter_2->setStretchFactor( 1, 1 );
ui->splitter_2->setStretchFactor( 0, 1 );
RecentPlaylistsModel* model = new RecentPlaylistsModel( HISTORY_PLAYLIST_ITEMS, this ); RecentPlaylistsModel* model = new RecentPlaylistsModel( HISTORY_PLAYLIST_ITEMS, this );
@@ -73,8 +72,6 @@ WelcomeWidget::WelcomeWidget( QWidget* parent )
ui->playlistWidget->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel ); ui->playlistWidget->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
updatePlaylists(); updatePlaylists();
connect( model, SIGNAL( emptinessChanged( bool ) ), this, SLOT( updatePlaylists() ) );
m_tracksModel = new PlaylistModel( ui->tracksView ); m_tracksModel = new PlaylistModel( ui->tracksView );
m_tracksModel->setStyle( TrackModel::ShortWithAvatars ); m_tracksModel->setStyle( TrackModel::ShortWithAvatars );
ui->tracksView->overlay()->setEnabled( false ); ui->tracksView->overlay()->setEnabled( false );
@@ -88,9 +85,10 @@ WelcomeWidget::WelcomeWidget( QWidget* parent )
m_timer = new QTimer( this ); m_timer = new QTimer( this );
connect( m_timer, SIGNAL( timeout() ), SLOT( checkQueries() ) ); connect( m_timer, SIGNAL( timeout() ), SLOT( checkQueries() ) );
connect( SourceList::instance(), SIGNAL( ready() ), SLOT( updateRecentTracks() ) ); connect( SourceList::instance(), SIGNAL( ready() ), SLOT( onSourcesReady() ) );
connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) ); connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) );
connect( ui->playlistWidget, SIGNAL( activated( QModelIndex ) ), SLOT( onPlaylistActivated( QModelIndex ) ) ); connect( ui->playlistWidget, SIGNAL( activated( QModelIndex ) ), SLOT( onPlaylistActivated( QModelIndex ) ) );
connect( model, SIGNAL( emptinessChanged( bool ) ), this, SLOT( updatePlaylists() ) );
} }
@@ -99,6 +97,7 @@ WelcomeWidget::~WelcomeWidget()
delete ui; delete ui;
} }
PlaylistInterface* PlaylistInterface*
WelcomeWidget::playlistInterface() const WelcomeWidget::playlistInterface() const
{ {
@@ -112,6 +111,7 @@ WelcomeWidget::jumpToCurrentTrack()
return ui->tracksView->jumpToCurrentTrack(); return ui->tracksView->jumpToCurrentTrack();
} }
bool bool
WelcomeWidget::isBeingPlayed() const WelcomeWidget::isBeingPlayed() const
{ {
@@ -120,11 +120,12 @@ WelcomeWidget::isBeingPlayed() const
void void
WelcomeWidget::updateRecentTracks() WelcomeWidget::onSourcesReady()
{ {
m_tracksModel->loadHistory( Tomahawk::source_ptr(), HISTORY_TRACK_ITEMS ); m_tracksModel->loadHistory( Tomahawk::source_ptr(), HISTORY_TRACK_ITEMS );
connect( SourceList::instance()->getLocal().data(), SIGNAL( stats( QVariantMap ) ), this, SLOT( updateRecentAdditions() ) ); foreach ( const source_ptr& source, SourceList::instance()->sources() )
onSourceAdded( source );
} }
@@ -152,6 +153,7 @@ WelcomeWidget::updatePlaylists()
void void
WelcomeWidget::onSourceAdded( const Tomahawk::source_ptr& source ) WelcomeWidget::onSourceAdded( const Tomahawk::source_ptr& source )
{ {
connect( source->collection().data(), SIGNAL( changed() ), SLOT( updateRecentAdditions() ) );
connect( source.data(), SIGNAL( playbackFinished( Tomahawk::query_ptr ) ), SLOT( onPlaybackFinished( Tomahawk::query_ptr ) ) ); connect( source.data(), SIGNAL( playbackFinished( Tomahawk::query_ptr ) ), SLOT( onPlaybackFinished( Tomahawk::query_ptr ) ) );
} }

View File

@@ -102,11 +102,11 @@ signals:
void destroyed( QWidget* widget ); void destroyed( QWidget* widget );
public slots: public slots:
void updateRecentTracks();
void updatePlaylists(); void updatePlaylists();
void updateRecentAdditions(); void updateRecentAdditions();
private slots: private slots:
void onSourcesReady();
void onSourceAdded( const Tomahawk::source_ptr& source ); void onSourceAdded( const Tomahawk::source_ptr& source );
void onPlaylistActivated( const QModelIndex& ); void onPlaylistActivated( const QModelIndex& );
void onPlaybackFinished( const Tomahawk::query_ptr& query ); void onPlaybackFinished( const Tomahawk::query_ptr& query );