mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-13 17:43:59 +02:00
hide expand button in read-only
This commit is contained in:
@@ -55,8 +55,8 @@ Tomahawk::CollapsibleControls::~CollapsibleControls()
|
||||
void
|
||||
CollapsibleControls::init()
|
||||
{
|
||||
m_timeline = new QTimeLine( 300, this );
|
||||
m_timeline->setUpdateInterval( 8 );
|
||||
m_timeline = new QTimeLine( 250, this );
|
||||
m_timeline->setUpdateInterval( 5 );
|
||||
m_animHeight = -1;
|
||||
m_collapseAnimation = false;
|
||||
|
||||
@@ -77,20 +77,25 @@ CollapsibleControls::init()
|
||||
m_summaryWidget->setMinimumHeight( 24 );
|
||||
m_summaryWidget->setMaximumHeight( 24 );
|
||||
m_summaryWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
|
||||
QHBoxLayout* summaryLayout = new QHBoxLayout;
|
||||
m_summaryWidget->setLayout( summaryLayout );
|
||||
m_summaryWidget->layout()->setMargin( 0 );
|
||||
m_summaryLayout = new QHBoxLayout;
|
||||
m_summaryWidget->setLayout( m_summaryLayout );
|
||||
m_summaryLayout->setMargin( 0 );
|
||||
|
||||
m_summary = new QLabel( m_summaryWidget );
|
||||
summaryLayout->addWidget( m_summary, 1 );
|
||||
m_summaryExpand = new QToolButton( m_summary );
|
||||
m_summaryExpand->setIconSize( QSize( 16, 16 ) );
|
||||
m_summaryLayout->addWidget( m_summary, 1 );
|
||||
m_summaryExpand = DynamicControlWrapper::initButton( this );
|
||||
m_summaryExpand->setIcon( QIcon( RESPATH "images/arrow-down-double.png" ) );
|
||||
m_summaryExpand->setToolButtonStyle( Qt::ToolButtonIconOnly );
|
||||
m_summaryExpand->setAutoRaise( true );
|
||||
m_summaryExpand->setContentsMargins( 0, 0, 0, 0 );
|
||||
m_expandL = new QStackedLayout;
|
||||
m_expandL->setContentsMargins( 0, 0, 0, 0 );
|
||||
m_expandL->setMargin( 0 );
|
||||
m_expandL->addWidget( m_summaryExpand );
|
||||
m_expandL->addWidget( DynamicControlWrapper::createDummy( m_summaryExpand, this ) );
|
||||
m_summaryLayout->addLayout( m_expandL );
|
||||
if( m_isLocal )
|
||||
summaryLayout->addWidget( m_summaryExpand );
|
||||
m_expandL->setCurrentIndex( 0 );
|
||||
else
|
||||
m_expandL->setCurrentIndex( 1 );
|
||||
|
||||
m_layout->addWidget( m_summaryWidget );
|
||||
connect( m_summaryExpand, SIGNAL( clicked( bool ) ), this, SLOT( toggleCollapse() ) );
|
||||
|
||||
@@ -120,6 +125,15 @@ CollapsibleControls::setControls( const dynplaylist_ptr& playlist, bool isLocal
|
||||
m_dynplaylist = playlist;
|
||||
m_isLocal = isLocal;
|
||||
m_controls->setControls( m_dynplaylist->generator(), m_dynplaylist->generator()->controls() );
|
||||
|
||||
if( !m_isLocal ) {
|
||||
m_expandL->setCurrentIndex( 1 );
|
||||
m_summary->setText( m_dynplaylist->generator()->sentenceSummary() );
|
||||
m_layout->setCurrentWidget( m_summaryWidget );
|
||||
setMaximumHeight( m_summaryWidget->sizeHint().height() );
|
||||
} else {
|
||||
m_expandL->setCurrentIndex( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -128,7 +142,6 @@ CollapsibleControls::toggleCollapse()
|
||||
// qDebug() << "TOGGLING SIZEHINTS:" << m_controls->height() << m_summaryWidget->sizeHint();
|
||||
m_timeline->setEasingCurve( QEasingCurve::OutBack );
|
||||
m_timeline->setFrameRange( m_summaryWidget->sizeHint().height(), m_controls->height() );
|
||||
m_collapseAnimation = true;
|
||||
if( m_layout->currentWidget() == m_controls ) {
|
||||
m_summary->setText( m_dynplaylist->generator()->sentenceSummary() );
|
||||
m_controls->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Ignored );
|
||||
@@ -136,6 +149,7 @@ CollapsibleControls::toggleCollapse()
|
||||
m_timeline->setDirection( QTimeLine::Backward );
|
||||
m_timeline->start();
|
||||
|
||||
m_collapseAnimation = true;
|
||||
} else {
|
||||
m_summaryWidget->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Ignored );
|
||||
m_layout->setCurrentWidget( m_controls );
|
||||
@@ -143,6 +157,7 @@ CollapsibleControls::toggleCollapse()
|
||||
m_timeline->setDirection( QTimeLine::Forward );
|
||||
m_timeline->start();
|
||||
|
||||
m_collapseAnimation = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +177,7 @@ CollapsibleControls::onAnimationFinished()
|
||||
setMaximumHeight( m_animHeight );
|
||||
m_animHeight = -1;
|
||||
|
||||
if( m_collapseAnimation && m_layout->currentWidget() == m_controls && m_timeline->direction() == QTimeLine::Backward ) {
|
||||
if( m_collapseAnimation ) {
|
||||
m_layout->setCurrentWidget( m_summaryWidget );
|
||||
} else {
|
||||
setMaximumHeight( QWIDGETSIZE_MAX );
|
||||
|
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QHBoxLayout;
|
||||
class QTimeLine;
|
||||
class QToolButton;
|
||||
class QLabel;
|
||||
@@ -63,7 +64,9 @@ private:
|
||||
bool m_isLocal;
|
||||
|
||||
QWidget* m_summaryWidget;
|
||||
QHBoxLayout* m_summaryLayout;
|
||||
QLabel* m_summary;
|
||||
QStackedLayout* m_expandL;
|
||||
QToolButton* m_summaryExpand;
|
||||
|
||||
// animations!
|
||||
|
@@ -48,7 +48,7 @@ DynamicControlWrapper::DynamicControlWrapper( const Tomahawk::dyncontrol_ptr& co
|
||||
m_matchSelector = control->matchSelector();
|
||||
m_entryWidget = control->inputField();
|
||||
|
||||
m_minusButton = initButton();
|
||||
m_minusButton = initButton( m_parent );
|
||||
m_minusButton->setIcon( QIcon( RESPATH "images/list-remove.png" ) );
|
||||
connect( m_minusButton, SIGNAL( clicked( bool ) ), this, SIGNAL( removeControl() ) );
|
||||
|
||||
@@ -57,7 +57,7 @@ DynamicControlWrapper::DynamicControlWrapper( const Tomahawk::dyncontrol_ptr& co
|
||||
m_plusL->setContentsMargins( 0, 0, 0, 0 );
|
||||
m_plusL->setMargin( 0 );
|
||||
m_plusL->addWidget( m_minusButton );
|
||||
m_plusL->addWidget( createDummy( m_minusButton ) ); // :-(
|
||||
m_plusL->addWidget( createDummy( m_minusButton, m_parent ) ); // :-(
|
||||
|
||||
connect( m_typeSelector, SIGNAL( activated( QString) ), SLOT( typeSelectorChanged( QString ) ) );
|
||||
connect( m_control.data(), SIGNAL( changed() ), this, SIGNAL( changed() ) );
|
||||
@@ -107,9 +107,9 @@ DynamicControlWrapper::removeFromLayout()
|
||||
}
|
||||
|
||||
|
||||
QToolButton* DynamicControlWrapper::initButton()
|
||||
QToolButton* DynamicControlWrapper::initButton( QWidget* parent )
|
||||
{
|
||||
QToolButton* btn = new QToolButton( m_parent );
|
||||
QToolButton* btn = new QToolButton( parent );
|
||||
btn->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
|
||||
btn->setIconSize( QSize( 16, 16 ) );
|
||||
btn->setToolButtonStyle( Qt::ToolButtonIconOnly );
|
||||
@@ -118,9 +118,9 @@ QToolButton* DynamicControlWrapper::initButton()
|
||||
return btn;
|
||||
}
|
||||
|
||||
QWidget* DynamicControlWrapper::createDummy( QWidget* fromW )
|
||||
QWidget* DynamicControlWrapper::createDummy( QWidget* fromW, QWidget* parent )
|
||||
{
|
||||
QWidget* dummy = new QWidget( m_parent );
|
||||
QWidget* dummy = new QWidget( parent );
|
||||
dummy->setContentsMargins( 0, 0, 0, 0 );
|
||||
dummy->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
|
||||
dummy->setMinimumSize( fromW->size() );
|
||||
|
@@ -48,6 +48,10 @@ public:
|
||||
dyncontrol_ptr control() const;
|
||||
|
||||
void removeFromLayout();
|
||||
|
||||
|
||||
static QToolButton* initButton( QWidget* parent );
|
||||
static QWidget* createDummy( QWidget* fromW, QWidget* parent );
|
||||
signals:
|
||||
void collapse();
|
||||
void removeControl();
|
||||
@@ -57,9 +61,6 @@ private slots:
|
||||
void typeSelectorChanged( const QString& selectedType, bool firstLoad = false );
|
||||
|
||||
private:
|
||||
QToolButton* initButton();
|
||||
QWidget* createDummy( QWidget* fromW );
|
||||
|
||||
QWidget* m_parent;
|
||||
int m_row;
|
||||
QStackedLayout* m_plusL;
|
||||
|
Reference in New Issue
Block a user