From 8945577fcd771170c8449e0ef73f97c7b59b51c0 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sun, 27 Feb 2011 05:03:18 +0100 Subject: [PATCH 1/2] * Fixed selecting Super Collection when it becomes active. --- src/libtomahawk/playlist/playlistmanager.cpp | 42 ++++++++++---------- src/libtomahawk/playlist/playlistmanager.h | 5 +-- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/libtomahawk/playlist/playlistmanager.cpp b/src/libtomahawk/playlist/playlistmanager.cpp index 7eceac460..d36e97edc 100644 --- a/src/libtomahawk/playlist/playlistmanager.cpp +++ b/src/libtomahawk/playlist/playlistmanager.cpp @@ -47,7 +47,6 @@ PlaylistManager::PlaylistManager( QObject* parent ) , m_widget( new QWidget() ) , m_welcomeWidget( new WelcomeWidget() ) , m_currentMode( 0 ) - , m_superCollectionVisible( true ) { s_instance = this; @@ -151,11 +150,9 @@ PlaylistManager::show( const Tomahawk::playlist_ptr& playlist ) } setPage( view ); - m_superCollectionVisible = false; - TomahawkSettings::instance()->appendRecentlyPlayedPlaylist( playlist ); - emit numSourcesChanged( SourceList::instance()->count() ); + return true; } @@ -177,11 +174,9 @@ PlaylistManager::show( const Tomahawk::dynplaylist_ptr& playlist ) else m_queueView->show(); - m_superCollectionVisible = false; - TomahawkSettings::instance()->appendRecentlyPlayedPlaylist( playlist ); - emit numSourcesChanged( SourceList::instance()->count() ); + return true; } @@ -208,9 +203,8 @@ PlaylistManager::show( const Tomahawk::artist_ptr& artist ) } setPage( view ); - m_superCollectionVisible = false; - emit numSourcesChanged( 1 ); + return true; } @@ -236,9 +230,8 @@ PlaylistManager::show( const Tomahawk::album_ptr& album ) } setPage( view ); - m_superCollectionVisible = false; - emit numSourcesChanged( 1 ); + return true; } @@ -291,9 +284,8 @@ PlaylistManager::show( const Tomahawk::collection_ptr& collection ) setPage( aview ); } - m_superCollectionVisible = false; - emit numSourcesChanged( 1 ); + return true; } @@ -313,9 +305,8 @@ PlaylistManager::show( const Tomahawk::source_ptr& source ) } setPage( swidget ); - m_superCollectionVisible = false; - emit numSourcesChanged( 1 ); + return true; } @@ -329,7 +320,6 @@ PlaylistManager::show( ViewPage* page ) } setPage( page ); - m_superCollectionVisible = false; return true; } @@ -360,9 +350,8 @@ PlaylistManager::showSuperCollection() setPage( m_superAlbumView ); } - m_superCollectionVisible = true; - emit numSourcesChanged( m_superCollections.count() ); + return true; } @@ -381,7 +370,7 @@ PlaylistManager::setTableMode() m_currentMode = 0; - if ( m_superCollectionVisible ) + if ( isSuperCollectionVisible() ) showSuperCollection(); else show( m_currentCollection ); @@ -397,7 +386,7 @@ PlaylistManager::setTreeMode() m_currentMode = 1; - if ( m_superCollectionVisible ) + if ( isSuperCollectionVisible() ) showSuperCollection(); else show( m_currentCollection ); @@ -411,7 +400,7 @@ PlaylistManager::setAlbumMode() m_currentMode = 2; - if ( m_superCollectionVisible ) + if ( isSuperCollectionVisible() ) showSuperCollection(); else show( m_currentCollection ); @@ -531,6 +520,8 @@ PlaylistManager::setPage( ViewPage* page, bool trackHistory ) emit dynamicPlaylistActivated( dynamicPlaylistForInterface( currentPlaylistInterface() ) ); if ( collectionForInterface( currentPlaylistInterface() ) ) emit collectionActivated( collectionForInterface( currentPlaylistInterface() ) ); + if ( isSuperCollectionVisible() ) + emit superCollectionActivated(); if ( !currentPlaylistInterface() ) emit tempPageActivated(); @@ -781,6 +772,15 @@ PlaylistManager::collectionForInterface( PlaylistInterface* interface ) const } +bool +PlaylistManager::isSuperCollectionVisible() const +{ + return ( m_pageHistory.count() && + ( currentPage()->playlistInterface() == m_superCollectionView->playlistInterface() || + currentPage()->playlistInterface() == m_superAlbumView->playlistInterface() ) ); +} + + void PlaylistManager::showCurrentTrack() { diff --git a/src/libtomahawk/playlist/playlistmanager.h b/src/libtomahawk/playlist/playlistmanager.h index 722f7286e..a1729a5d1 100644 --- a/src/libtomahawk/playlist/playlistmanager.h +++ b/src/libtomahawk/playlist/playlistmanager.h @@ -46,7 +46,7 @@ public: QWidget* widget() const { return m_widget; } PlaylistView* queue() const; - bool isSuperCollectionVisible() const { return true; } + bool isSuperCollectionVisible() const; PlaylistInterface* currentPlaylistInterface() const; Tomahawk::ViewPage* currentPage() const; @@ -118,7 +118,6 @@ public slots: private slots: void applyFilter(); - void onWidgetDestroyed( QWidget* widget ); private: @@ -160,9 +159,7 @@ private: int m_historyPosition; Tomahawk::collection_ptr m_currentCollection; - int m_currentMode; - bool m_superCollectionVisible; QTimer m_filterTimer; QString m_filter; From 38b0519b1a3c21d1719030d4ab976b82cce6ee2c Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sun, 27 Feb 2011 16:05:23 +0100 Subject: [PATCH 2/2] * Fixed resetting the active playlist. --- src/libtomahawk/audio/audioengine.h | 3 ++- src/libtomahawk/playlist/playlistmanager.cpp | 2 +- src/libtomahawk/playlist/playlistmanager.h | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libtomahawk/audio/audioengine.h b/src/libtomahawk/audio/audioengine.h index a94a5359b..b83eb9bf1 100644 --- a/src/libtomahawk/audio/audioengine.h +++ b/src/libtomahawk/audio/audioengine.h @@ -32,7 +32,8 @@ public: unsigned int volume() const { if ( m_audio ) return m_audio->volume() * 100.0; else return 0; }; // in percent bool isPaused() const { return m_audio->isPaused(); } - + bool isPlaying() const { return m_audio->isPlaying(); } + /* Returns the PlaylistInterface of the currently playing track. Note: This might be different to the current playlist! */ PlaylistInterface* currentTrackPlaylist() const { return m_currentTrackPlaylist; } diff --git a/src/libtomahawk/playlist/playlistmanager.cpp b/src/libtomahawk/playlist/playlistmanager.cpp index d36e97edc..b8062fb86 100644 --- a/src/libtomahawk/playlist/playlistmanager.cpp +++ b/src/libtomahawk/playlist/playlistmanager.cpp @@ -525,7 +525,7 @@ PlaylistManager::setPage( ViewPage* page, bool trackHistory ) if ( !currentPlaylistInterface() ) emit tempPageActivated(); - if ( !AudioEngine::instance()->playlist() ) + if ( !AudioEngine::instance()->isPlaying() ) AudioEngine::instance()->setPlaylist( currentPlaylistInterface() ); m_stack->setCurrentWidget( page->widget() ); diff --git a/src/libtomahawk/playlist/playlistmanager.h b/src/libtomahawk/playlist/playlistmanager.h index a1729a5d1..4cab2f398 100644 --- a/src/libtomahawk/playlist/playlistmanager.h +++ b/src/libtomahawk/playlist/playlistmanager.h @@ -103,8 +103,6 @@ public slots: void showQueue(); void hideQueue(); - void setFilter( const QString& filter ); - void setRepeatMode( PlaylistInterface::RepeatMode mode ); void setShuffled( bool enabled ); @@ -117,6 +115,7 @@ public slots: void onPauseClicked(); private slots: + void setFilter( const QString& filter ); void applyFilter(); void onWidgetDestroyed( QWidget* widget );