1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-12 09:04:33 +02:00

* Improved behaviour: If you click AudioControl's track title, it will jump back to the currently playing playlist (in case you switched to a different playlist / collection in the meantime).

* A few cleanups in AudioEngine & AudioControls.
This commit is contained in:
Christian Muehlhaeuser
2010-11-16 06:48:07 +01:00
parent 8e48e61843
commit 6a508430c4
5 changed files with 46 additions and 22 deletions

View File

@@ -268,6 +268,7 @@ AudioEngine::playItem( PlaylistInterface* playlist, const Tomahawk::result_ptr&
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
m_playlist = playlist; m_playlist = playlist;
m_currentPlaylist = playlist;
loadTrack( result ); loadTrack( result );
} }

View File

@@ -28,19 +28,11 @@ public:
unsigned int volume() { if ( m_audio ) return m_audio->volume() * 100.0; else return 0; }; // in percent unsigned int volume() { if ( m_audio ) return m_audio->volume() * 100.0; else return 0; }; // in percent
signals: /* Returns the PlaylistInterface of the currently playing track. Note: This might be different to the current playlist! */
void loading( const Tomahawk::result_ptr& track ); PlaylistInterface* currentPlaylist() const { return m_currentPlaylist; }
void started( const Tomahawk::result_ptr& track );
void stopped();
void paused();
void resumed();
void volumeChanged( int volume /* in percent */ ); /* Returns the PlaylistInterface of the current playlist. Note: The currently playing track might still be from a different playlist! */
PlaylistInterface* playlist() const { return m_playlist; }
void timerSeconds( unsigned int secondsElapsed );
void timerPercentage( unsigned int percentage );
void error( AudioErrorCode errorCode );
public slots: public slots:
void play(); void play();
@@ -60,6 +52,20 @@ public slots:
void onTrackAboutToClose(); void onTrackAboutToClose();
signals:
void loading( const Tomahawk::result_ptr& track );
void started( const Tomahawk::result_ptr& track );
void stopped();
void paused();
void resumed();
void volumeChanged( int volume /* in percent */ );
void timerSeconds( unsigned int secondsElapsed );
void timerPercentage( unsigned int percentage );
void error( AudioErrorCode errorCode );
private slots: private slots:
bool loadTrack( const Tomahawk::result_ptr& result ); bool loadTrack( const Tomahawk::result_ptr& result );
void loadPreviousTrack(); void loadPreviousTrack();
@@ -86,6 +92,7 @@ private:
Tomahawk::result_ptr m_currentTrack; Tomahawk::result_ptr m_currentTrack;
Tomahawk::result_ptr m_lastTrack; Tomahawk::result_ptr m_lastTrack;
PlaylistInterface* m_playlist; PlaylistInterface* m_playlist;
PlaylistInterface* m_currentPlaylist;
QMutex m_mutex; QMutex m_mutex;
int m_i; int m_i;

View File

@@ -194,7 +194,7 @@ AudioControls::onCoverArtDownloaded()
} }
else else
{ {
// qDebug() << "Following redirect to" << redir.toString(); // Follow HTTP redirect
QNetworkRequest req( redir ); QNetworkRequest req( redir );
QNetworkReply* reply = APP->nam()->get( req ); QNetworkReply* reply = APP->nam()->get( req );
connect( reply, SIGNAL( finished() ), SLOT( onCoverArtDownloaded() ) ); connect( reply, SIGNAL( finished() ), SLOT( onCoverArtDownloaded() ) );
@@ -231,7 +231,7 @@ AudioControls::onPlaybackLoading( const Tomahawk::result_ptr& result )
ui->coverImage->setPixmap( m_defaultCover ); ui->coverImage->setPixmap( m_defaultCover );
if ( ui->timeLabel->text().isEmpty() ) if ( ui->timeLabel->text().isEmpty() )
ui->timeLabel->setText( "00:00" ); ui->timeLabel->setText( TomahawkUtils::timeToString( 0 ) );
if ( ui->timeLeftLabel->text().isEmpty() ) if ( ui->timeLeftLabel->text().isEmpty() )
ui->timeLeftLabel->setText( "-" + TomahawkUtils::timeToString( result->duration() ) ); ui->timeLeftLabel->setText( "-" + TomahawkUtils::timeToString( result->duration() ) );

View File

@@ -269,6 +269,30 @@ PlaylistManager::setShuffled( bool enabled )
void void
PlaylistManager::showCurrentTrack() PlaylistManager::showCurrentTrack()
{ {
bool found = false;
foreach ( const QList<PlaylistView*>& pv, m_views.values() )
{
if ( APP->audioEngine()->currentPlaylist() == pv.first()->proxyModel() )
{
Tomahawk::playlist_ptr pptr = m_views.key( pv );
show( pptr );
found = true;
}
}
if ( !found )
{
foreach ( const QList<CollectionView*>& pv, m_collectionViews.values() )
{
if ( APP->audioEngine()->currentPlaylist() == pv.first()->proxyModel() )
{
Tomahawk::collection_ptr cptr = m_collectionViews.key( pv );
show( cptr );
}
}
}
if ( m_currentView && m_currentProxyModel ) if ( m_currentView && m_currentProxyModel )
m_currentView->scrollTo( m_currentProxyModel->currentItem(), QAbstractItemView::PositionAtCenter ); m_currentView->scrollTo( m_currentProxyModel->currentItem(), QAbstractItemView::PositionAtCenter );
} }

View File

@@ -162,14 +162,6 @@ SourceTreeView::onItemActivated( const QModelIndex& index )
void void
SourceTreeView::onSelectionChanged() SourceTreeView::onSelectionChanged()
{ {
/* QModelIndexList si = selectedIndexes();
foreach( const QModelIndex& idx, si )
{
int type = SourcesModel::indexType( idx );
if ( type == 0 )
selectionModel()->select( idx, QItemSelectionModel::Deselect );
}*/
} }