mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-18 23:09:42 +01:00
Clean up some sourceplaylistinterface logic to hopefully prevent it
saying that a track couldn't be resolved when it gets resolved right afterwards. Also, have the latch mode changing (for instance on pause) affect the source's icon.
This commit is contained in:
parent
fad6768955
commit
78ad724bac
@ -74,6 +74,8 @@ AudioEngine::AudioEngine()
|
||||
|
||||
connect( m_audioOutput, SIGNAL( volumeChanged( qreal ) ), SLOT( onVolumeChanged( qreal ) ) );
|
||||
|
||||
connect( this, SIGNAL( sendWaitingNotification() ), SLOT( sendWaitingNotificationSlot() ), Qt::QueuedConnection );
|
||||
|
||||
onVolumeChanged( m_audioOutput->volume() );
|
||||
|
||||
#ifndef Q_WS_X11
|
||||
@ -178,9 +180,7 @@ AudioEngine::stop()
|
||||
map[ Tomahawk::InfoSystem::InfoNowStopped ] = QVariant();
|
||||
|
||||
if ( m_waitingOnNewTrack )
|
||||
{
|
||||
sendWaitingNotification();
|
||||
}
|
||||
emit sendWaitingNotification();
|
||||
else if ( TomahawkSettings::instance()->verboseNotifications() )
|
||||
{
|
||||
QVariantMap stopInfo;
|
||||
@ -310,8 +310,13 @@ AudioEngine::mute()
|
||||
|
||||
|
||||
void
|
||||
AudioEngine::sendWaitingNotification() const
|
||||
AudioEngine::sendWaitingNotificationSlot() const
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||
//since it's async, after this is triggered our result could come in, so don't show the popup in that case
|
||||
if ( !m_playlist.isNull() && m_playlist->hasNextItem() )
|
||||
return;
|
||||
|
||||
QVariantMap retryInfo;
|
||||
retryInfo["message"] = QString( "The current track could not be resolved. Tomahawk will pick back up with the next resolvable track from this source." );
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
|
||||
@ -538,7 +543,7 @@ AudioEngine::playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk:
|
||||
{
|
||||
m_waitingOnNewTrack = true;
|
||||
if ( isStopped() )
|
||||
sendWaitingNotification();
|
||||
emit sendWaitingNotification();
|
||||
else
|
||||
stop();
|
||||
}
|
||||
|
@ -112,6 +112,8 @@ signals:
|
||||
|
||||
void error( AudioEngine::AudioErrorCode errorCode );
|
||||
|
||||
void sendWaitingNotification();
|
||||
|
||||
private slots:
|
||||
bool loadTrack( const Tomahawk::result_ptr& result );
|
||||
void loadPreviousTrack();
|
||||
@ -126,13 +128,14 @@ private slots:
|
||||
void onNowPlayingInfoReady();
|
||||
void onPlaylistNextTrackReady();
|
||||
|
||||
void sendWaitingNotificationSlot() const;
|
||||
|
||||
private:
|
||||
void setState( AudioState state );
|
||||
|
||||
bool isHttpResult( const QString& ) const;
|
||||
bool isLocalResult( const QString& ) const;
|
||||
|
||||
void sendWaitingNotification() const;
|
||||
void sendNowPlayingNotification();
|
||||
|
||||
QSharedPointer<QIODevice> m_input;
|
||||
|
@ -89,6 +89,7 @@ signals:
|
||||
void shuffleModeChanged( bool enabled );
|
||||
void trackCountChanged( unsigned int tracks );
|
||||
void sourceTrackCountChanged( unsigned int tracks );
|
||||
void latchModeChanged( Tomahawk::PlaylistInterface::LatchMode mode );
|
||||
void nextTrackReady();
|
||||
|
||||
protected:
|
||||
|
@ -61,15 +61,15 @@ Tomahawk::result_ptr
|
||||
SourcePlaylistInterface::nextItem()
|
||||
{
|
||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
|
||||
if ( m_source.isNull() || m_source.data()->currentTrack().isNull() || m_source.data()->currentTrack()->results().isEmpty() )
|
||||
if ( !sourceValid() )
|
||||
{
|
||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO << " Results were empty for current track or source no longer valid";
|
||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO << " Source no longer valid";
|
||||
m_currentItem = Tomahawk::result_ptr();
|
||||
return m_currentItem;
|
||||
}
|
||||
else if ( !m_gotNextItem )
|
||||
else if ( !hasNextItem() )
|
||||
{
|
||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO << " This song was already fetched";
|
||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO << " This song was already fetched or the source isn't playing anything";
|
||||
return Tomahawk::result_ptr();
|
||||
}
|
||||
|
||||
@ -87,12 +87,22 @@ SourcePlaylistInterface::currentItem() const
|
||||
|
||||
|
||||
bool
|
||||
SourcePlaylistInterface::hasNextItem()
|
||||
SourcePlaylistInterface::sourceValid()
|
||||
{
|
||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
|
||||
if ( m_source.isNull() || m_source.data()->currentTrack().isNull() || m_source.data()->currentTrack()->results().isEmpty() )
|
||||
if ( m_source.isNull() || m_source.data()->currentTrack().isNull() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
SourcePlaylistInterface::hasNextItem()
|
||||
{
|
||||
if ( !sourceValid() )
|
||||
return false;
|
||||
|
||||
return m_gotNextItem;
|
||||
}
|
||||
|
||||
@ -115,10 +125,10 @@ SourcePlaylistInterface::source() const
|
||||
void
|
||||
SourcePlaylistInterface::reset()
|
||||
{
|
||||
if ( !m_currentItem.isNull() )
|
||||
m_gotNextItem = true;
|
||||
else
|
||||
if ( m_currentItem.isNull() )
|
||||
m_gotNextItem = false;
|
||||
else
|
||||
m_gotNextItem = true;
|
||||
}
|
||||
|
||||
|
||||
@ -128,7 +138,7 @@ SourcePlaylistInterface::onSourcePlaybackStarted( const Tomahawk::query_ptr& que
|
||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
|
||||
connect( query.data(), SIGNAL( resolvingFinished( bool ) ), SLOT( resolvingFinished( bool ) ) );
|
||||
Pipeline::instance()->resolve( query, true );
|
||||
m_gotNextItem = true;
|
||||
m_gotNextItem = false;
|
||||
}
|
||||
|
||||
|
||||
@ -137,5 +147,8 @@ SourcePlaylistInterface::resolvingFinished( bool hasResults )
|
||||
{
|
||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO << " and has results? : " << (hasResults ? "true" : "false");
|
||||
if ( hasResults )
|
||||
{
|
||||
m_gotNextItem = true;
|
||||
emit nextTrackReady();
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ public:
|
||||
virtual int unfilteredTrackCount() const { return 1; }
|
||||
|
||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
|
||||
virtual bool sourceValid();
|
||||
virtual bool hasNextItem();
|
||||
virtual Tomahawk::result_ptr nextItem();
|
||||
virtual Tomahawk::result_ptr currentItem() const;
|
||||
@ -54,6 +55,8 @@ public:
|
||||
virtual PlaylistInterface::RetryMode retryMode() const { return Retry; }
|
||||
virtual quint32 retryInterval() const { return 5000; }
|
||||
|
||||
virtual void setLatchMode( PlaylistInterface::LatchMode latchMode ) { m_latchMode = latchMode; emit latchModeChanged( latchMode ); }
|
||||
|
||||
virtual bool shuffled() const { return false; }
|
||||
virtual void setFilter( const QString& /*pattern*/ ) {}
|
||||
|
||||
|
@ -108,7 +108,7 @@ SourceItem::SourceItem( SourcesModel* mdl, SourceTreeItem* parent, const Tomahaw
|
||||
SLOT( onAutoPlaylistsAdded( QList<Tomahawk::dynplaylist_ptr> ) ), Qt::QueuedConnection );
|
||||
connect( source->collection().data(), SIGNAL( stationsAdded( QList<Tomahawk::dynplaylist_ptr> ) ),
|
||||
SLOT( onStationsAdded( QList<Tomahawk::dynplaylist_ptr> ) ), Qt::QueuedConnection );
|
||||
|
||||
|
||||
if ( m_source->isLocal() )
|
||||
QTimer::singleShot( 0, this, SLOT( requestExpanding() ) );
|
||||
}
|
||||
@ -209,6 +209,7 @@ SourceItem::latchedOff( const source_ptr& from, const source_ptr& to )
|
||||
if ( from->isLocal() && ( m_source == to || m_source == from ) )
|
||||
{
|
||||
m_latchedOn = false;
|
||||
disconnect( m_latchedOnTo->playlistInterface().data(), SIGNAL( latchModeChanged( Tomahawk::PlaylistInterface::LatchMode ) ) );
|
||||
m_latchedOnTo.clear();
|
||||
emit updated();
|
||||
}
|
||||
@ -222,11 +223,19 @@ SourceItem::latchedOn( const source_ptr& from, const source_ptr& to )
|
||||
{
|
||||
m_latchedOn = true;
|
||||
m_latchedOnTo = to;
|
||||
connect( m_latchedOnTo->playlistInterface().data(), SIGNAL( latchModeChanged( Tomahawk::PlaylistInterface::LatchMode ) ), SLOT( latchModeChanged( Tomahawk::PlaylistInterface::LatchMode ) ) );
|
||||
emit updated();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourceItem::latchModeChanged( Tomahawk::PlaylistInterface::LatchMode mode )
|
||||
{
|
||||
Q_UNUSED( mode );
|
||||
emit updated();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourceItem::playlistsAddedInternal( SourceTreeItem* parent, const QList< dynplaylist_ptr >& playlists )
|
||||
|
@ -64,6 +64,7 @@ private slots:
|
||||
|
||||
void latchedOn( const Tomahawk::source_ptr&, const Tomahawk::source_ptr& );
|
||||
void latchedOff( const Tomahawk::source_ptr&, const Tomahawk::source_ptr& );
|
||||
void latchModeChanged( Tomahawk::PlaylistInterface::LatchMode mode );
|
||||
|
||||
void requestExpanding();
|
||||
|
||||
|
@ -422,10 +422,12 @@ TomahawkApp::registerMetaTypes()
|
||||
qRegisterMetaType< Tomahawk::InfoSystem::InfoType >( "Tomahawk::InfoSystem::InfoType" );
|
||||
qRegisterMetaType< Tomahawk::InfoSystem::InfoRequestData >( "Tomahawk::InfoSystem::InfoRequestData" );
|
||||
qRegisterMetaType< Tomahawk::InfoSystem::InfoSystemCache* >( "Tomahawk::InfoSystem::InfoSystemCache*" );
|
||||
|
||||
qRegisterMetaType< QList< Tomahawk::InfoSystem::InfoStringHash > >("QList< Tomahawk::InfoSystem::InfoStringHash > ");
|
||||
|
||||
qRegisterMetaTypeStreamOperators< QList< Tomahawk::InfoSystem::InfoStringHash > >("QList< Tomahawk::InfoSystem::InfoStringHash > ");
|
||||
qRegisterMetaType< QPersistentModelIndex >( "QPersistentModelIndex" );
|
||||
|
||||
qRegisterMetaType< Tomahawk::PlaylistInterface::LatchMode >( "Tomahawk::PlaylistInterface::LatchMode" );
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user