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

List:       kde-commits
Subject:    extragear/multimedia/amarok/src
From:       Jeff Mitchell <kde-dev () emailgoeshere ! com>
Date:       2007-06-30 22:35:38
Message-ID: 1183242938.806441.32036.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 681939 by mitchell:

Begin implementation of PUD in CV.  Some enhancements to GraphicsItemFader as well.  \
Don't know why it's not working right though.  Enable it by changing  the static bool \
in contextview.cpp to true.


 M  +2 -3      collectionbrowser/collectiontreeview.cpp  
 M  +68 -0     contextview/contextview.cpp  
 M  +10 -0     contextview/contextview.h  
 M  +19 -2     contextview/graphicsitemfader.cpp  
 M  +3 -0      contextview/graphicsitemfader.h  


--- trunk/extragear/multimedia/amarok/src/collectionbrowser/collectiontreeview.cpp \
#681938:681939 @@ -10,8 +10,8 @@
 
 #include "amarok.h"
 #include "collectionbrowser/collectiontreeitemmodel.h"
+#include "contextview/contextview.h"
 #include "playlist/PlaylistModel.h"
-//#include "popupdropper/PopupDropper.h"
 #include "TheInstances.h"
 
 #include <QContextMenuEvent>
@@ -159,8 +159,7 @@
     if( ( e->pos() - m_dragStartPosition).manhattanLength() < \
QApplication::startDragDistance() )  return;
 
-    //if( The::PopupDropper()->isEnabled() )
-    //    The::PopupDropper()->create();
+    ContextView::instance()->showPopupDropper();
 
     QTreeView::mouseMoveEvent( e );
 }
--- trunk/extragear/multimedia/amarok/src/contextview/contextview.cpp #681938:681939
@@ -36,6 +36,7 @@
 #include <QColor>
 #include <QGraphicsTextItem>
 #include <QGraphicsScene>
+#include <QMouseEvent>
 #include <QWheelEvent>
 
 //just for testing
@@ -43,6 +44,8 @@
 
 using namespace Context;
 
+static bool enablePUD = false;
+
 ContextView *ContextView::s_instance = 0;
 
 ContextView::ContextView()
@@ -50,6 +53,7 @@
     , EngineObserver( EngineController::instance() )
 {
     m_testItem = 0;
+    m_pudShown = false;
     s_instance = this; // we are a singleton class
 
     // start context item manager
@@ -61,6 +65,7 @@
     setRenderHints( QPainter::Antialiasing );
     setCacheMode( QGraphicsView::CacheBackground ); // this won't be changing \
regularly  
+    setMouseTracking( true );
 
     showHome();
 }
@@ -285,6 +290,69 @@
     shuffleItems( shuffle, change );
 }
 
