Commit b5360cd0 authored by François Cartegnie's avatar François Cartegnie 🤞

Qt: BackGroundWidget: fade in background

parent e82b763a
......@@ -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 */
......
......@@ -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 ); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment