From 64be0a4ea4c0d7225e618a981df7ec60d7b5f227 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Wed, 19 Jan 2011 18:04:51 -0500 Subject: [PATCH] fix AnimatedSplitter and sizing. this makes AnimatedSplitter set the stretch factor for the desired greedy widget to > 0, so that when QSplitter::resizeEvent is called by non-AnimatedSplitter places, the greedy widget is still respected --- .../dynamic/widgets/DynamicControlList.cpp | 6 +++--- src/libtomahawk/utils/animatedsplitter.cpp | 15 +++++++++++++++ src/libtomahawk/utils/animatedsplitter.h | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/libtomahawk/playlist/dynamic/widgets/DynamicControlList.cpp b/src/libtomahawk/playlist/dynamic/widgets/DynamicControlList.cpp index 008718160..a405898af 100644 --- a/src/libtomahawk/playlist/dynamic/widgets/DynamicControlList.cpp +++ b/src/libtomahawk/playlist/dynamic/widgets/DynamicControlList.cpp @@ -100,7 +100,6 @@ DynamicControlList::init() m_collapseLayout->addWidget( m_addControl ); m_collapse->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); - m_layout->addLayout( m_collapseLayout ); // connect( m_collapse, SIGNAL( clicked() ), this, ); connect( m_addControl, SIGNAL( clicked() ), this, SLOT( addNewControl() ) ); @@ -155,18 +154,19 @@ DynamicControlList::onShown( QWidget* w ) if( w != this ) return; - AnimatedWidget::onShown( w ); m_layout->removeWidget( m_summaryWidget ); m_layout->removeItem( m_collapseLayout ); + m_summaryWidget->hide(); foreach( DynamicControlWidget* control, m_controls ) { m_layout->addWidget( control ); - control->show(); } m_layout->addLayout( m_collapseLayout ); m_layout->setStretchFactor( m_collapseLayout, 1 ); + + AnimatedWidget::onShown( w ); } void DynamicControlList::addNewControl() diff --git a/src/libtomahawk/utils/animatedsplitter.cpp b/src/libtomahawk/utils/animatedsplitter.cpp index 351658adf..764782ade 100644 --- a/src/libtomahawk/utils/animatedsplitter.cpp +++ b/src/libtomahawk/utils/animatedsplitter.cpp @@ -195,6 +195,21 @@ AnimatedSplitter::onAnimationFinished() m_animateIndex = -1; } +void +AnimatedSplitter::setGreedyWidget(int index) +{ + m_greedyIndex = index; + if( !widget( index ) ) + return; + QSizePolicy policy = widget( m_greedyIndex )->sizePolicy(); + if( orientation() == Qt::Horizontal ) + policy.setHorizontalStretch( 1 ); + else + policy.setVerticalStretch( 1 ); + widget( m_greedyIndex )->setSizePolicy( policy ); + +} + void AnimatedSplitter::onHiddenSizeChanged() diff --git a/src/libtomahawk/utils/animatedsplitter.h b/src/libtomahawk/utils/animatedsplitter.h index 6ab6da2f1..1744a144b 100644 --- a/src/libtomahawk/utils/animatedsplitter.h +++ b/src/libtomahawk/utils/animatedsplitter.h @@ -19,7 +19,7 @@ public: void show( int index, bool animate = true ); void hide( int index, bool animate = true ); - void setGreedyWidget( int index ) { m_greedyIndex = index; } + void setGreedyWidget( int index ); void addWidget( QWidget* widget ); void addWidget( AnimatedWidget* widget );