diff --git a/src/libtomahawk/utils/animatedsplitter.cpp b/src/libtomahawk/utils/animatedsplitter.cpp index 2bbb3f147..bd733034a 100644 --- a/src/libtomahawk/utils/animatedsplitter.cpp +++ b/src/libtomahawk/utils/animatedsplitter.cpp @@ -61,6 +61,8 @@ AnimatedSplitter::addWidget( AnimatedWidget* widget ) connect( widget, SIGNAL( showWidget() ), SLOT( onShowRequest() ) ); connect( widget, SIGNAL( hideWidget() ), SLOT( onHideRequest() ) ); + connect( widget, SIGNAL( sizeChanged( QSize) ), SLOT( onSizeChanged( QSize ) ) ); + connect( this, SIGNAL( shown( QWidget*, bool ) ), widget, SLOT( onShown( QWidget*, bool ) ) ); connect( this, SIGNAL( hidden( QWidget*, bool ) ), widget, SLOT( onHidden( QWidget*, bool ) ) ); } @@ -88,17 +90,51 @@ AnimatedSplitter::onHideRequest() } +void +AnimatedSplitter::onSizeChanged( const QSize& size ) +{ + AnimatedWidget* w = (AnimatedWidget*)(sender()); + int wi = indexOf( w ); + + QList< int > sizes; + for ( int i = 0; i < count(); i ++ ) + { + int j = 0; + + if ( i == m_greedyIndex ) + { + j = height() - size.height(); + } + else if ( i == wi ) + { + j = size.height(); + } + else + { + j = widget( i )->height(); + } + + sizes << j; + } + + setSizes( sizes ); +} + + void AnimatedSplitter::setGreedyWidget( int index ) { - m_greedyIndex = index; if( !widget( index ) ) return; + + m_greedyIndex = index; + QSizePolicy policy = widget( m_greedyIndex )->sizePolicy(); if( orientation() == Qt::Horizontal ) policy.setHorizontalStretch( 1 ); else policy.setVerticalStretch( 1 ); + widget( m_greedyIndex )->setSizePolicy( policy ); } @@ -180,6 +216,9 @@ void AnimatedWidget::onAnimationStep( int frame ) { setFixedHeight( frame ); + + QSize s( 0, frame ); //FIXME + emit sizeChanged( s ); } diff --git a/src/libtomahawk/utils/animatedsplitter.h b/src/libtomahawk/utils/animatedsplitter.h index f28c1eb7d..8c0c19502 100644 --- a/src/libtomahawk/utils/animatedsplitter.h +++ b/src/libtomahawk/utils/animatedsplitter.h @@ -49,6 +49,8 @@ private slots: void onShowRequest(); void onHideRequest(); + void onSizeChanged( const QSize& size ); + private: int m_greedyIndex; }; @@ -73,6 +75,7 @@ signals: void showWidget(); void hideWidget(); + void sizeChanged( const QSize& size ); void hiddenSizeChanged(); private slots: