[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/multimedia/amarok/src/widgets
From:       Maximilian Kossick <maximilian.kossick () googlemail ! com>
Date:       2007-08-03 21:57:48
Message-ID: 1186178268.287720.18212.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 696126 by mkossick:

the progress slider does work again after removing the moodbar code and a few other \
changes ~yay


 M  +21 -28    progressslider.cpp  
 M  +3 -3      progressslider.h  
 M  +0 -205    sliderwidget.cpp  
 M  +0 -37     sliderwidget.h  


--- trunk/extragear/multimedia/amarok/src/widgets/progressslider.cpp #696125:696126
@@ -11,26 +11,29 @@
  *                                                                         *
  ***************************************************************************/
 
+#include "progressslider.h"
+
 #include "amarokconfig.h"
 #include "debug.h"
 #include "enginecontroller.h"
 #include "meta/meta.h"
 #include "meta/MetaUtility.h"
-#include "progressslider.h"
 #include "timeLabel.h"
 
-#include <kpassivepopup.h>
-#include <khbox.h>
-
 #include <QHBoxLayout>
 #include <QLabel>
 #include <QList>
 #include <QPolygon>
 
+#include <khbox.h>
+#include <klocale.h>
+#include <kpassivepopup.h>
+
+
 // Class ProgressSlider
 ProgressSlider *ProgressSlider::s_instance = 0;
 ProgressSlider::ProgressSlider( QWidget *parent ) :
-        Amarok::PrettySlider( Qt::Horizontal, Amarok::PrettySlider::Normal, parent )
+        Amarok::Slider( Qt::Horizontal, parent )
 {
     s_instance = this;
     setMouseTracking( true );
@@ -56,7 +59,7 @@
 void
 ProgressSlider::paintEvent( QPaintEvent *e )
 {
-    Amarok::PrettySlider::paintEvent( e );
+    Amarok::Slider::paintEvent( e );
 
     if( isEnabled() )
     {
@@ -100,7 +103,7 @@
     }
     oldpoint = e->pos();
 
-    Amarok::PrettySlider::mouseMoveEvent( e );
+    Amarok::Slider::mouseMoveEvent( e );
 }
 
 void
@@ -111,7 +114,7 @@
         if( p.containsPoint( e->pos(), Qt::OddEvenFill ) )
             ec->seek( p.seconds() * 1000 );
 
-    Amarok::PrettySlider::mousePressEvent( e );
+    Amarok::Slider::mousePressEvent( e );
 }
 // END Class ProgressSlider
 
@@ -245,13 +248,11 @@
 void
 ProgressWidget::engineStateChanged( Engine::State state, Engine::State /*oldState*/ \
)  {
-
     switch ( state ) {
         case Engine::Empty:
             m_slider->setEnabled( false );
             m_slider->setMinimum( 0 ); //needed because setMaximum() calls with \
bogus values can change minValue  m_slider->setMaximum( 0 );
-            m_slider->newBundle( MetaBundle() ); // Set an empty bundle
             m_timeLabel->setEnabled( false ); //must be done after the setValue() \
above, due to a signal connection  m_timeLabel2->setEnabled( false );
             break;
@@ -269,29 +270,21 @@
 }
 
 void
-ProgressWidget::engineNewMetaData( const MetaBundle &bundle, bool /*trackChanged*/ )
+ProgressWidget::engineTrackLengthChanged( long seconds )
 {
-    m_slider->newBundle( bundle );
-    engineTrackLengthChanged( bundle.length() );
-    Meta::TrackPtr track = EngineController::instance()->currentTrack();
-    if( !track )
-        return;
-    m_slider->setMaximum( track->length() );
-
-    ProgressSlider::instance()->addBookmark( 20 );
-    ProgressSlider::instance()->addBookmark( 40);
-    QList<uint> bookmarkList;
-    bookmarkList << 30 << 50 << 45;
-    ProgressSlider::instance()->addBookmarks( bookmarkList );
+    m_slider->setMinimum( 0 );
+    m_slider->setMaximum( seconds * 1000 );
+    m_slider->setEnabled( seconds > 0 );
+    m_timeLength = Meta::secToPrettyTime( seconds ).length()+1; // account for - in \
remaining time  }
 
 void
-ProgressWidget::engineTrackLengthChanged( long length )
+ProgressWidget::engineNewTrackPlaying()
 {
-    m_slider->setMinimum( 0 );
-    m_slider->setMaximum( length * 1000 );
-    m_slider->setEnabled( length > 0 );
-    m_timeLength = Meta::secToPrettyTime( length ).length()+1; // account for - in \
remaining time +    Meta::TrackPtr track = \
EngineController::instance()->currentTrack(); +    if( !track )
+        return;
+    engineTrackLengthChanged( track->length() );
 }
 
 #include "progressslider.moc"
--- trunk/extragear/multimedia/amarok/src/widgets/progressslider.h #696125:696126
@@ -64,7 +64,7 @@
         int m_seconds;
 };
 
-class ProgressSlider : public Amarok::PrettySlider
+class ProgressSlider : public Amarok::Slider
 {
     Q_OBJECT
     static ProgressSlider *s_instance;
@@ -104,8 +104,8 @@
     protected:
         virtual void engineTrackPositionChanged( long position, bool /*userSeek*/ );
         virtual void engineStateChanged( Engine::State state, Engine::State oldState \
                = Engine::Empty );
-        virtual void engineTrackLengthChanged( long length );
-        virtual void engineNewMetaData( const MetaBundle &bundle, bool trackChanged \
); +        virtual void engineTrackLengthChanged( long seconds );
+        virtual void engineNewTrackPlaying();
 
     private:
         QLabel *m_timeLabel;
--- trunk/extragear/multimedia/amarok/src/widgets/sliderwidget.cpp #696125:696126
@@ -139,212 +139,7 @@
         m_prevValue = newValue;
 }
 
-
 //////////////////////////////////////////////////////////////////////////////////////////
                
-/// CLASS PrettySlider
-//////////////////////////////////////////////////////////////////////////////////////////
                
-
-#define THICKNESS 7
-#define MARGIN 3
-
-Amarok::PrettySlider::PrettySlider( Qt::Orientation orientation, SliderMode mode,
-                                    QWidget *parent, uint max )
-    : Amarok::Slider( orientation, parent, max )
-    , m_mode( mode )
-    , m_showingMoodbar( false )
-{
-    if( m_mode == Pretty)
-      {
-        setWindowFlags( Qt::WNoAutoErase );
-        setFocusPolicy( Qt::NoFocus );
-      }
-
-    // We only have to connect this *once*, since our MetaBundle
-    // doesn't get destroyed until we do.
-    connect( &m_bundle.moodbar(), SIGNAL( jobEvent( int ) ),
-             SLOT( moodbarJobEvent( int ) ) );
-
-    // We want to know if we should reset our moodbar data
-    connect( App::instance(), SIGNAL( moodbarPrefs( bool, bool, int, bool ) ),
-             SLOT( slotMoodbarPrefs( bool, bool, int, bool ) ) );
-
-}
-
-void
-Amarok::PrettySlider::mousePressEvent( QMouseEvent *e )
-{
-    Amarok::Slider::mousePressEvent( e );
-
-    slideEvent( e );
-}
-
-void
-Amarok::PrettySlider::slideEvent( QMouseEvent *e )
-{
-    if( m_mode == Pretty  ||  m_showingMoodbar )
-      QSlider::setValue( orientation() == Qt::Horizontal
-          ? QStyle::sliderValueFromPosition( minimum(), maximum(), e->pos().x(), \
                width()-2 )
-          : QStyle::sliderValueFromPosition( minimum(), maximum(), e->pos().y(), \
                height()-2 ) );
-    else
-      Amarok::Slider::slideEvent( e );
-}
-
-namespace Amarok {
-    namespace ColorScheme {
-        extern QColor Background;
-        extern QColor Foreground;
-    }
-}
-
-void
-Amarok::PrettySlider::paintEvent( QPaintEvent *e )
-{
-    const int w   = orientation() == Qt::Horizontal ? width() : height();
-    const int pos = int( double( w-2 ) / maximum() * Slider::value() );
-    int h = THICKNESS;
-
-    m_showingMoodbar = ( !m_bundle.url().isEmpty()       &&
-                         m_bundle.moodbar().dataExists() &&
-                         AmarokConfig::showMoodbar() );
-    QPixmap mood;
-    if( m_showingMoodbar )
-      {
-        if( m_mode == Normal )
-          h = (orientation() == Qt::Vertical ? width() : height()) - 2*MARGIN;
-        mood = m_bundle.moodbar().draw( w, h );
-      }
-    // If we're a Normal PrettySlider and we have no moodbar,
-    // emulate the behavior of Slider
-    else if( m_mode == Normal )
-      {
-        Amarok::Slider::paintEvent( e );
-        return;
-      }
-
-    QPainter p( this );
-
-    if ( orientation() == Qt::Vertical )
-    {
-        p.translate( 0, height()-1 );
-        p.rotate( -90 ); //90 degrees clockwise
-    }
-
-    if( !m_showingMoodbar )
-      {
-        p.translate( 0, MARGIN );
-          p.setPen( Amarok::ColorScheme::Foreground );
-          p.fillRect( 0, 0, pos, h, QColor( Amarok::ColorScheme::Background ) );
-          p.drawRect( 0, 0, w, h );
-        p.translate( 0, -MARGIN );
-      }
-    else
-      {
-        p.translate( 0, MARGIN );
-          p.drawPixmap( 0, 0, mood );
-          p.setPen( Amarok::ColorScheme::Foreground );
-          p.drawRect( 0, 0, w, h );
-        p.translate( 0, -MARGIN );
-
-        // Larger triangle for the moodbar
-      }
-
-    //<Triangle Marker>
-    if( m_mode == Pretty )
-      {
-        QPolygon pa( 3 );
-        pa.setPoint( 0, pos - 3, 1 );
-        pa.setPoint( 1, pos + 3, 1 );
-        pa.setPoint( 2, pos,     5 );
-        p.setBrush( paletteForegroundColor() );
-        p.drawConvexPolygon( pa );
-      }
-
-    else if( m_mode == Normal )
-      {
-        QPolygon pa( 3 );
-        pa.setPoint( 0, pos - 5, 1 );
-        pa.setPoint( 1, pos + 5, 1 );
-        pa.setPoint( 2, pos,     9 );
-        p.setBrush( paletteForegroundColor() );
-        p.drawConvexPolygon( pa );
-      }
-    //</Triangle Marker>
-}
-
-
-// This gets called when the moodbar job starts or finishes
-void
-Amarok::PrettySlider::moodbarJobEvent( int newState )
-{
-    if( newState == Moodbar::JobStateSucceeded )
-      {
-        debug() << "moodbarJobEvent: new moodbar data";
-        update();
-      }
-}
-
-// This gets called when the user presses "Ok" or "Apply" in the
-// config dialog.  Reload our moodbar data, in case it was
-// permanently disabled before because the moodbar was disabled.
-void
-Amarok::PrettySlider::slotMoodbarPrefs( bool show, bool moodier, int alter, bool \
                withMusic )
-{
-    (void) moodier;  (void) alter;  (void) withMusic;
-
-    if( show )
-      {
-        m_bundle.moodbar().reset();
-        if( !m_bundle.moodbar().dataExists() )
-          m_bundle.moodbar().load();
-        update();
-      }
-}
-
-
-
-
-// This is called when the track changes / stops / starts
-void
-Amarok::PrettySlider::newBundle( const MetaBundle &bundle )
-{
-    m_bundle = bundle;
-
-    // This is the easiest way to tell if the bundle refers
-    // to a real track, or if we're STOP'd.
-    if( m_bundle.url().isEmpty() )
-      return;
-
-    // It's a real track; get the moodbar data if it's not there
-    if( !m_bundle.moodbar().dataExists() )
-      m_bundle.moodbar().load();
-    else
-      update();
-}
-
-
-
-#if 0
-/** these functions aren't required in our fixed size world,
-    but they may become useful one day **/
-
-QSize
-Amarok::PrettySlider::minimumSizeHint() const
-{
-    return sizeHint();
-}
-
-QSize
-Amarok::PrettySlider::sizeHint() const
-{
-    constPolish();
-
-    return (orientation() == Qt::Horizontal
-             ? QSize( maximum(), THICKNESS + MARGIN )
-             : QSize( THICKNESS + MARGIN, maximum() )).expandedTo( QApplit \
                ication::globalStrut() );
-}
-#endif
-
-//////////////////////////////////////////////////////////////////////////////////////////
  /// CLASS VolumeSlider
 //////////////////////////////////////////////////////////////////////////////////////////
  
--- trunk/extragear/multimedia/amarok/src/widgets/sliderwidget.h #696125:696126
@@ -20,8 +20,6 @@
 #ifndef AMAROKSLIDER_H
 #define AMAROKSLIDER_H
 
-#include "metabundle.h"
-
 #include <QPixmap>
 #include <QSlider>
 #include <QVector>
@@ -75,41 +73,6 @@
             Slider &operator=( const Slider& ); //undefined
     };
 
-
-    class PrettySlider : public Slider
-    {
-        Q_OBJECT
-
-        public:
-            typedef enum
-            {
-                Normal,  // Same behavior as Slider *unless* there's a moodbar
-                Pretty
-            } SliderMode;
-
-            PrettySlider( Qt::Orientation orientation, SliderMode mode,
-                          QWidget *parent, uint max = 0 );
-
-            virtual void newBundle( const MetaBundle &bundle );
-
-        protected:
-            virtual void paintEvent( QPaintEvent *e );
-            virtual void slideEvent( QMouseEvent* );
-            virtual void mousePressEvent( QMouseEvent* );
-
-        protected slots:
-            void moodbarJobEvent( int newState );
-            void slotMoodbarPrefs( bool show, bool moodier, int alter, bool \
                withMusic );
-
-        private:
-            PrettySlider( const PrettySlider& ); //undefined
-            PrettySlider &operator=( const PrettySlider& ); //undefined
-
-            SliderMode m_mode;
-            MetaBundle m_bundle;  // Has our moodbar data!
-            bool       m_showingMoodbar;
-    };
-
     class VolumeSlider: public Slider
     {
         Q_OBJECT


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic