1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-11 16:44:05 +02:00

Show filter errors when loading a dynamic playlist for the first time too

This commit is contained in:
Leo Franchi
2012-03-01 22:34:55 -05:00
parent f7f2c51d4e
commit be7b5babe9

View File

@@ -120,30 +120,32 @@ DynamicWidget::loadDynamicPlaylist( const Tomahawk::dynplaylist_ptr& playlist )
// called after the user has already created more revisions. ignore in that case. // called after the user has already created more revisions. ignore in that case.
if ( m_playlist.data() == playlist.data() && m_seqRevLaunched > 0 if ( m_playlist.data() == playlist.data() && m_seqRevLaunched > 0
&& m_controls->controls().size() != playlist->generator()->controls().size() // different number of controls && m_controls->controls().size() != playlist->generator()->controls().size() // different number of controls
&& qAbs( m_playlist->generator()->controls().size() - playlist->generator()->controls().size() ) < m_seqRevLaunched ) { // difference in controls has to be less than how many revisions we launched && qAbs( m_playlist->generator()->controls().size() - playlist->generator()->controls().size() ) < m_seqRevLaunched )
{ // difference in controls has to be less than how many revisions we launched
return; return;
} }
m_seqRevLaunched = 0; m_seqRevLaunched = 0;
// if we're being told to load the same dynamic playlist over again, only do it if the controls have a different number // if we're being told to load the same dynamic playlist over again, only do it if the controls have a different number
if ( !m_playlist.isNull() && ( m_playlist.data() == playlist.data() ) // same playlist pointer if ( !m_playlist.isNull() && ( m_playlist.data() == playlist.data() ) // same playlist pointer
&& m_playlist->generator()->controls().size() == playlist->generator()->controls().size() ) { && m_playlist->generator()->controls().size() == playlist->generator()->controls().size() )
{
// we can skip our work. just let the dynamiccontrollist show the difference // we can skip our work. just let the dynamiccontrollist show the difference
m_controls->setControls( m_playlist, m_playlist->author()->isLocal() ); m_controls->setControls( m_playlist, m_playlist->author()->isLocal() );
m_playlist = playlist; m_playlist = playlist;
if( !m_runningOnDemand ) { if ( !m_runningOnDemand )
m_model->loadPlaylist( m_playlist ); m_model->loadPlaylist( m_playlist );
} else if( !m_controlsChanged ) { // if the controls changed, we already dealt with that and don't want to change station yet else if ( !m_controlsChanged ) // if the controls changed, we already dealt with that and don't want to change station yet
m_model->changeStation(); m_model->changeStation();
}
m_controlsChanged = false; m_controlsChanged = false;
return; return;
} }
if( !m_playlist.isNull() ) { if ( !m_playlist.isNull() )
{
disconnect( m_playlist->generator().data(), SIGNAL( generated( QList<Tomahawk::query_ptr> ) ), this, SLOT( tracksGenerated( QList<Tomahawk::query_ptr> ) ) ); disconnect( m_playlist->generator().data(), SIGNAL( generated( QList<Tomahawk::query_ptr> ) ), this, SLOT( tracksGenerated( QList<Tomahawk::query_ptr> ) ) );
disconnect( m_playlist.data(), SIGNAL( dynamicRevisionLoaded( Tomahawk::DynamicPlaylistRevision) ), this, SLOT(onRevisionLoaded( Tomahawk::DynamicPlaylistRevision) ) ); disconnect( m_playlist.data(), SIGNAL( dynamicRevisionLoaded( Tomahawk::DynamicPlaylistRevision) ), this, SLOT(onRevisionLoaded( Tomahawk::DynamicPlaylistRevision) ) );
disconnect( m_playlist->generator().data(), SIGNAL( error( QString, QString ) ), this, SLOT( generatorError( QString, QString ) ) ); disconnect( m_playlist->generator().data(), SIGNAL( error( QString, QString ) ), this, SLOT( generatorError( QString, QString ) ) );
@@ -160,23 +162,22 @@ DynamicWidget::loadDynamicPlaylist( const Tomahawk::dynplaylist_ptr& playlist )
m_setup->setPlaylist( m_playlist ); m_setup->setPlaylist( m_playlist );
if( !m_playlist->author()->isLocal() ) { // hide controls, as we show the description in the summary if ( !m_playlist->author()->isLocal() ) // hide controls, as we show the description in the summary
m_layout->removeWidget( m_controls ); m_layout->removeWidget( m_controls );
} else if( m_layout->indexOf( m_controls ) == -1 ) { else if ( m_layout->indexOf( m_controls ) == -1 )
m_layout->insertWidget( 0, m_controls ); m_layout->insertWidget( 0, m_controls );
}
if( m_playlist->mode() == OnDemand && !m_playlist->generator()->controls().isEmpty() )
showPreview();
if( !m_playlist.isNull() )
m_controls->setControls( m_playlist, m_playlist->author()->isLocal() );
connect( m_playlist->generator().data(), SIGNAL( generated( QList<Tomahawk::query_ptr> ) ), this, SLOT( tracksGenerated( QList<Tomahawk::query_ptr> ) ) ); connect( m_playlist->generator().data(), SIGNAL( generated( QList<Tomahawk::query_ptr> ) ), this, SLOT( tracksGenerated( QList<Tomahawk::query_ptr> ) ) );
connect( m_playlist.data(), SIGNAL( dynamicRevisionLoaded( Tomahawk::DynamicPlaylistRevision ) ), this, SLOT( onRevisionLoaded( Tomahawk::DynamicPlaylistRevision ) ) ); connect( m_playlist.data(), SIGNAL( dynamicRevisionLoaded( Tomahawk::DynamicPlaylistRevision ) ), this, SLOT( onRevisionLoaded( Tomahawk::DynamicPlaylistRevision ) ) );
connect( m_playlist->generator().data(), SIGNAL( error( QString, QString ) ), this, SLOT( generatorError( QString, QString ) ) ); connect( m_playlist->generator().data(), SIGNAL( error( QString, QString ) ), this, SLOT( generatorError( QString, QString ) ) );
connect( m_playlist.data(), SIGNAL( deleted( Tomahawk::dynplaylist_ptr ) ), this, SLOT( onDeleted() ) ); connect( m_playlist.data(), SIGNAL( deleted( Tomahawk::dynplaylist_ptr ) ), this, SLOT( onDeleted() ) );
connect( m_playlist.data(), SIGNAL( changed() ), this, SLOT( onChanged() ) ); connect( m_playlist.data(), SIGNAL( changed() ), this, SLOT( onChanged() ) );
if ( m_playlist->mode() == OnDemand && !m_playlist->generator()->controls().isEmpty() )
showPreview();
if ( !m_playlist.isNull() )
m_controls->setControls( m_playlist, m_playlist->author()->isLocal() );
} }
@@ -226,12 +227,15 @@ DynamicWidget::resizeEvent(QResizeEvent* )
void void
DynamicWidget::layoutFloatingWidgets() DynamicWidget::layoutFloatingWidgets()
{ {
if( !m_runningOnDemand ) { if ( !m_runningOnDemand )
{
int x = ( width() / 2 ) - ( m_setup->size().width() / 2 ); int x = ( width() / 2 ) - ( m_setup->size().width() / 2 );
int y = height() - m_setup->size().height() - 40; // padding int y = height() - m_setup->size().height() - 40; // padding
m_setup->move( x, y ); m_setup->move( x, y );
} else if( m_runningOnDemand && m_steering ) { }
else if( m_runningOnDemand && m_steering )
{
int x = ( width() / 2 ) - ( m_steering->size().width() / 2 ); int x = ( width() / 2 ) - ( m_steering->size().width() / 2 );
int y = height() - m_steering->size().height() - 40; // padding int y = height() - m_steering->size().height() - 40; // padding
@@ -243,13 +247,15 @@ DynamicWidget::layoutFloatingWidgets()
void void
DynamicWidget::playlistChanged( Tomahawk::playlistinterface_ptr pl ) DynamicWidget::playlistChanged( Tomahawk::playlistinterface_ptr pl )
{ {
if( pl == m_view->proxyModel()->playlistInterface() ) { // same playlist if ( pl == m_view->proxyModel()->playlistInterface() ) // same playlist
m_activePlaylist = true; m_activePlaylist = true;
} else { else
{
m_activePlaylist = false; m_activePlaylist = false;
// user started playing something somewhere else, so give it a rest // user started playing something somewhere else, so give it a rest
if( m_runningOnDemand ) { if ( m_runningOnDemand )
{
stopStation( false ); stopStation( false );
} }
} }
@@ -259,10 +265,9 @@ DynamicWidget::playlistChanged( Tomahawk::playlistinterface_ptr pl )
void void
DynamicWidget::showEvent(QShowEvent* ) DynamicWidget::showEvent(QShowEvent* )
{ {
if( !m_playlist.isNull() && !m_runningOnDemand ) { if ( !m_playlist.isNull() && !m_runningOnDemand )
m_setup->fadeIn(); m_setup->fadeIn();
} }
}
void void
@@ -290,7 +295,8 @@ void
DynamicWidget::trackStarted() DynamicWidget::trackStarted()
{ {
if ( m_activePlaylist && !m_playlist.isNull() && if ( m_activePlaylist && !m_playlist.isNull() &&
m_playlist->mode() == OnDemand && !m_runningOnDemand ) { m_playlist->mode() == OnDemand && !m_runningOnDemand )
{
startStation(); startStation();
} }
@@ -325,7 +331,8 @@ DynamicWidget::startStation()
m_setup->fadeOut(); m_setup->fadeOut();
// show the steering controls // show the steering controls
if( m_playlist->generator()->onDemandSteerable() ) { if ( m_playlist->generator()->onDemandSteerable() )
{
// position it horizontally centered, above the botton. // position it horizontally centered, above the botton.
m_steering = m_playlist->generator()->steeringWidget(); m_steering = m_playlist->generator()->steeringWidget();
Q_ASSERT( m_steering ); Q_ASSERT( m_steering );
@@ -455,9 +462,9 @@ DynamicWidget::showPreview()
void void
DynamicWidget::generatorError( const QString& title, const QString& content ) DynamicWidget::generatorError( const QString& title, const QString& content )
{ {
if( m_runningOnDemand ) { if ( m_runningOnDemand )
stopStation( false ); stopStation( false );
}
m_view->setDynamicWorking( false ); m_view->setDynamicWorking( false );
m_loading->fadeOut(); m_loading->fadeOut();
m_view->showMessageTimeout( title, content ); m_view->showMessageTimeout( title, content );