mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-13 04:21:51 +02:00
collapse plus and minus tosame button area
This commit is contained in:
parent
0df8ea0732
commit
e9963bb4d2
@ -86,6 +86,7 @@ DynamicControlList::setControls( const geninterface_ptr& generator, const QList<
|
||||
foreach( const dyncontrol_ptr& control, controls ) {
|
||||
m_controls << new DynamicControlWidget( control, false, false, false, this );
|
||||
connect( m_controls.last(), SIGNAL( addNewControl() ), this, SLOT( addNewControl() ) );
|
||||
connect( m_controls.last(), SIGNAL( removeControl() ), this, SLOT( removeControl() ) );
|
||||
}
|
||||
onShown( this );
|
||||
}
|
||||
@ -133,6 +134,23 @@ void DynamicControlList::addNewControl()
|
||||
m_controls.append( new DynamicControlWidget( m_generator->createControl(), true, false, true, this ) );
|
||||
m_layout->addWidget( m_controls.last() );
|
||||
connect( m_controls.last(), SIGNAL( addNewControl() ), this, SLOT( addNewControl() ) );
|
||||
connect( m_controls.last(), SIGNAL( removeControl() ), this, SLOT( removeControl() ) );
|
||||
}
|
||||
|
||||
void DynamicControlList::removeControl()
|
||||
{
|
||||
DynamicControlWidget* w = qobject_cast<DynamicControlWidget*>( sender() );
|
||||
m_layout->removeWidget( w );
|
||||
delete w;
|
||||
|
||||
m_controls.last()->setShowCollapseButton( true );
|
||||
m_controls.last()->setShowPlusButton( true );
|
||||
m_controls.last()->setShowMinusButton( false );
|
||||
}
|
||||
|
||||
QList< dyncontrol_ptr >& DynamicControlList::controls() const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -51,6 +51,7 @@ public slots:
|
||||
virtual void onHidden(QWidget* );
|
||||
virtual void onShown(QWidget* );
|
||||
void addNewControl();
|
||||
void removeControl();
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
@ -51,25 +51,20 @@ DynamicControlWidget::DynamicControlWidget( const Tomahawk::dyncontrol_ptr& cont
|
||||
m_layout->setSpacing( 0 );
|
||||
setContentsMargins( 0, 0, 0, 0 );
|
||||
|
||||
m_plusButton = initButton();
|
||||
m_minusButton = initButton();
|
||||
m_minusButton->setIcon( QIcon( RESPATH "images/list-remove.png" ) );
|
||||
connect( m_minusButton, SIGNAL( clicked( bool ) ), this, SIGNAL( removeControl() ) );
|
||||
|
||||
m_plusButton = initButton();
|
||||
m_plusButton->setIcon( QIcon( RESPATH "images/list-add.png" ) );
|
||||
connect( m_plusButton, SIGNAL( clicked( bool ) ), this, SIGNAL( addNewControl() ) );
|
||||
m_plusL = new QStackedLayout;
|
||||
m_plusL->setContentsMargins( 0, 0, 0, 0 );
|
||||
m_plusL->addWidget( m_plusButton );
|
||||
m_plusL->addWidget( m_minusButton );
|
||||
m_plusL->addWidget( createDummy( m_plusButton ) ); // :-(
|
||||
m_plusL->setCurrentIndex( 0 );
|
||||
|
||||
m_minusButton = initButton();
|
||||
m_minusButton->setIcon( QIcon( RESPATH "images/list-remove.png" ) );
|
||||
connect( m_minusButton, SIGNAL( clicked( bool ) ), this, SIGNAL( removeControl() ) );
|
||||
m_minusL = new QStackedLayout;
|
||||
m_minusL->setContentsMargins( 0, 0, 0, 0 );
|
||||
m_minusL->addWidget( m_minusButton );
|
||||
m_minusL->addWidget( createDummy( m_plusButton ) ); // :-(
|
||||
m_minusL->setCurrentIndex( 0 );
|
||||
|
||||
m_collapseButton = initButton();
|
||||
m_collapseButton->setIcon( QIcon( RESPATH "images/arrow-up-double.png" ) );
|
||||
m_collapseL = new QStackedLayout;
|
||||
@ -92,7 +87,6 @@ DynamicControlWidget::DynamicControlWidget( const Tomahawk::dyncontrol_ptr& cont
|
||||
typeSelectorChanged( m_control.isNull() ? "" : m_control->selectedType() );
|
||||
|
||||
m_layout->addLayout( m_collapseL, 0 );
|
||||
m_layout->addLayout( m_minusL, 0 );
|
||||
m_layout->addLayout( m_plusL, 0 );
|
||||
|
||||
if( m_showCollapse )
|
||||
@ -100,7 +94,7 @@ DynamicControlWidget::DynamicControlWidget( const Tomahawk::dyncontrol_ptr& cont
|
||||
if( m_showPlus )
|
||||
m_plusL->setCurrentIndex( 0 );
|
||||
if( m_showMinus )
|
||||
m_minusL->setCurrentIndex( 0 );
|
||||
m_plusL->setCurrentIndex( 1 );
|
||||
|
||||
setLayout( m_layout );
|
||||
}
|
||||
@ -156,7 +150,7 @@ DynamicControlWidget::setShowPlusButton(bool show)
|
||||
{
|
||||
|
||||
if( m_showPlus != show ) {
|
||||
show ? m_plusL->setCurrentIndex( 0 ) : m_plusL->setCurrentIndex( 1 );
|
||||
show ? m_plusL->setCurrentIndex( 0 ) : m_plusL->setCurrentIndex( 2 );
|
||||
}
|
||||
|
||||
m_showPlus = show;
|
||||
@ -181,14 +175,15 @@ void DynamicControlWidget::setShowMinusButton(bool show)
|
||||
void DynamicControlWidget::enterEvent(QEvent* ev)
|
||||
{
|
||||
if( m_showMinus )
|
||||
m_minusL->setCurrentIndex( 0 );
|
||||
m_plusL->setCurrentIndex( 1 );
|
||||
|
||||
QWidget::enterEvent( ev );
|
||||
}
|
||||
|
||||
void DynamicControlWidget::leaveEvent(QEvent* ev)
|
||||
{
|
||||
m_minusL->setCurrentIndex( 1 );
|
||||
if( m_showMinus )
|
||||
m_plusL->setCurrentIndex( 2 );
|
||||
|
||||
QWidget::leaveEvent( ev );
|
||||
}
|
||||
|
@ -67,7 +67,6 @@ private:
|
||||
// i hate qlayout
|
||||
QStackedLayout* m_plusL;
|
||||
QToolButton* m_plusButton;
|
||||
QStackedLayout* m_minusL;
|
||||
QToolButton* m_minusButton;
|
||||
QStackedLayout* m_collapseL;
|
||||
QToolButton* m_collapseButton;
|
||||
|
Loading…
x
Reference in New Issue
Block a user