+void ContextView::showPopupDropper()
+{
+    if( !enablePUD )
+        return;
+    DEBUG_BLOCK
+    if( m_pudShown )
+        return;
+
+    while( !m_pudFaders.isEmpty() )
+        delete m_pudFaders.takeFirst();
+
+    foreach( ContextBox* box, m_contextBoxes )
+    {
+        GraphicsItemFader *fader = new GraphicsItemFader( box );
+        fader->setFadeColor( palette().highlight().color() );
+        fader->setDuration( 3000 );
+        fader->setStartAlpha( 0 );
+        fader->setTargetAlpha( 120 );
+        m_pudFaders.append( fader );
+    }
+
+    foreach( GraphicsItemFader* fader, m_pudFaders )
+        fader->startFading();
+
+    m_pudShown = true;
+}
+
+void ContextView::hidePopupDropper()
+{
+    if( !enablePUD ) 
+        return;
+    DEBUG_BLOCK
+    if( !m_pudShown )
+        return;
+
+    foreach( GraphicsItemFader* fader, m_pudFaders )
+    {
+        fader->setStartAlpha( 120 );
+        fader->setTargetAlpha( 0 );
+    }
+
+    foreach( GraphicsItemFader* fader, m_pudFaders )
+        fader->startFading();
+
+    m_pudShown = false;
+}
+
+void ContextView::mouseMoveEvent( QMouseEvent *e )
+{
+    DEBUG_BLOCK
+    if( m_pudShown )
+        hidePopupDropper();
+    QGraphicsView::mouseMoveEvent( e );
+}
+
+void ContextView::mouseReleaseEvent( QMouseEvent *e )
+{
+    DEBUG_BLOCK
+    if( m_pudShown )
+        hidePopupDropper();
+    QGraphicsView::mouseReleaseEvent( e );
+}
+
 void ContextView::removeContextBox( ContextBox *oldBox, bool fadeOut )
 {
     DEBUG_BLOCK
--- trunk/extragear/multimedia/amarok/src/contextview/contextview.h #681938:681939
@@ -20,12 +20,14 @@
 #include "ContextObserver.h"
 #include "engineobserver.h"
 #include "GenericInfoBox.h"
+#include "graphicsitemfader.h"
 
 #include <QGraphicsSvgItem>
 #include <QGraphicsView>
 #include <QPointer>
 
 class QGraphicsScene;
+class QMouseEvent;
 class QResizeEvent;
 class QWheelEvent;
 
@@ -54,9 +56,14 @@
         
         void removeContextBox( ContextBox *oldBox, bool fadeOut = false );
 
+        void showPopupDropper();
+        void hidePopupDropper();
+
     protected:
         void engineNewMetaData( const MetaBundle&, bool );
         void engineStateChanged( Engine::State, Engine::State = Engine::Empty );
+        void mouseMoveEvent( QMouseEvent *event );
+        void mouseReleaseEvent( QMouseEvent *event);
         void resizeEvent( QResizeEvent *event );
         void wheelEvent( QWheelEvent *event );
 
@@ -88,6 +95,9 @@
 
         ContextBox *m_testItem;
 
+        QList<GraphicsItemFader*> m_pudFaders;
+        bool m_pudShown;
+
     private slots:
         void introAnimationComplete();
         void boxHeightChanged(qreal change);
--- trunk/extragear/multimedia/amarok/src/contextview/graphicsitemfader.cpp \
#681938:681939 @@ -35,6 +35,7 @@
     , m_duration( 5000 )
 {
     m_contentItem = item;
+    m_itemPreviousParent = m_contentItem->parentItem();
     m_contentItem->setParentItem( this );
     m_contentItem->setZValue( 1 );
     m_contentItem->setPos( 1, 1 );
@@ -54,8 +55,16 @@
 
     m_timeLine = new QTimeLine( m_duration, this );
     connect( m_timeLine, SIGNAL( frameChanged( int ) ), this, SLOT( fadeSlot( int ) \
) ); +    connect( m_timeLine, SIGNAL( finished() ), this, SLOT( fadeFinished() ) );
 }
 
+GraphicsItemFader::~GraphicsItemFader()
+{
+    m_timeLine->stop();
+    fadeSlot( m_animationSteps );
+    m_contentItem->setParentItem( m_itemPreviousParent );
+}
+
 void GraphicsItemFader::setStartAlpha(int alpha)
 {
     m_startAlpha = alpha;
@@ -100,18 +109,26 @@
     if ( newAlpha == m_targetAlpha )
         emit( animationComplete() );
 
-    //debug() << "fading, new alpha = " << newAlpha <<  endl;
+    debug() << "fading, new alpha = " << newAlpha <<  endl;
 }
 
+void GraphicsItemFader::fadeFinished()
+{
+    DEBUG_BLOCK
+    emit( animationComplete() );
+}
+
 void GraphicsItemFader::startFading()
 {
+    if( m_timeLine->state() != QTimeLine::NotRunning )
+        m_timeLine->stop();
     //total number of animation steps;
     m_animationSteps = m_fps * ( ( float ) m_duration / 1000.0 );
 
     //how much should alpha change each step
     m_alphaStep = ( ( float ) ( m_targetAlpha - m_startAlpha ) ) / ( float ) \
m_animationSteps;  
-    //debug() << "Start fading, animationSteps = " << m_animationSteps << ", \
alphaStep = " <<  m_alphaStep << endl; +    debug() << "Start fading, animationSteps \
= " << m_animationSteps << " over " << m_duration << " mseconds, alphaStep = " <<  \
m_alphaStep << endl;  
     m_timeLine->setDuration( m_duration );
     m_timeLine->setFrameRange( 0, m_animationSteps );
--- trunk/extragear/multimedia/amarok/src/contextview/graphicsitemfader.h \
#681938:681939 @@ -42,6 +42,7 @@
     Q_OBJECT
     public:
         explicit GraphicsItemFader( QGraphicsItem * item, QGraphicsItem * parent = 0 \
); +        ~GraphicsItemFader();
 
         virtual QRectF boundingRect () const;
         void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, \
QWidget *widget ); @@ -59,11 +60,13 @@
 
     public slots:
         void fadeSlot( int step );
+        void fadeFinished();
 
     private:
         QTimeLine * m_timeLine;
         QGraphicsItem * m_contentItem;
         QGraphicsRectItem * m_shadeRectItem;
+        QGraphicsItem * m_itemPreviousParent;
 
         QColor m_fadeColor;
         int m_startAlpha;


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

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