mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-08 07:07:05 +02: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:
@@ -74,6 +74,8 @@ AudioEngine::AudioEngine()
|
|||||||
|
|
||||||
connect( m_audioOutput, SIGNAL( volumeChanged( qreal ) ), SLOT( onVolumeChanged( qreal ) ) );
|
connect( m_audioOutput, SIGNAL( volumeChanged( qreal ) ), SLOT( onVolumeChanged( qreal ) ) );
|
||||||
|
|
||||||
|
connect( this, SIGNAL( sendWaitingNotification() ), SLOT( sendWaitingNotificationSlot() ), Qt::QueuedConnection );
|
||||||
|
|
||||||
onVolumeChanged( m_audioOutput->volume() );
|
onVolumeChanged( m_audioOutput->volume() );
|
||||||
|
|
||||||
#ifndef Q_WS_X11
|
#ifndef Q_WS_X11
|
||||||
@@ -178,9 +180,7 @@ AudioEngine::stop()
|
|||||||
map[ Tomahawk::InfoSystem::InfoNowStopped ] = QVariant();
|
map[ Tomahawk::InfoSystem::InfoNowStopped ] = QVariant();
|
||||||
|
|
||||||
if ( m_waitingOnNewTrack )
|
if ( m_waitingOnNewTrack )
|
||||||
{
|
emit sendWaitingNotification();
|
||||||
sendWaitingNotification();
|
|
||||||
}
|
|
||||||
else if ( TomahawkSettings::instance()->verboseNotifications() )
|
else if ( TomahawkSettings::instance()->verboseNotifications() )
|
||||||
{
|
{
|
||||||
QVariantMap stopInfo;
|
QVariantMap stopInfo;
|
||||||
@@ -310,8 +310,13 @@ AudioEngine::mute()
|
|||||||
|
|
||||||
|
|
||||||
void
|
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;
|
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." );
|
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(
|
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
|
||||||
@@ -538,7 +543,7 @@ AudioEngine::playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk:
|
|||||||
{
|
{
|
||||||
m_waitingOnNewTrack = true;
|
m_waitingOnNewTrack = true;
|
||||||
if ( isStopped() )
|
if ( isStopped() )
|
||||||
sendWaitingNotification();
|
emit sendWaitingNotification();
|
||||||
else
|
else
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
@@ -112,6 +112,8 @@ signals:
|
|||||||
|
|
||||||
void error( AudioEngine::AudioErrorCode errorCode );
|
void error( AudioEngine::AudioErrorCode errorCode );
|
||||||
|
|
||||||
|
void sendWaitingNotification();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
bool loadTrack( const Tomahawk::result_ptr& result );
|
bool loadTrack( const Tomahawk::result_ptr& result );
|
||||||
void loadPreviousTrack();
|
void loadPreviousTrack();
|
||||||
@@ -126,13 +128,14 @@ private slots:
|
|||||||
void onNowPlayingInfoReady();
|
void onNowPlayingInfoReady();
|
||||||
void onPlaylistNextTrackReady();
|
void onPlaylistNextTrackReady();
|
||||||
|
|
||||||
|
void sendWaitingNotificationSlot() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setState( AudioState state );
|
void setState( AudioState state );
|
||||||
|
|
||||||
bool isHttpResult( const QString& ) const;
|
bool isHttpResult( const QString& ) const;
|
||||||
bool isLocalResult( const QString& ) const;
|
bool isLocalResult( const QString& ) const;
|
||||||
|
|
||||||
void sendWaitingNotification() const;
|
|
||||||
void sendNowPlayingNotification();
|
void sendNowPlayingNotification();
|
||||||
|
|
||||||
QSharedPointer<QIODevice> m_input;
|
QSharedPointer<QIODevice> m_input;
|
||||||
|
@@ -89,6 +89,7 @@ signals:
|
|||||||
void shuffleModeChanged( bool enabled );
|
void shuffleModeChanged( bool enabled );
|
||||||
void trackCountChanged( unsigned int tracks );
|
void trackCountChanged( unsigned int tracks );
|
||||||
void sourceTrackCountChanged( unsigned int tracks );
|
void sourceTrackCountChanged( unsigned int tracks );
|
||||||
|
void latchModeChanged( Tomahawk::PlaylistInterface::LatchMode mode );
|
||||||
void nextTrackReady();
|
void nextTrackReady();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@@ -61,15 +61,15 @@ Tomahawk::result_ptr
|
|||||||
SourcePlaylistInterface::nextItem()
|
SourcePlaylistInterface::nextItem()
|
||||||
{
|
{
|
||||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
|
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();
|
m_currentItem = Tomahawk::result_ptr();
|
||||||
return m_currentItem;
|
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();
|
return Tomahawk::result_ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,10 +87,20 @@ SourcePlaylistInterface::currentItem() const
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SourcePlaylistInterface::hasNextItem()
|
SourcePlaylistInterface::sourceValid()
|
||||||
{
|
{
|
||||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
|
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 false;
|
||||||
|
|
||||||
return m_gotNextItem;
|
return m_gotNextItem;
|
||||||
@@ -115,10 +125,10 @@ SourcePlaylistInterface::source() const
|
|||||||
void
|
void
|
||||||
SourcePlaylistInterface::reset()
|
SourcePlaylistInterface::reset()
|
||||||
{
|
{
|
||||||
if ( !m_currentItem.isNull() )
|
if ( m_currentItem.isNull() )
|
||||||
m_gotNextItem = true;
|
|
||||||
else
|
|
||||||
m_gotNextItem = false;
|
m_gotNextItem = false;
|
||||||
|
else
|
||||||
|
m_gotNextItem = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -128,7 +138,7 @@ SourcePlaylistInterface::onSourcePlaybackStarted( const Tomahawk::query_ptr& que
|
|||||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
|
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
|
||||||
connect( query.data(), SIGNAL( resolvingFinished( bool ) ), SLOT( resolvingFinished( bool ) ) );
|
connect( query.data(), SIGNAL( resolvingFinished( bool ) ), SLOT( resolvingFinished( bool ) ) );
|
||||||
Pipeline::instance()->resolve( query, true );
|
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");
|
tDebug( LOGEXTRA ) << Q_FUNC_INFO << " and has results? : " << (hasResults ? "true" : "false");
|
||||||
if ( hasResults )
|
if ( hasResults )
|
||||||
|
{
|
||||||
|
m_gotNextItem = true;
|
||||||
emit nextTrackReady();
|
emit nextTrackReady();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -44,6 +44,7 @@ public:
|
|||||||
virtual int unfilteredTrackCount() const { return 1; }
|
virtual int unfilteredTrackCount() const { return 1; }
|
||||||
|
|
||||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
|
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
|
||||||
|
virtual bool sourceValid();
|
||||||
virtual bool hasNextItem();
|
virtual bool hasNextItem();
|
||||||
virtual Tomahawk::result_ptr nextItem();
|
virtual Tomahawk::result_ptr nextItem();
|
||||||
virtual Tomahawk::result_ptr currentItem() const;
|
virtual Tomahawk::result_ptr currentItem() const;
|
||||||
@@ -54,6 +55,8 @@ public:
|
|||||||
virtual PlaylistInterface::RetryMode retryMode() const { return Retry; }
|
virtual PlaylistInterface::RetryMode retryMode() const { return Retry; }
|
||||||
virtual quint32 retryInterval() const { return 5000; }
|
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 bool shuffled() const { return false; }
|
||||||
virtual void setFilter( const QString& /*pattern*/ ) {}
|
virtual void setFilter( const QString& /*pattern*/ ) {}
|
||||||
|
|
||||||
|
@@ -209,6 +209,7 @@ SourceItem::latchedOff( const source_ptr& from, const source_ptr& to )
|
|||||||
if ( from->isLocal() && ( m_source == to || m_source == from ) )
|
if ( from->isLocal() && ( m_source == to || m_source == from ) )
|
||||||
{
|
{
|
||||||
m_latchedOn = false;
|
m_latchedOn = false;
|
||||||
|
disconnect( m_latchedOnTo->playlistInterface().data(), SIGNAL( latchModeChanged( Tomahawk::PlaylistInterface::LatchMode ) ) );
|
||||||
m_latchedOnTo.clear();
|
m_latchedOnTo.clear();
|
||||||
emit updated();
|
emit updated();
|
||||||
}
|
}
|
||||||
@@ -222,11 +223,19 @@ SourceItem::latchedOn( const source_ptr& from, const source_ptr& to )
|
|||||||
{
|
{
|
||||||
m_latchedOn = true;
|
m_latchedOn = true;
|
||||||
m_latchedOnTo = to;
|
m_latchedOnTo = to;
|
||||||
|
connect( m_latchedOnTo->playlistInterface().data(), SIGNAL( latchModeChanged( Tomahawk::PlaylistInterface::LatchMode ) ), SLOT( latchModeChanged( Tomahawk::PlaylistInterface::LatchMode ) ) );
|
||||||
emit updated();
|
emit updated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SourceItem::latchModeChanged( Tomahawk::PlaylistInterface::LatchMode mode )
|
||||||
|
{
|
||||||
|
Q_UNUSED( mode );
|
||||||
|
emit updated();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SourceItem::playlistsAddedInternal( SourceTreeItem* parent, const QList< dynplaylist_ptr >& playlists )
|
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 latchedOn( const Tomahawk::source_ptr&, const Tomahawk::source_ptr& );
|
||||||
void latchedOff( 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();
|
void requestExpanding();
|
||||||
|
|
||||||
|
@@ -422,10 +422,12 @@ TomahawkApp::registerMetaTypes()
|
|||||||
qRegisterMetaType< Tomahawk::InfoSystem::InfoType >( "Tomahawk::InfoSystem::InfoType" );
|
qRegisterMetaType< Tomahawk::InfoSystem::InfoType >( "Tomahawk::InfoSystem::InfoType" );
|
||||||
qRegisterMetaType< Tomahawk::InfoSystem::InfoRequestData >( "Tomahawk::InfoSystem::InfoRequestData" );
|
qRegisterMetaType< Tomahawk::InfoSystem::InfoRequestData >( "Tomahawk::InfoSystem::InfoRequestData" );
|
||||||
qRegisterMetaType< Tomahawk::InfoSystem::InfoSystemCache* >( "Tomahawk::InfoSystem::InfoSystemCache*" );
|
qRegisterMetaType< Tomahawk::InfoSystem::InfoSystemCache* >( "Tomahawk::InfoSystem::InfoSystemCache*" );
|
||||||
|
|
||||||
qRegisterMetaType< QList< Tomahawk::InfoSystem::InfoStringHash > >("QList< Tomahawk::InfoSystem::InfoStringHash > ");
|
qRegisterMetaType< QList< Tomahawk::InfoSystem::InfoStringHash > >("QList< Tomahawk::InfoSystem::InfoStringHash > ");
|
||||||
|
|
||||||
qRegisterMetaTypeStreamOperators< QList< Tomahawk::InfoSystem::InfoStringHash > >("QList< Tomahawk::InfoSystem::InfoStringHash > ");
|
qRegisterMetaTypeStreamOperators< QList< Tomahawk::InfoSystem::InfoStringHash > >("QList< Tomahawk::InfoSystem::InfoStringHash > ");
|
||||||
qRegisterMetaType< QPersistentModelIndex >( "QPersistentModelIndex" );
|
qRegisterMetaType< QPersistentModelIndex >( "QPersistentModelIndex" );
|
||||||
|
|
||||||
|
qRegisterMetaType< Tomahawk::PlaylistInterface::LatchMode >( "Tomahawk::PlaylistInterface::LatchMode" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user