void AnimatedSplitter::hide( int index, bool animate ) { m_animateIndex = index; QWidget* w = widget( index ); int minHeight = m_sizes.at( index ).height(); if ( w->height() == minHeight ) return; emit hidden( w ); w->setMinimumHeight( minHeight ); qDebug() << "animating to:" << w->height() << "from" << minHeight; m_animateForward = false; if ( animate ) { if ( m_timeLine->state() == QTimeLine::Running ) m_timeLine->stop(); m_timeLine->setFrameRange( minHeight, w->height() ); m_timeLine->setDirection( QTimeLine::Backward ); m_timeLine->start(); } else { onAnimationStep( minHeight ); onAnimationFinished(); } }
void AnimatedWidget::onHidden( QWidget* widget, bool animated ) { if ( widget != this ) return; m_animateForward = false; int minHeight = hiddenSize().height(); if ( animated ) { if ( m_timeLine->state() == QTimeLine::Running ) m_timeLine->stop(); m_timeLine->setFrameRange( minHeight, height() ); m_timeLine->setDirection( QTimeLine::Backward ); m_timeLine->start(); } else { onAnimationStep( minHeight ); onAnimationFinished(); } m_isHidden = true; }
void AnimatedSplitter::show( int index, bool animate ) { m_animateIndex = index; QWidget* w = widget( index ); QSize size = w->sizeHint(); if ( w->height() == size.height() ) return; emit shown( w ); w->setMaximumHeight( QWIDGETSIZE_MAX ); qDebug() << "animating to:" << size.height() << "from" << w->height(); m_animateForward = true; if ( animate ) { if ( m_timeLine->state() == QTimeLine::Running ) m_timeLine->stop(); m_timeLine->setFrameRange( w->height(), size.height() ); m_timeLine->setDirection( QTimeLine::Forward ); m_timeLine->start(); } else { onAnimationStep( size.height() ); onAnimationFinished(); } }
void AnimatedWidget::onShown( QWidget* widget, bool animated ) { if ( widget != this ) return; m_animateForward = true; if ( animated ) { if ( m_timeLine->state() == QTimeLine::Running ) m_timeLine->stop(); m_timeLine->setFrameRange( height(), sizeHint().height() ); m_timeLine->setDirection( QTimeLine::Forward ); m_timeLine->start(); } else { onAnimationStep( sizeHint().height() ); onAnimationFinished(); } m_isHidden = false; }