1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 11:20:22 +02:00

Refresh stations preview whenever controls are changed

This commit is contained in:
Leo Franchi
2011-10-20 17:23:58 -04:00
parent f796f1f133
commit be737a24f2
6 changed files with 16 additions and 9 deletions

View File

@@ -120,7 +120,7 @@ CollapsibleControls::init()
m_layout->setCurrentWidget( m_summary ); m_layout->setCurrentWidget( m_summary );
connect( m_controls, SIGNAL( controlChanged( Tomahawk::dyncontrol_ptr ) ), SIGNAL( controlChanged( Tomahawk::dyncontrol_ptr ) ) ); connect( m_controls, SIGNAL( controlChanged( Tomahawk::dyncontrol_ptr ) ), SIGNAL( controlChanged( Tomahawk::dyncontrol_ptr ) ) );
connect( m_controls, SIGNAL( controlsChanged() ), SIGNAL( controlsChanged() ) ); connect( m_controls, SIGNAL( controlsChanged( bool ) ), SIGNAL( controlsChanged( bool ) ) );
setLayout( m_layout ); setLayout( m_layout );

View File

@@ -49,7 +49,7 @@ public:
virtual QSize sizeHint() const; virtual QSize sizeHint() const;
signals: signals:
void controlsChanged(); void controlsChanged( bool added );
void controlChanged( const Tomahawk::dyncontrol_ptr& control ); void controlChanged( const Tomahawk::dyncontrol_ptr& control );
private slots: private slots:

View File

@@ -156,7 +156,7 @@ DynamicControlList::addNewControl()
connect( m_controls.last(), SIGNAL( changed() ), this, SLOT( controlChanged() ) ); connect( m_controls.last(), SIGNAL( changed() ), this, SLOT( controlChanged() ) );
m_layout->addItem( m_collapseLayout, m_layout->rowCount(), 0, 1, 4, Qt::AlignCenter ); m_layout->addItem( m_collapseLayout, m_layout->rowCount(), 0, 1, 4, Qt::AlignCenter );
emit controlsChanged(); emit controlsChanged( true );
} }
@@ -170,7 +170,7 @@ DynamicControlList::removeControl()
m_generator->removeControl( w->control() ); m_generator->removeControl( w->control() );
delete w; delete w;
emit controlsChanged(); emit controlsChanged( false );
} }

View File

@@ -53,7 +53,7 @@ public:
QList< DynamicControlWrapper* > controls() const { return m_controls; } QList< DynamicControlWrapper* > controls() const { return m_controls; }
signals: signals:
void controlsChanged(); void controlsChanged( bool added );
void controlChanged( const Tomahawk::dyncontrol_ptr& control ); void controlChanged( const Tomahawk::dyncontrol_ptr& control );
void toggleCollapse(); void toggleCollapse();

View File

@@ -95,7 +95,7 @@ DynamicWidget::DynamicWidget( const Tomahawk::dynplaylist_ptr& playlist, QWidget
layoutFloatingWidgets(); layoutFloatingWidgets();
connect( m_controls, SIGNAL( controlChanged( Tomahawk::dyncontrol_ptr ) ), this, SLOT( controlChanged( Tomahawk::dyncontrol_ptr ) ), Qt::QueuedConnection ); connect( m_controls, SIGNAL( controlChanged( Tomahawk::dyncontrol_ptr ) ), this, SLOT( controlChanged( Tomahawk::dyncontrol_ptr ) ), Qt::QueuedConnection );
connect( m_controls, SIGNAL( controlsChanged() ), this, SLOT( controlsChanged() ), Qt::QueuedConnection ); connect( m_controls, SIGNAL( controlsChanged( bool ) ), this, SLOT( controlsChanged( bool ) ), Qt::QueuedConnection );
connect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), this, SLOT( trackStarted() ) ); connect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), this, SLOT( trackStarted() ) );
connect( AudioEngine::instance(), SIGNAL( playlistChanged( Tomahawk::PlaylistInterface* ) ), this, SLOT( playlistChanged( Tomahawk::PlaylistInterface* ) ) ); connect( AudioEngine::instance(), SIGNAL( playlistChanged( Tomahawk::PlaylistInterface* ) ), this, SLOT( playlistChanged( Tomahawk::PlaylistInterface* ) ) );
@@ -361,7 +361,7 @@ DynamicWidget::tracksGenerated( const QList< query_ptr >& queries )
void void
DynamicWidget::controlsChanged() DynamicWidget::controlsChanged( bool added )
{ {
// controlsChanged() is emitted when a control is added or removed // controlsChanged() is emitted when a control is added or removed
// in the case of addition, it's blank by default... so to avoid an error // in the case of addition, it's blank by default... so to avoid an error
@@ -373,6 +373,9 @@ DynamicWidget::controlsChanged()
m_playlist->createNewRevision(); m_playlist->createNewRevision();
m_seqRevLaunched++; m_seqRevLaunched++;
if ( !added )
showPreview();
emit descriptionChanged( m_playlist->generator()->sentenceSummary() ); emit descriptionChanged( m_playlist->generator()->sentenceSummary() );
} }
@@ -395,7 +398,11 @@ DynamicWidget::controlChanged( const Tomahawk::dyncontrol_ptr& control )
void void
DynamicWidget::showPreview() DynamicWidget::showPreview()
{ {
if( m_playlist->mode() == OnDemand && !m_runningOnDemand && m_model->rowCount( QModelIndex() ) == 0 ) { // if this is a not running station, preview matching tracks if ( m_playlist->mode() == OnDemand &&
!m_runningOnDemand )
{
// if this is a not running station, preview matching tracks
m_model->clear();
generate( 20 ); // ask for more, we'll filter how many we actually want generate( 20 ); // ask for more, we'll filter how many we actually want
} }
} }

View File

@@ -101,7 +101,7 @@ private slots:
void tracksGenerated( const QList< Tomahawk::query_ptr>& queries ); void tracksGenerated( const QList< Tomahawk::query_ptr>& queries );
void generatorError( const QString& title, const QString& content ); void generatorError( const QString& title, const QString& content );
void controlsChanged(); void controlsChanged( bool added );
void controlChanged( const Tomahawk::dyncontrol_ptr& control ); void controlChanged( const Tomahawk::dyncontrol_ptr& control );
void showPreview(); void showPreview();