[vlc-commits] Qt: BackGroundWidget: fade in background

Francois Cartegnie git at videolan.org
Thu Oct 4 14:47:52 CEST 2012


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Oct  4 14:47:05 2012 +0200| [b5360cd03e74fcc343127550517203434da290b9] | committer: Francois Cartegnie

Qt: BackGroundWidget: fade in background

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b5360cd03e74fcc343127550517203434da290b9
---

 modules/gui/qt4/components/interface_widgets.cpp |   18 ++++++++++++++++++
 modules/gui/qt4/components/interface_widgets.hpp |    3 +++
 2 files changed, 21 insertions(+)

diff --git a/modules/gui/qt4/components/interface_widgets.cpp b/modules/gui/qt4/components/interface_widgets.cpp
index 8d12d9b..d6967c8 100644
--- a/modules/gui/qt4/components/interface_widgets.cpp
+++ b/modules/gui/qt4/components/interface_widgets.cpp
@@ -199,6 +199,16 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i )
     /* Init the cone art */
     updateArt( "" );
 
+    /* fade in animator */
+    setProperty( "opacity", 1.0 );
+    fadeAnimation = new QPropertyAnimation( this, "opacity", this );
+    fadeAnimation->setDuration( 1000 );
+    fadeAnimation->setStartValue( 0.0 );
+    fadeAnimation->setEndValue( 1.0 );
+    fadeAnimation->setEasingCurve( QEasingCurve::OutSine );
+    CONNECT( fadeAnimation, valueChanged( const QVariant & ),
+             this, update() );
+
     CONNECT( THEMIM->getIM(), artChanged( QString ),
              this, updateArt( const QString& ) );
 }
@@ -219,6 +229,12 @@ void BackgroundWidget::updateArt( const QString& url )
     update();
 }
 
+void BackgroundWidget::showEvent( QShowEvent * e )
+{
+    Q_UNUSED( e );
+    if ( b_withart ) fadeAnimation->start();
+}
+
 void BackgroundWidget::paintEvent( QPaintEvent *e )
 {
     if ( !b_withart )
@@ -237,6 +253,8 @@ void BackgroundWidget::paintEvent( QPaintEvent *e )
     i_maxwidth  = __MIN( maximumWidth(), width() ) - MARGIN * 2;
     i_maxheight = __MIN( maximumHeight(), height() ) - MARGIN * 2;
 
+    painter.setOpacity( property( "opacity" ).toFloat() );
+
     if ( height() > MARGIN * 2 )
     {
         /* Scale down the pixmap if the widget is too small */
diff --git a/modules/gui/qt4/components/interface_widgets.hpp b/modules/gui/qt4/components/interface_widgets.hpp
index 0b7795e..730c7e0 100644
--- a/modules/gui/qt4/components/interface_widgets.hpp
+++ b/modules/gui/qt4/components/interface_widgets.hpp
@@ -42,6 +42,7 @@
 #include <QFrame>
 #include <QLabel>
 #include <QMouseEvent>
+#include <QPropertyAnimation>
 
 class ResizeEvent;
 class QPixmap;
@@ -93,9 +94,11 @@ private:
     QString pixmapUrl;
     bool b_expandPixmap;
     bool b_withart;
+    QPropertyAnimation *fadeAnimation;
     virtual void contextMenuEvent( QContextMenuEvent *event );
 protected:
     void paintEvent( QPaintEvent *e );
+    virtual void showEvent( QShowEvent * e );
     static const int MARGIN = 5;
 public slots:
     void toggle(){ TOGGLEV( this ); }



More information about the vlc-commits mailing list