1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 22:26:32 +02:00

* Fix a few animation issues.

This commit is contained in:
Christian Muehlhaeuser
2010-11-27 05:35:52 +01:00
parent af4898331a
commit cef7883fd6
2 changed files with 50 additions and 20 deletions

View File

@@ -21,23 +21,32 @@ AnimatedSplitter::show( int index, bool animate )
if ( m_greedyIndex < 0 ) if ( m_greedyIndex < 0 )
return; return;
int time = animate ? ANIMATION_TIME : 0;
m_animateIndex = index; m_animateIndex = index;
QWidget* w = widget( index ); QWidget* w = widget( index );
QSize size = w->sizeHint(); QSize size = w->sizeHint();
w->setMaximumHeight( QWIDGETSIZE_MAX );
qDebug() << "SizeHint:" << index << w->height() << size; qDebug() << "SizeHint:" << index << w->height() << size;
m_greedyHeight = widget( m_greedyIndex )->height(); m_animateForward = true;
if ( animate )
{
m_greedyHeight = widget( m_greedyIndex )->height();
QTimeLine *timeLine = new QTimeLine( time, this ); QTimeLine *timeLine = new QTimeLine( ANIMATION_TIME, this );
timeLine->setFrameRange( w->height(), size.height() ); timeLine->setFrameRange( w->height(), size.height() );
timeLine->setUpdateInterval( 10 ); timeLine->setUpdateInterval( 10 );
timeLine->setCurveShape( QTimeLine::EaseOutCurve ); timeLine->setCurveShape( QTimeLine::EaseOutCurve );
connect( timeLine, SIGNAL( frameChanged( int ) ), SLOT( onAnimationStep( int ) ) ); connect( timeLine, SIGNAL( frameChanged( int ) ), SLOT( onAnimationStep( int ) ) );
connect( timeLine, SIGNAL( finished() ), SLOT( onAnimationFinished() ) ); connect( timeLine, SIGNAL( finished() ), SLOT( onAnimationFinished() ) );
timeLine->start(); timeLine->start();
}
else
{
onAnimationStep( size.height() );
onAnimationFinished();
}
emit shown( w ); emit shown( w );
} }
@@ -49,23 +58,31 @@ AnimatedSplitter::hide( int index, bool animate )
if ( m_greedyIndex < 0 ) if ( m_greedyIndex < 0 )
return; return;
int time = animate ? ANIMATION_TIME : 0;
m_animateIndex = index; m_animateIndex = index;
QWidget* w = widget( index ); QWidget* w = widget( index );
qDebug() << "SizeHint:" << index << w->height(); qDebug() << "SizeHint:" << index << w->height();
m_greedyHeight = widget( m_greedyIndex )->height(); m_greedyHeight = widget( m_greedyIndex )->height();
QTimeLine *timeLine = new QTimeLine( time, this ); m_animateForward = false;
timeLine->setFrameRange( 25, w->height() ); if ( animate )
timeLine->setUpdateInterval( 10 ); {
timeLine->setDirection( QTimeLine::Backward );
timeLine->setCurveShape( QTimeLine::EaseOutCurve );
connect( timeLine, SIGNAL( frameChanged( int ) ), SLOT( onAnimationStep( int ) ) ); QTimeLine *timeLine = new QTimeLine( ANIMATION_TIME, this );
connect( timeLine, SIGNAL( finished() ), SLOT( onAnimationFinished() ) ); timeLine->setFrameRange( 25, w->height() );
timeLine->start(); timeLine->setUpdateInterval( 10 );
timeLine->setDirection( QTimeLine::Backward );
timeLine->setCurveShape( QTimeLine::EaseOutCurve );
connect( timeLine, SIGNAL( frameChanged( int ) ), SLOT( onAnimationStep( int ) ) );
connect( timeLine, SIGNAL( finished() ), SLOT( onAnimationFinished() ) );
timeLine->start();
}
else
{
onAnimationStep( 25 );
onAnimationFinished();
}
emit hidden( w ); emit hidden( w );
} }
@@ -160,5 +177,17 @@ AnimatedSplitter::onAnimationFinished()
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
sender()->deleteLater(); QWidget* w = widget( m_animateIndex );
if ( m_animateForward )
w->setMinimumHeight( 100 );
else
{
w->setMinimumHeight( 25 );
w->setMaximumHeight( 25 );
}
m_animateIndex = -1;
if ( sender() )
sender()->deleteLater();
} }

View File

@@ -30,6 +30,7 @@ private slots:
private: private:
int m_animateIndex; int m_animateIndex;
bool m_animateForward;
int m_greedyIndex; int m_greedyIndex;
int m_greedyHeight; int m_greedyHeight;