extragear/multimedia/amarok/src/statusbar
Maximilian Kossick
maximilian.kossick at googlemail.com
Wed Jul 9 12:54:52 CEST 2008
A similar problem still exists with the progressbar: the progress bar
changes its length on start/stop of a track because the right time
label is shown/hidden
On Wed, Jul 9, 2008 at 8:47 AM, Nikolaj Hald Nielsen
<nhnFreespirit at gmail.com> wrote:
> SVN commit 829791 by nhnielsen:
>
> Make the status bar much more consistently display info ( instead of just being blank ) especially in relation to streams with changing meta data. Also make if flicker a lot less by not clearing the text ever time a new event is
> recieved.
>
>
>
> M +86 -48 StatusBar.cpp
> M +11 -1 StatusBar.h
>
>
> --- trunk/extragear/multimedia/amarok/src/statusbar/StatusBar.cpp #829790:829791
> @@ -3,6 +3,7 @@
> * (C) 2004 Frederik Holljen <fh at ez.no> *
> * (C) 2005 Gábor Lehel <illissius at gmail.com> *
> * (C) 2007 Seb Ruiz <ruiz at kde.org> *
> + * (C) 2008 Nikolaj Hald Nielsen <nhnFreespirit at gmail.com> *
> * *
> * This program is free software; you can redistribute it and/or modify *
> * it under the terms of the GNU General Public License as published by *
> @@ -17,7 +18,7 @@
> * You should have received a copy of the GNU General Public License *
> * along with this program; if not, write to the *
> * Free Software Foundation, Inc., *
> - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
> + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
> ***************************************************************************/
>
> #include "StatusBar.h"
> @@ -60,10 +61,15 @@
> void
> StatusBar::engineStateChanged( Phonon::State state, Phonon::State /*oldState*/ )
> {
> + DEBUG_BLOCK
> switch ( state ) {
> case Phonon::StoppedState:
> case Phonon::LoadingState:
> - setMainText( QString() );
> + debug() << "LoadingState: clear text";
> + if ( m_currentTrack )
> + updateInfo( m_currentTrack );
> + else
> + setMainText( QString() );
> break;
>
> case Phonon::PausedState:
> @@ -71,7 +77,11 @@
> break;
>
> case Phonon::PlayingState:
> - resetMainText(); // if we were paused, this is necessary
> + debug() << "PlayingState: clear text";
> + if ( m_currentTrack )
> + updateInfo( m_currentTrack );
> + else
> + resetMainText(); // if we were paused, this is necessary
> break;
>
> case Phonon::ErrorState:
> @@ -84,11 +94,81 @@
> void
> StatusBar::engineNewTrackPlaying()
> {
> - Meta::TrackPtr track = The::engineController()->currentTrack();
>
> - if( !track )
> + DEBUG_BLOCK
> +
> + if( m_currentTrack )
> + unsubscribeFrom( m_currentTrack );
> +
> + m_currentTrack = The::engineController()->currentTrack();
> +
> + if( !m_currentTrack ) {
> + m_currentTrack = Meta::TrackPtr();
> + debug() << "no track";
> return;
> + }
>
> + subscribeTo( m_currentTrack );
> +
> + updateInfo( m_currentTrack );
> +
> +
> +
> +}
> +
> +///////////////////
> +//MessageQueue
> +///////////////////
> +
> +MessageQueue::MessageQueue()
> + : m_queueMessages( true )
> +{
> + DEBUG_BLOCK
> +}
> +
> +MessageQueue::~MessageQueue()
> +{
> + DEBUG_BLOCK
> +}
> +
> +K_GLOBAL_STATIC( MessageQueue, s_messageQueue );
> +
> +MessageQueue*
> +MessageQueue::instance()
> +{
> + return s_messageQueue;
> +}
> +
> +void
> +MessageQueue::addMessage(const QString& message)
> +{
> + if(m_queueMessages)
> + m_messages.push(message);
> + else
> + StatusBar::instance()->longMessage(message);
> +}
> +
> +void
> +MessageQueue::sendMessages()
> +{
> + m_queueMessages = false;
> + while(! m_messages.isEmpty())
> + {
> + StatusBar::instance()->longMessage(m_messages.pop());
> + }
> +}
> +
> +void Amarok::StatusBar::metadataChanged( Meta::Track * track )
> +{
> + if ( m_currentTrack )
> + updateInfo( m_currentTrack );
> + else
> + engineNewTrackPlaying();
> +}
> +
> +void Amarok::StatusBar::updateInfo( Meta::TrackPtr track )
> +{
> +
> QString title = Qt::escape( track->name() );
> QString prettyTitle = Qt::escape( track->prettyName() );
> QString artist = track->artist() ? Qt::escape( track->artist()->name() ) : QString();
> @@ -97,7 +177,7 @@
>
> if ( artist == "Mike Oldfield" && title == "Amarok" ) {
> longMessage( i18n(
> - "<p>One of Mike Oldfield's best pieces of work, Amarok, inspired the name behind "
> + "<p>One of Mike Oldfield's best pieces of work, Amarok, inspired the name behind "
> "the audio-player you are currently using. Thanks for choosing Amarok!</p>"
> "<p align=right>Mark Kretschmann<br/>Max Howell<br/>Chris Muehlhaeuser<br/>"
> "The many other people who have helped make Amarok what it is</p>" ), KDE::StatusBar::Information );
> @@ -146,45 +226,3 @@
>
> setMainText( i18n( "Playing: %1", title ) );
> }
> -
> -///////////////////
> -//MessageQueue
> -///////////////////
> -
> -MessageQueue::MessageQueue()
> - : m_queueMessages( true )
> -{
> - DEBUG_BLOCK
> -}
> -
> -MessageQueue::~MessageQueue()
> -{
> - DEBUG_BLOCK
> -}
> -
> -K_GLOBAL_STATIC( MessageQueue, s_messageQueue );
> -
> -MessageQueue*
> -MessageQueue::instance()
> -{
> - return s_messageQueue;
> -}
> -
> -void
> -MessageQueue::addMessage(const QString& message)
> -{
> - if(m_queueMessages)
> - m_messages.push(message);
> - else
> - StatusBar::instance()->longMessage(message);
> -}
> -
> -void
> -MessageQueue::sendMessages()
> -{
> - m_queueMessages = false;
> - while(! m_messages.isEmpty())
> - {
> - StatusBar::instance()->longMessage(m_messages.pop());
> - }
> -}
> --- trunk/extragear/multimedia/amarok/src/statusbar/StatusBar.h #829790:829791
> @@ -22,6 +22,7 @@
> #define AMAROK_StatusBar_H
>
> #include "EngineObserver.h" //baseclass
> +#include "meta/Meta.h" // album observer
> #include "StatusBarBase.h" //baseclass
>
> #include <QStack>
> @@ -41,7 +42,7 @@
>
> namespace Amarok
> {
> - class AMAROK_EXPORT StatusBar : public KDE::StatusBar, public EngineObserver
> + class AMAROK_EXPORT StatusBar : public KDE::StatusBar, public EngineObserver, public Meta::Observer
> {
> friend Amarok::StatusBar* The::statusBar();
>
> @@ -51,9 +52,18 @@
> explicit StatusBar( QWidget *parent, const char *name = 0 );
> static StatusBar* instance() { return s_instance; }
>
> + // reimplemented from Meta::Observer
> + using Observer::metadataChanged;
> + void metadataChanged( Meta::Track *track );
> +
> protected: /* reimpl from engineobserver */
> virtual void engineStateChanged( Phonon::State state, Phonon::State oldState = Phonon::StoppedState );
> virtual void engineNewTrackPlaying();
> +
> + private:
> + void updateInfo( Meta::TrackPtr track );
> + Meta::TrackPtr m_currentTrack;
> +
> };
>
> /**
>
More information about the Amarok-devel
mailing list