diff --git a/src/libtomahawk/widgets/animatedsplitter.cpp b/src/libtomahawk/widgets/animatedsplitter.cpp index 392db19cb..77a14f683 100644 --- a/src/libtomahawk/widgets/animatedsplitter.cpp +++ b/src/libtomahawk/widgets/animatedsplitter.cpp @@ -247,3 +247,26 @@ AnimatedWidget::onAnimationFinished() setFixedHeight( hiddenSize().height() ); } } + +QSize +AnimatedSplitterHandle::sizeHint() const +{ + // Re-calculate our position if the items in the splitter changed, or if we haven't calculated it yet + if ( m_indexInSplitter == -1 || m_lastCount != splitter()->count() ) + { + for ( int i = 0; i < splitter()->count(); i++ ) + { + if ( splitter()->handle( i ) == this ) + { + m_indexInSplitter = i; + } + } + m_lastCount = splitter()->count(); + } + + // sizeHint is 0,0 if widget below handle has size 0 or is hidden + if ( splitter()->widget( m_indexInSplitter )->height() == 0 ) + return QSize( 0, 0 ); + else + return QSize( 1, 1 ); +} diff --git a/src/libtomahawk/widgets/animatedsplitter.h b/src/libtomahawk/widgets/animatedsplitter.h index 5bc64124c..982d62709 100644 --- a/src/libtomahawk/widgets/animatedsplitter.h +++ b/src/libtomahawk/widgets/animatedsplitter.h @@ -65,14 +65,17 @@ Q_OBJECT public: explicit AnimatedSplitterHandle( Qt::Orientation orientation, QSplitter* parent ) : QSplitterHandle( orientation, parent ) + , m_indexInSplitter( -1 ) + , m_lastCount( -1 ) { setCursor( Qt::ArrowCursor ); } - virtual QSize sizeHint() const - { - return QSize( 0, 0 ); - } + virtual QSize sizeHint() const; + +private: + mutable int m_indexInSplitter; + mutable int m_lastCount; };