1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 03:10:12 +02:00

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
This commit is contained in:
Leo Franchi
2011-01-19 18:04:51 -05:00
parent 9395712e78
commit 64be0a4ea4
3 changed files with 19 additions and 4 deletions

View File

@@ -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()

View File

@@ -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()

View File

@@ -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 );