mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-10 08:04:25 +02:00
save working but weird splitter sizes
This commit is contained in:
@@ -19,10 +19,13 @@
|
|||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPaintEvent>
|
#include <QPaintEvent>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QToolButton>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
#include "DynamicControlWidget.h"
|
#include "DynamicControlWidget.h"
|
||||||
#include "dynamic/GeneratorInterface.h"
|
#include "dynamic/GeneratorInterface.h"
|
||||||
|
#include "tomahawk/tomahawkapp.h"
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
@@ -67,7 +70,10 @@ DynamicControlList::init()
|
|||||||
m_layout->setMargin( 0 );
|
m_layout->setMargin( 0 );
|
||||||
m_layout->setSpacing( 0 );
|
m_layout->setSpacing( 0 );
|
||||||
m_layout->setContentsMargins( 0, 0, 0, 0 );
|
m_layout->setContentsMargins( 0, 0, 0, 0 );
|
||||||
|
m_layout->setSizeConstraint( QLayout::SetMinimumSize );
|
||||||
// setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Ignored );
|
// setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Ignored );
|
||||||
|
splitter()->setStretchFactor( 0, 0 );
|
||||||
|
splitter()->setStretchFactor( 1,1 );
|
||||||
|
|
||||||
m_summaryWidget = new QWidget( this );
|
m_summaryWidget = new QWidget( this );
|
||||||
// TODO replace
|
// TODO replace
|
||||||
@@ -78,8 +84,28 @@ DynamicControlList::init()
|
|||||||
m_summaryWidget->layout()->setMargin( 0 );
|
m_summaryWidget->layout()->setMargin( 0 );
|
||||||
m_summaryWidget->layout()->addWidget( new QLabel( "replace me plz", m_summaryWidget ) );
|
m_summaryWidget->layout()->addWidget( new QLabel( "replace me plz", m_summaryWidget ) );
|
||||||
|
|
||||||
setHiddenSize( m_summaryWidget->size() );
|
m_collapseLayout = new QHBoxLayout( this );
|
||||||
|
m_collapseLayout->setContentsMargins( 0, 0, 0, 0 );
|
||||||
|
m_collapseLayout->setMargin( 0 );
|
||||||
|
m_collapseLayout->setSpacing( 0 );
|
||||||
|
m_collapse = new QPushButton( tr( "Click to collapse" ), this );
|
||||||
|
m_collapseLayout->addWidget( m_collapse );
|
||||||
|
m_addControl = new QToolButton( this );
|
||||||
|
m_addControl->setIcon( QIcon( RESPATH "images/list-add.png" ) );
|
||||||
|
m_addControl->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
|
||||||
|
m_addControl->setIconSize( QSize( 16, 16 ) );
|
||||||
|
m_addControl->setToolButtonStyle( Qt::ToolButtonIconOnly );
|
||||||
|
m_addControl->setAutoRaise( true );
|
||||||
|
m_addControl->setContentsMargins( 0, 0, 0, 0 );
|
||||||
|
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() ) );
|
||||||
|
|
||||||
|
setHiddenSize( m_summaryWidget->size() );
|
||||||
|
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
|
||||||
emit showWidget();
|
emit showWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,15 +119,13 @@ DynamicControlList::setControls( const geninterface_ptr& generator, const QList<
|
|||||||
m_isLocal = isLocal;
|
m_isLocal = isLocal;
|
||||||
m_generator = generator;
|
m_generator = generator;
|
||||||
if( controls.isEmpty() ) {
|
if( controls.isEmpty() ) {
|
||||||
m_controls << new DynamicControlWidget( generator->createControl(), false, false, false, isLocal, this );
|
m_controls << new DynamicControlWidget( generator->createControl(), isLocal, this );
|
||||||
connect( m_controls.last(), SIGNAL( addNewControl() ), this, SLOT( addNewControl() ) );
|
|
||||||
connect( m_controls.last(), SIGNAL( removeControl() ), this, SLOT( removeControl() ) );
|
connect( m_controls.last(), SIGNAL( removeControl() ), this, SLOT( removeControl() ) );
|
||||||
connect( m_controls.last(), SIGNAL( changed() ), this, SLOT( controlChanged() ) );
|
connect( m_controls.last(), SIGNAL( changed() ), this, SLOT( controlChanged() ) );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
foreach( const dyncontrol_ptr& control, controls ) {
|
foreach( const dyncontrol_ptr& control, controls ) {
|
||||||
m_controls << new DynamicControlWidget( control, false, false, false, isLocal, this );
|
m_controls << new DynamicControlWidget( control, isLocal, this );
|
||||||
connect( m_controls.last(), SIGNAL( addNewControl() ), this, SLOT( addNewControl() ) );
|
|
||||||
connect( m_controls.last(), SIGNAL( removeControl() ), this, SLOT( removeControl() ) );
|
connect( m_controls.last(), SIGNAL( removeControl() ), this, SLOT( removeControl() ) );
|
||||||
connect( m_controls.last(), SIGNAL( changed() ), this, SLOT( controlChanged() ) );
|
connect( m_controls.last(), SIGNAL( changed() ), this, SLOT( controlChanged() ) );
|
||||||
}
|
}
|
||||||
@@ -134,23 +158,21 @@ DynamicControlList::onShown( QWidget* w )
|
|||||||
AnimatedWidget::onShown( w );
|
AnimatedWidget::onShown( w );
|
||||||
|
|
||||||
m_layout->removeWidget( m_summaryWidget );
|
m_layout->removeWidget( m_summaryWidget );
|
||||||
|
m_layout->removeItem( m_collapseLayout );
|
||||||
m_summaryWidget->hide();
|
m_summaryWidget->hide();
|
||||||
foreach( DynamicControlWidget* control, m_controls ) {
|
foreach( DynamicControlWidget* control, m_controls ) {
|
||||||
m_layout->addWidget( control );
|
m_layout->addWidget( control );
|
||||||
control->show();
|
control->show();
|
||||||
control->setShowMinusButton( control != m_controls.last() );
|
|
||||||
control->setShowPlusButton( control == m_controls.last() );
|
|
||||||
control->setShowCollapseButton( control == m_controls.last() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_layout->addLayout( m_collapseLayout );
|
||||||
|
m_layout->setStretchFactor( m_collapseLayout, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicControlList::addNewControl()
|
void DynamicControlList::addNewControl()
|
||||||
{
|
{
|
||||||
m_controls.last()->setShowCollapseButton( false );
|
|
||||||
m_controls.last()->setShowPlusButton( false );
|
|
||||||
m_controls.last()->setShowMinusButton( true );
|
|
||||||
dyncontrol_ptr control = m_generator->createControl();
|
dyncontrol_ptr control = m_generator->createControl();
|
||||||
m_controls.append( new DynamicControlWidget( control, true, false, true, m_isLocal, this ) );
|
m_controls.append( new DynamicControlWidget( control, m_isLocal, this ) );
|
||||||
m_layout->addWidget( m_controls.last() );
|
m_layout->addWidget( m_controls.last() );
|
||||||
connect( m_controls.last(), SIGNAL( addNewControl() ), this, SLOT( addNewControl() ) );
|
connect( m_controls.last(), SIGNAL( addNewControl() ), this, SLOT( addNewControl() ) );
|
||||||
connect( m_controls.last(), SIGNAL( removeControl() ), this, SLOT( removeControl() ) );
|
connect( m_controls.last(), SIGNAL( removeControl() ), this, SLOT( removeControl() ) );
|
||||||
@@ -168,11 +190,6 @@ void DynamicControlList::removeControl()
|
|||||||
m_generator->removeControl( w->control() );
|
m_generator->removeControl( w->control() );
|
||||||
delete w;
|
delete w;
|
||||||
|
|
||||||
|
|
||||||
m_controls.last()->setShowCollapseButton( true );
|
|
||||||
m_controls.last()->setShowPlusButton( true );
|
|
||||||
m_controls.last()->setShowMinusButton( false );
|
|
||||||
|
|
||||||
emit controlsChanged();
|
emit controlsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,7 +21,11 @@
|
|||||||
#include "typedefs.h"
|
#include "typedefs.h"
|
||||||
#include "dynamic/DynamicPlaylist.h"
|
#include "dynamic/DynamicPlaylist.h"
|
||||||
|
|
||||||
|
class QPushButton;
|
||||||
|
class QHBoxLayout;
|
||||||
class QVBoxLayout;
|
class QVBoxLayout;
|
||||||
|
class QToolButton;
|
||||||
|
|
||||||
namespace Tomahawk
|
namespace Tomahawk
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -66,6 +70,11 @@ private:
|
|||||||
QVBoxLayout* m_layout;
|
QVBoxLayout* m_layout;
|
||||||
QList< DynamicControlWidget* > m_controls;
|
QList< DynamicControlWidget* > m_controls;
|
||||||
QWidget* m_summaryWidget;
|
QWidget* m_summaryWidget;
|
||||||
|
|
||||||
|
QHBoxLayout* m_collapseLayout;
|
||||||
|
QPushButton* m_collapse;
|
||||||
|
QToolButton* m_addControl;
|
||||||
|
|
||||||
bool m_isLocal;
|
bool m_isLocal;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -30,15 +30,11 @@
|
|||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
DynamicControlWidget::DynamicControlWidget( const Tomahawk::dyncontrol_ptr& control, bool showPlus, bool showMinus, bool showCollapse, bool isLocal, QWidget* parent )
|
DynamicControlWidget::DynamicControlWidget( const Tomahawk::dyncontrol_ptr& control, bool isLocal, QWidget* parent )
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, m_showPlus( showPlus )
|
|
||||||
, m_showMinus( showMinus )
|
|
||||||
, m_showCollapse( showCollapse )
|
|
||||||
, m_isLocal( isLocal )
|
, m_isLocal( isLocal )
|
||||||
, m_plusButton( 0 )
|
, m_mouseOver( false )
|
||||||
, m_minusButton( 0 )
|
, m_minusButton( 0 )
|
||||||
, m_collapseButton( 0 )
|
|
||||||
, m_control( control )
|
, m_control( control )
|
||||||
, m_typeSelector( 0 )
|
, m_typeSelector( 0 )
|
||||||
, m_matchSelector( 0 )
|
, m_matchSelector( 0 )
|
||||||
@@ -69,28 +65,13 @@ DynamicControlWidget::DynamicControlWidget( const Tomahawk::dyncontrol_ptr& cont
|
|||||||
connect( m_minusButton, SIGNAL( clicked( bool ) ), this, SIGNAL( removeControl() ) );
|
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 = new QStackedLayout;
|
||||||
m_plusL->setContentsMargins( 0, 0, 0, 0 );
|
m_plusL->setContentsMargins( 0, 0, 0, 0 );
|
||||||
m_plusL->setMargin( 0 );
|
m_plusL->setMargin( 0 );
|
||||||
m_plusL->addWidget( m_plusButton );
|
|
||||||
m_plusL->addWidget( m_minusButton );
|
m_plusL->addWidget( m_minusButton );
|
||||||
m_plusL->addWidget( createDummy( m_plusButton ) ); // :-(
|
m_plusL->addWidget( createDummy( m_minusButton ) ); // :-(
|
||||||
m_plusL->setCurrentIndex( 2 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_collapseButton = initButton();
|
|
||||||
m_collapseButton->setIcon( QIcon( RESPATH "images/arrow-up-double.png" ) );
|
|
||||||
m_collapseL = new QStackedLayout;
|
|
||||||
m_collapseL->setContentsMargins( 0, 0, 0, 0 );
|
|
||||||
m_collapseL->setMargin( 0 );
|
|
||||||
m_collapseL->addWidget( m_collapseButton );
|
|
||||||
m_collapseL->addWidget( createDummy( m_collapseButton ) ); // :-(
|
|
||||||
m_collapseL->setCurrentIndex( 1 );
|
|
||||||
|
|
||||||
connect( m_collapseButton, SIGNAL( clicked( bool ) ), this, SIGNAL( collapse() ) );
|
|
||||||
connect( typeSelector, SIGNAL( activated( QString) ), SLOT( typeSelectorChanged( QString ) ) );
|
connect( typeSelector, SIGNAL( activated( QString) ), SLOT( typeSelectorChanged( QString ) ) );
|
||||||
connect( m_control.data(), SIGNAL( changed() ), this, SIGNAL( changed() ) );
|
connect( m_control.data(), SIGNAL( changed() ), this, SIGNAL( changed() ) );
|
||||||
|
|
||||||
@@ -103,20 +84,13 @@ DynamicControlWidget::DynamicControlWidget( const Tomahawk::dyncontrol_ptr& cont
|
|||||||
|
|
||||||
typeSelectorChanged( m_control.isNull() ? "" : m_control->selectedType(), true );
|
typeSelectorChanged( m_control.isNull() ? "" : m_control->selectedType(), true );
|
||||||
|
|
||||||
m_layout->addLayout( m_collapseL, 0 );
|
|
||||||
|
|
||||||
if( m_isLocal )
|
if( m_isLocal )
|
||||||
{
|
{
|
||||||
m_layout->addLayout( m_plusL, 0 );
|
m_layout->addLayout( m_plusL, 0 );
|
||||||
|
m_plusL->setCurrentIndex( 1 );
|
||||||
if( m_showPlus )
|
|
||||||
m_plusL->setCurrentIndex( 0 );
|
|
||||||
if( m_showMinus )
|
|
||||||
m_plusL->setCurrentIndex( 1 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_showCollapse )
|
setMouseTracking( true );
|
||||||
m_collapseL->setCurrentIndex( 0 );
|
|
||||||
setLayout( m_layout );
|
setLayout( m_layout );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,39 +160,12 @@ DynamicControlWidget::typeSelectorChanged( const QString& type, bool firstLoad )
|
|||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
DynamicControlWidget::setShowPlusButton(bool show)
|
|
||||||
{
|
|
||||||
|
|
||||||
if( m_showPlus != show && m_isLocal ) {
|
|
||||||
show ? m_plusL->setCurrentIndex( 0 ) : m_plusL->setCurrentIndex( 2 );
|
|
||||||
}
|
|
||||||
|
|
||||||
m_showPlus = show;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
DynamicControlWidget::setShowCollapseButton(bool show)
|
|
||||||
{
|
|
||||||
if( m_showCollapse != show ) {
|
|
||||||
show ? m_collapseL->setCurrentIndex( 0 ) : m_collapseL->setCurrentIndex( 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
m_showCollapse = show;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
DynamicControlWidget::setShowMinusButton(bool show)
|
|
||||||
{
|
|
||||||
m_showMinus = show;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicControlWidget::enterEvent(QEvent* ev)
|
DynamicControlWidget::enterEvent(QEvent* ev)
|
||||||
{
|
{
|
||||||
if( m_showMinus && m_isLocal )
|
m_mouseOver = true;
|
||||||
m_plusL->setCurrentIndex( 1 );
|
if( m_isLocal )
|
||||||
|
m_plusL->setCurrentIndex( 0 );
|
||||||
|
|
||||||
if( ev )
|
if( ev )
|
||||||
QWidget::enterEvent( ev );
|
QWidget::enterEvent( ev );
|
||||||
@@ -227,13 +174,22 @@ DynamicControlWidget::enterEvent(QEvent* ev)
|
|||||||
void
|
void
|
||||||
DynamicControlWidget::leaveEvent(QEvent* ev)
|
DynamicControlWidget::leaveEvent(QEvent* ev)
|
||||||
{
|
{
|
||||||
if( m_showMinus && m_isLocal )
|
m_mouseOver = true;
|
||||||
m_plusL->setCurrentIndex( 2 );
|
if( m_isLocal )
|
||||||
|
m_plusL->setCurrentIndex( 1 );
|
||||||
|
|
||||||
if( ev )
|
if( ev )
|
||||||
QWidget::leaveEvent( ev );
|
QWidget::leaveEvent( ev );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DynamicControlWidget::mouseMoveEvent(QMouseEvent* ev)
|
||||||
|
{
|
||||||
|
m_mouseOver = true;
|
||||||
|
setMouseTracking( false );
|
||||||
|
enterEvent( ev );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicControlWidget::paintEvent(QPaintEvent* )
|
DynamicControlWidget::paintEvent(QPaintEvent* )
|
||||||
|
@@ -39,21 +39,17 @@ class DynamicControlWidget : public QWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit DynamicControlWidget( const dyncontrol_ptr& control, bool showPlus = false, bool showMinus = false, bool showCollapse = false, bool isLocal = false, QWidget* parent = 0);
|
explicit DynamicControlWidget( const dyncontrol_ptr& control, bool isLocal = false, QWidget* parent = 0);
|
||||||
virtual ~DynamicControlWidget();
|
virtual ~DynamicControlWidget();
|
||||||
|
|
||||||
void setShowPlusButton( bool show );
|
|
||||||
void setShowMinusButton( bool show );
|
|
||||||
void setShowCollapseButton( bool show );
|
|
||||||
|
|
||||||
virtual void paintEvent(QPaintEvent* );
|
virtual void paintEvent(QPaintEvent* );
|
||||||
virtual void enterEvent(QEvent* );
|
virtual void enterEvent(QEvent* );
|
||||||
virtual void leaveEvent(QEvent* );
|
virtual void leaveEvent(QEvent* );
|
||||||
|
virtual void mouseMoveEvent(QMouseEvent* );
|
||||||
|
|
||||||
dyncontrol_ptr control() const;
|
dyncontrol_ptr control() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void addNewControl();
|
|
||||||
void collapse();
|
void collapse();
|
||||||
void removeControl();
|
void removeControl();
|
||||||
void changed();
|
void changed();
|
||||||
@@ -65,17 +61,11 @@ private:
|
|||||||
QToolButton* initButton();
|
QToolButton* initButton();
|
||||||
QWidget* createDummy( QWidget* fromW );
|
QWidget* createDummy( QWidget* fromW );
|
||||||
|
|
||||||
bool m_showPlus;
|
bool m_isLocal, m_mouseOver;
|
||||||
bool m_showMinus;
|
|
||||||
bool m_showCollapse;
|
|
||||||
bool m_isLocal;
|
|
||||||
|
|
||||||
// i hate qlayout
|
// i hate qlayout
|
||||||
QStackedLayout* m_plusL;
|
QStackedLayout* m_plusL;
|
||||||
QToolButton* m_plusButton;
|
|
||||||
QToolButton* m_minusButton;
|
QToolButton* m_minusButton;
|
||||||
QStackedLayout* m_collapseL;
|
|
||||||
QToolButton* m_collapseButton;
|
|
||||||
|
|
||||||
dyncontrol_ptr m_control;
|
dyncontrol_ptr m_control;
|
||||||
ReadOrWriteWidget* m_typeSelector;
|
ReadOrWriteWidget* m_typeSelector;
|
||||||
@@ -89,3 +79,5 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
class QPaintEvent;
|
class QPaintEvent;
|
||||||
|
|
||||||
|
class QMouseEvent;
|
||||||
|
@@ -67,7 +67,10 @@ signals:
|
|||||||
void hideWidget();
|
void hideWidget();
|
||||||
|
|
||||||
void hiddenSizeChanged();
|
void hiddenSizeChanged();
|
||||||
|
protected:
|
||||||
|
|
||||||
|
AnimatedSplitter* splitter() { return m_parent; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AnimatedSplitter* m_parent;
|
AnimatedSplitter* m_parent;
|
||||||
QSize m_hiddenSize;
|
QSize m_hiddenSize;
|
||||||
|
Reference in New Issue
Block a user