1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-19 04:11:46 +02:00

Refactor dynamic control UI to fit in a gridlayout, and remove the AnimatedSplitter to replace with a QStackedWidget

This commit is contained in:
Leo Franchi
2011-01-22 13:31:13 -05:00
parent 992275e174
commit 7eb6822725
9 changed files with 272 additions and 186 deletions

View File

@@ -98,10 +98,11 @@ set( libSources
playlist/dynamic/echonest/EchonestGenerator.cpp
playlist/dynamic/echonest/EchonestControl.cpp
playlist/dynamic/widgets/DynamicWidget.cpp
playlist/dynamic/widgets/DynamicControlWidget.cpp
playlist/dynamic/widgets/DynamicControlWrapper.cpp
playlist/dynamic/widgets/DynamicControlList.cpp
playlist/dynamic/widgets/ReadOrWriteWidget.cpp
playlist/dynamic/widgets/MiscControlWidgets.cpp
playlist/dynamic/widgets/CollapsibleControls.cpp
network/bufferiodevice.cpp
@@ -228,10 +229,11 @@ set( libHeaders
playlist/dynamic/echonest/EchonestGenerator.h
playlist/dynamic/echonest/EchonestControl.h
playlist/dynamic/widgets/DynamicWidget.h
playlist/dynamic/widgets/DynamicControlWidget.h
playlist/dynamic/widgets/DynamicControlWrapper.h
playlist/dynamic/widgets/DynamicControlList.h
playlist/dynamic/widgets/ReadOrWriteWidget.h
playlist/dynamic/widgets/MiscControlWidgets.h
playlist/dynamic/widgets/CollapsibleControls.h
utils/querylabel.h
utils/elidedlabel.h

View File

@@ -0,0 +1,94 @@
/****************************************************************************************
* Copyright (c) 2010-2011 Leo Franchi <lfranchi@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify it under *
* the terms of the GNU General Public License as published by the Free Software *
* Foundation; either version 2 of the License, or (at your option) any later *
* version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT ANY *
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A *
* PARTICULAR PURPOSE. See the GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License along with *
* this program. If not, see <http://www.gnu.org/licenses/>. *
****************************************************************************************/
#include "CollapsibleControls.h"
#include "DynamicControlList.h"
#include "DynamicControlWrapper.h"
#include "dynamic/GeneratorInterface.h"
#include "dynamic/DynamicControl.h"
#include <QLabel>
#include <QStackedLayout>
using namespace Tomahawk;
CollapsibleControls::CollapsibleControls( QWidget* parent )
: QWidget( parent )
{
init();
}
CollapsibleControls::CollapsibleControls( const geninterface_ptr& generator, const QList< dyncontrol_ptr >& controls, bool isLocal, QWidget* parent )
: QWidget( parent )
{
init();
setControls( generator, controls, isLocal );
}
Tomahawk::CollapsibleControls::~CollapsibleControls()
{
}
void
CollapsibleControls::init()
{
m_layout = new QStackedLayout;
setContentsMargins( 0, 0, 0, 0 );
m_layout->setContentsMargins( 0, 0, 0, 0 );
m_layout->setSpacing( 0 );
m_controls = new Tomahawk::DynamicControlList( this );
m_layout->addWidget( m_controls );
m_summaryWidget = new QWidget( this );
// TODO replace
// m_summaryWidget->setMinimumHeight( 24 );
// m_summaryWidget->setMaximumHeight( 24 );
m_summaryWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
m_summaryWidget->setLayout( new QVBoxLayout );
m_summaryWidget->layout()->setMargin( 0 );
m_summaryWidget->layout()->addWidget( new QLabel( "replace me plz", m_summaryWidget ) );
m_layout->addWidget( m_summaryWidget );
m_layout->setCurrentIndex( 0 );
connect( m_controls, SIGNAL( controlChanged( Tomahawk::dyncontrol_ptr ) ), SIGNAL( controlChanged( Tomahawk::dyncontrol_ptr ) ) );
connect( m_controls, SIGNAL( controlsChanged() ), SIGNAL( controlsChanged() ) );
setLayout( m_layout );
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
}
QList< DynamicControlWrapper* >
Tomahawk::CollapsibleControls::controls() const
{
return m_controls->controls();
}
void
CollapsibleControls::setControls( const geninterface_ptr& generator, const QList< dyncontrol_ptr >& controls, bool isLocal )
{
m_controls->setControls( generator, controls, isLocal );
}
void
CollapsibleControls::toggleCollapse()
{
}

View File

@@ -0,0 +1,59 @@
/****************************************************************************************
* Copyright (c) 2010-2011 Leo Franchi <lfranchi@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify it under *
* the terms of the GNU General Public License as published by the Free Software *
* Foundation; either version 2 of the License, or (at your option) any later *
* version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT ANY *
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A *
* PARTICULAR PURPOSE. See the GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License along with *
* this program. If not, see <http://www.gnu.org/licenses/>. *
****************************************************************************************/
#ifndef COLLAPSIBLE_CONTROLS_H
#define COLLAPSIBLE_CONTROLS_H
#include "typedefs.h"
#include <QWidget>
class QStackedLayout;
namespace Tomahawk
{
class DynamicControlWrapper;
class DynamicControlList;
class CollapsibleControls : public QWidget
{
Q_OBJECT
public:
CollapsibleControls( QWidget* parent );
CollapsibleControls( const geninterface_ptr& generator, const QList< dyncontrol_ptr >& controls, bool isLocal, QWidget* parent = 0 );
virtual ~CollapsibleControls();
void setControls( const geninterface_ptr& generator, const QList< dyncontrol_ptr >& controls, bool isLocal );
QList< DynamicControlWrapper* > controls() const;
signals:
void controlsChanged();
void controlChanged( const Tomahawk::dyncontrol_ptr& control );
private slots:
void toggleCollapse();
private:
void init();
QStackedLayout* m_layout;
DynamicControlList* m_controls;
QWidget* m_summaryWidget;
};
}
#endif

View File

@@ -22,35 +22,27 @@
#include <QPushButton>
#include <QToolButton>
#include <QPainter>
#include <QGridLayout>
#include "DynamicControlWidget.h"
#include "DynamicControlWrapper.h"
#include "dynamic/GeneratorInterface.h"
#include "tomahawk/tomahawkapp.h"
#include <QHBoxLayout>
using namespace Tomahawk;
DynamicControlList::DynamicControlList()
: AnimatedWidget()
, m_layout( new QVBoxLayout )
DynamicControlList::DynamicControlList( QWidget* parent )
: QWidget( parent )
, m_layout( new QGridLayout )
, m_summaryWidget( 0 )
{
init();
}
DynamicControlList::DynamicControlList( AnimatedSplitter* parent )
: AnimatedWidget( parent )
, m_layout( new QVBoxLayout )
, m_summaryWidget( 0 )
, m_isLocal( true )
{
init();
}
DynamicControlList::DynamicControlList( const geninterface_ptr& generator, const QList< dyncontrol_ptr >& controls, AnimatedSplitter* parent, bool isLocal )
: AnimatedWidget(parent)
DynamicControlList::DynamicControlList( const geninterface_ptr& generator, const QList< dyncontrol_ptr >& controls, bool isLocal, QWidget* parent )
: QWidget( parent )
, m_generator( generator )
, m_layout( new QVBoxLayout )
, m_layout( new QGridLayout )
, m_summaryWidget( 0 )
, m_isLocal( isLocal )
{
@@ -66,23 +58,14 @@ DynamicControlList::~DynamicControlList()
void
DynamicControlList::init()
{
qDebug() << "GRIDLAYOUT: " << m_layout->rowCount();
setContentsMargins( 0, 0, 0, 0 );
setLayout( m_layout );
m_layout->setColumnStretch( 2, 1 );
m_layout->setMargin( 0 );
m_layout->setSpacing( 0 );
m_layout->setContentsMargins( 0, 0, 0, 0 );
m_layout->setSizeConstraint( QLayout::SetMinimumSize );
// setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Ignored );
splitter()->setStretchFactor( 0, 0 );
splitter()->setStretchFactor( 1,1 );
m_summaryWidget = new QWidget( this );
// TODO replace
// m_summaryWidget->setMinimumHeight( 24 );
// m_summaryWidget->setMaximumHeight( 24 );
m_summaryWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
m_summaryWidget->setLayout( new QVBoxLayout );
m_summaryWidget->layout()->setMargin( 0 );
m_summaryWidget->layout()->addWidget( new QLabel( "replace me plz", m_summaryWidget ) );
m_collapseLayout = new QHBoxLayout( this );
m_collapseLayout->setContentsMargins( 0, 0, 0, 0 );
@@ -100,12 +83,10 @@ DynamicControlList::init()
m_collapseLayout->addWidget( m_addControl );
m_collapse->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
// connect( m_collapse, SIGNAL( clicked() ), this, );
connect( m_collapse, SIGNAL( clicked() ), this, SIGNAL( toggleCollapse() ) );
connect( m_addControl, SIGNAL( clicked() ), this, SLOT( addNewControl() ) );
setHiddenSize( m_summaryWidget->size() );
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
emit showWidget();
}
void
@@ -115,65 +96,36 @@ DynamicControlList::setControls( const geninterface_ptr& generator, const QList<
qDeleteAll( m_controls );
m_controls.clear();
}
m_layout->removeItem( m_collapseLayout );
m_isLocal = isLocal;
m_generator = generator;
if( controls.isEmpty() ) {
m_controls << new DynamicControlWidget( generator->createControl(), isLocal, this );
connect( m_controls.last(), SIGNAL( removeControl() ), this, SLOT( removeControl() ) );
connect( m_controls.last(), SIGNAL( changed() ), this, SLOT( controlChanged() ) );
qDebug() << "CREATING DEFAULT CONTROL";
DynamicControlWrapper* ctrlW = new DynamicControlWrapper( generator->createControl(), m_layout, m_controls.size(), isLocal, this );
connect( ctrlW, SIGNAL( removeControl() ), this, SLOT( removeControl() ) );
connect( ctrlW, SIGNAL( changed() ), this, SLOT( controlChanged() ) );
m_controls << ctrlW;
} else
{
foreach( const dyncontrol_ptr& control, controls ) {
m_controls << new DynamicControlWidget( control, isLocal, this );
connect( m_controls.last(), SIGNAL( removeControl() ), this, SLOT( removeControl() ) );
connect( m_controls.last(), SIGNAL( changed() ), this, SLOT( controlChanged() ) );
DynamicControlWrapper* ctrlW = new DynamicControlWrapper( control, m_layout, m_controls.size(), isLocal, this );
connect( ctrlW, SIGNAL( removeControl() ), this, SLOT( removeControl() ) );
connect( ctrlW, SIGNAL( changed() ), this, SLOT( controlChanged() ) );
m_controls << ctrlW;
}
}
onShown( this );
}
void
DynamicControlList::onHidden( QWidget* w )
{
if( w != this )
return;
m_layout->addItem( m_collapseLayout, m_layout->rowCount(), 0, 1, 4, Qt::AlignCenter );
AnimatedWidget::onHidden( w );
foreach( DynamicControlWidget* control, m_controls ) {
m_layout->removeWidget( control );
control->hide();
}
m_layout->addWidget( m_summaryWidget );
m_summaryWidget->show();
}
void
DynamicControlList::onShown( QWidget* w )
{
if( w != this )
return;
m_layout->removeWidget( m_summaryWidget );
m_layout->removeItem( m_collapseLayout );
m_summaryWidget->hide();
foreach( DynamicControlWidget* control, m_controls ) {
m_layout->addWidget( control );
}
m_layout->addItem( m_collapseLayout );
m_layout->setStretchFactor( m_collapseLayout, 1 );
AnimatedWidget::onShown( w );
}
void DynamicControlList::addNewControl()
{
dyncontrol_ptr control = m_generator->createControl();
m_controls.append( new DynamicControlWidget( control, m_isLocal, this ) );
m_layout->insertWidget( m_layout->count() - 1, m_controls.last() );
m_controls.append( new DynamicControlWrapper( control, m_layout, m_controls.size(), m_isLocal, this ) );
connect( m_controls.last(), SIGNAL( removeControl() ), this, SLOT( removeControl() ) );
connect( m_controls.last(), SIGNAL( changed() ), this, SLOT( controlChanged() ) );
@@ -182,8 +134,8 @@ void DynamicControlList::addNewControl()
void DynamicControlList::removeControl()
{
DynamicControlWidget* w = qobject_cast<DynamicControlWidget*>( sender() );
m_layout->removeWidget( w );
DynamicControlWrapper* w = qobject_cast<DynamicControlWrapper*>( sender() );
w->removeFromLayout();
m_controls.removeAll( w );
m_generator->removeControl( w->control() );
@@ -194,16 +146,11 @@ void DynamicControlList::removeControl()
void DynamicControlList::controlChanged()
{
Q_ASSERT( sender() && qobject_cast<DynamicControlWidget*>(sender()) );
DynamicControlWidget* widget = qobject_cast<DynamicControlWidget*>(sender());
Q_ASSERT( sender() && qobject_cast<DynamicControlWrapper*>(sender()) );
DynamicControlWrapper* widget = qobject_cast<DynamicControlWrapper*>(sender());
qDebug() << "control changed!";
foreach( DynamicControlWidget* c, m_controls )
foreach( DynamicControlWrapper* c, m_controls )
qDebug() << c->control()->id() << c->control()->selectedType() << c->control()->match() << c->control()->input();
emit controlChanged( widget->control() );
}
void DynamicControlList::paintEvent(QPaintEvent* )
{
}

View File

@@ -17,10 +17,12 @@
#ifndef DYNAMIC_CONTROL_LIST_H
#define DYNAMIC_CONTROL_LIST_H
#include "utils/animatedsplitter.h"
#include "typedefs.h"
#include "dynamic/DynamicPlaylist.h"
#include <QStackedWidget>
class QGridLayout;
class QPushButton;
class QHBoxLayout;
class QVBoxLayout;
@@ -29,46 +31,41 @@ class QToolButton;
namespace Tomahawk
{
class DynamicControlWidget;
class DynamicControlWrapper;
/**
* This widget encapsulates the list of dynamic controls and behaves as an animated widget in
* the animated splitter
* This widget encapsulates the list of dynamic controls. It can hide or show the controls.
*/
class DynamicControlList : public AnimatedWidget
class DynamicControlList : public QWidget
{
Q_OBJECT
public:
DynamicControlList(); // bad compiler!
explicit DynamicControlList(AnimatedSplitter* parent );
explicit DynamicControlList( const geninterface_ptr& generator, const QList< dyncontrol_ptr >& controls, AnimatedSplitter* parent, bool isLocal );
DynamicControlList( QWidget* parent = 0 );
explicit DynamicControlList( const geninterface_ptr& generator, const QList< dyncontrol_ptr >& controls, bool isLocal, QWidget* parent = 0 );
virtual ~DynamicControlList();
void setControls( const geninterface_ptr& generator, const QList< dyncontrol_ptr >& controls, bool isLocal );
QList< DynamicControlWidget* > controls() const { return m_controls; }
virtual void paintEvent(QPaintEvent* );
QList< DynamicControlWrapper* > controls() const { return m_controls; }
signals:
void controlsChanged();
void controlChanged( const Tomahawk::dyncontrol_ptr& control );
void toggleCollapse();
public slots:
virtual void onHidden(QWidget* );
virtual void onShown(QWidget* );
void addNewControl();
void removeControl();
void controlChanged();
private:
void init();
geninterface_ptr m_generator;
QVBoxLayout* m_layout;
QList< DynamicControlWidget* > m_controls;
QGridLayout* m_layout;
QList< DynamicControlWrapper* > m_controls;
QWidget* m_summaryWidget;
QHBoxLayout* m_collapseLayout;

View File

@@ -1,5 +1,5 @@
/****************************************************************************************
* Copyright (c) 2010 Leo Franchi <lfranchi@kde.org> *
* Copyright (c) 2010-2011 Leo Franchi <lfranchi@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify it under *
* the terms of the GNU General Public License as published by the Free Software *
@@ -14,7 +14,7 @@
* this program. If not, see <http://www.gnu.org/licenses/>. *
****************************************************************************************/
#include "DynamicControlWidget.h"
#include "DynamicControlWrapper.h"
#include "tomahawk/tomahawkapp.h"
#include "dynamic/DynamicControl.h"
@@ -30,33 +30,28 @@
using namespace Tomahawk;
DynamicControlWidget::DynamicControlWidget( const Tomahawk::dyncontrol_ptr& control, bool isLocal, QWidget* parent )
: QWidget(parent)
DynamicControlWrapper::DynamicControlWrapper( const Tomahawk::dyncontrol_ptr& control, QGridLayout* layout, int row, bool isLocal, QWidget* parent )
: QObject( parent )
, m_isLocal( isLocal )
, m_mouseOver( false )
, m_parent( parent )
, m_row( row )
, m_minusButton( 0 )
, m_control( control )
, m_typeSelector( 0 )
, m_matchSelector( 0 )
, m_entryWidget( 0 )
, m_layout( 0 )
, m_layout( layout )
{
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
m_layout = new QHBoxLayout;
m_layout->setMargin( 0 );
m_layout->setContentsMargins( 0, 0, 0, 0 );
qDebug() << "CREATING DYNAMIC CONTROL WRAPPER WITH ROW:" << row << layout;
QComboBox* typeSelector = new QComboBox( this );
m_typeSelector = new ReadOrWriteWidget( typeSelector, m_isLocal, this );
m_matchSelector = new ReadOrWriteWidget( control->matchSelector(), m_isLocal, this );
m_entryWidget = new ReadOrWriteWidget( control->inputField(), m_isLocal, this );
m_layout->setMargin( 0 );
m_layout->setSpacing( 0 );
setContentsMargins( 0, 0, 0, 0 );
QComboBox* typeSelector = new QComboBox( parent );
m_typeSelector = new ReadOrWriteWidget( typeSelector, m_isLocal, m_parent );
m_matchSelector = new ReadOrWriteWidget( control->matchSelector(), m_isLocal, m_parent );
m_entryWidget = new ReadOrWriteWidget( control->inputField(), m_isLocal, m_parent );
if( m_isLocal )
{
m_minusButton = initButton();
@@ -74,7 +69,7 @@ DynamicControlWidget::DynamicControlWidget( const Tomahawk::dyncontrol_ptr& cont
connect( typeSelector, SIGNAL( activated( QString) ), SLOT( typeSelectorChanged( QString ) ) );
connect( m_control.data(), SIGNAL( changed() ), this, SIGNAL( changed() ) );
m_layout->addWidget( m_typeSelector, 0, Qt::AlignLeft );
m_layout->addWidget( m_typeSelector, row, 0, Qt::AlignLeft );
if( !control.isNull() ) {
foreach( const QString& type, control->typeSelectors() )
@@ -85,34 +80,45 @@ DynamicControlWidget::DynamicControlWidget( const Tomahawk::dyncontrol_ptr& cont
if( m_isLocal )
{
m_layout->addLayout( m_plusL, 0 );
m_layout->addLayout( m_plusL, m_row, 3, Qt::AlignCenter );
m_plusL->setCurrentIndex( 1 );
}
setMouseTracking( true );
setLayout( m_layout );
}
DynamicControlWidget::~DynamicControlWidget()
DynamicControlWrapper::~DynamicControlWrapper()
{
// remove the controls widgets from our layout so they are not parented
// we don't want to auto-delete them since the control should own them
// if we delete them, then the control will be holding on to null ptrs
m_layout->removeWidget( m_control->inputField() );
removeFromLayout();
m_control->inputField()->setParent( 0 );
m_layout->removeWidget( m_control->matchSelector() );
m_control->matchSelector()->setParent( 0 );
delete m_typeSelector;
delete m_matchSelector;
delete m_entryWidget;
}
dyncontrol_ptr DynamicControlWidget::control() const
dyncontrol_ptr
DynamicControlWrapper::control() const
{
return m_control;
}
QToolButton* DynamicControlWidget::initButton()
void
DynamicControlWrapper::removeFromLayout()
{
QToolButton* btn = new QToolButton( this );
m_layout->removeWidget( m_typeSelector );
m_layout->removeWidget( m_matchSelector );
m_layout->removeWidget( m_entryWidget );
m_layout->removeItem( m_plusL );
}
QToolButton* DynamicControlWrapper::initButton()
{
QToolButton* btn = new QToolButton( m_parent );
btn->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
btn->setIconSize( QSize( 16, 16 ) );
btn->setToolButtonStyle( Qt::ToolButtonIconOnly );
@@ -121,9 +127,9 @@ QToolButton* DynamicControlWidget::initButton()
return btn;
}
QWidget* DynamicControlWidget::createDummy( QWidget* fromW )
QWidget* DynamicControlWrapper::createDummy( QWidget* fromW )
{
QWidget* dummy = new QWidget( this );
QWidget* dummy = new QWidget( m_parent );
dummy->setContentsMargins( 0, 0, 0, 0 );
dummy->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
dummy->setMinimumSize( fromW->size() );
@@ -133,7 +139,7 @@ QWidget* DynamicControlWidget::createDummy( QWidget* fromW )
void
DynamicControlWidget::typeSelectorChanged( const QString& type, bool firstLoad )
DynamicControlWrapper::typeSelectorChanged( const QString& type, bool firstLoad )
{
Q_ASSERT( m_layout );
m_layout->removeWidget( m_matchSelector );
@@ -155,31 +161,32 @@ DynamicControlWidget::typeSelectorChanged( const QString& type, bool firstLoad )
m_matchSelector->setWritableWidget( m_control->matchSelector() );
m_matchSelector->setLabel( m_control->matchString() );
m_matchSelector->setWritable( m_isLocal );
m_layout->insertWidget( 1, m_matchSelector, 0 );
m_layout->addWidget( m_matchSelector, m_row, 1, Qt::AlignCenter );
}
if( m_control->inputField() ) {
m_entryWidget->setWritableWidget( m_control->inputField() );
m_entryWidget->setLabel( m_control->input() );
m_entryWidget->setWritable( m_isLocal );
m_layout->insertWidget( 2, m_entryWidget, 1 );
m_layout->addWidget( m_entryWidget, m_row, 2 );
}
emit changed();
}
/*
void
DynamicControlWidget::enterEvent(QEvent* ev)
DynamicControlWrapper::enterEvent(QEvent* ev)
{
m_mouseOver = true;
if( m_isLocal )
m_plusL->setCurrentIndex( 0 );
if( ev )
QWidget::enterEvent( ev );
QObject::enterEvent( ev );
}
void
DynamicControlWidget::leaveEvent(QEvent* ev)
DynamicControlWrapper::leaveEvent(QEvent* ev)
{
m_mouseOver = true;
if( m_isLocal )
@@ -188,17 +195,5 @@ DynamicControlWidget::leaveEvent(QEvent* ev)
if( ev )
QWidget::leaveEvent( ev );
}
void
DynamicControlWidget::mouseMoveEvent(QMouseEvent* ev)
{
m_mouseOver = true;
setMouseTracking( false );
enterEvent( ev );
}
void
DynamicControlWidget::paintEvent(QPaintEvent* )
{
}
*/

View File

@@ -1,5 +1,5 @@
/****************************************************************************************
* Copyright (c) 2010 Leo Franchi <lfranchi@kde.org> *
* Copyright (c) 2010-2011 Leo Franchi <lfranchi@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify it under *
* the terms of the GNU General Public License as published by the Free Software *
@@ -14,13 +14,14 @@
* this program. If not, see <http://www.gnu.org/licenses/>. *
****************************************************************************************/
#ifndef DYNAMIC_CONTROL_WIDGET_H
#define DYNAMIC_CONTROL_WIDGET_H
#ifndef DYNAMIC_CONTROL_WRAPPER_H
#define DYNAMIC_CONTROL_WRAPPER_H
#include <QWidget>
#include "typedefs.h"
class QGridLayout;
class ReadOrWriteWidget;
class QStackedLayout;
class QEvent;
@@ -33,22 +34,21 @@ namespace Tomahawk
{
/**
* This widget holds one horizontal control attached to a dynamic playlist. It's a container more than anything.
* This abstraction object manages the widgets for 1 dynamic playlist control, laid out in the desired layout
*/
class DynamicControlWidget : public QWidget
class DynamicControlWrapper : public QObject
{
Q_OBJECT
public:
explicit DynamicControlWidget( const dyncontrol_ptr& control, bool isLocal = false, QWidget* parent = 0);
virtual ~DynamicControlWidget();
explicit DynamicControlWrapper( const dyncontrol_ptr& control, QGridLayout* layout, int row, bool isLocal = false, QWidget* parent = 0 );
virtual ~DynamicControlWrapper();
virtual void paintEvent(QPaintEvent* );
virtual void enterEvent(QEvent* );
virtual void leaveEvent(QEvent* );
virtual void mouseMoveEvent(QMouseEvent* );
// virtual void enterEvent(QEvent* );
// virtual void leaveEvent(QEvent* );
dyncontrol_ptr control() const;
void removeFromLayout();
signals:
void collapse();
void removeControl();
@@ -63,7 +63,8 @@ private:
bool m_isLocal, m_mouseOver;
// i hate qlayout
QWidget* m_parent;
int m_row;
QStackedLayout* m_plusL;
QToolButton* m_minusButton;
@@ -71,7 +72,7 @@ private:
ReadOrWriteWidget* m_typeSelector;
ReadOrWriteWidget* m_matchSelector;
ReadOrWriteWidget* m_entryWidget;
QHBoxLayout* m_layout;
QGridLayout* m_layout;
};
};

View File

@@ -31,6 +31,7 @@
#include "pipeline.h"
#include "audio/audioengine.h"
#include "ReadOrWriteWidget.h"
#include "CollapsibleControls.h"
using namespace Tomahawk;
@@ -47,7 +48,6 @@ DynamicWidget::DynamicWidget( const Tomahawk::dynplaylist_ptr& playlist, QWidget
, m_logo( 0 )
, m_generateButton( 0 )
, m_controls( 0 )
, m_splitter( 0 )
, m_view( 0 )
, m_model()
{
@@ -81,25 +81,16 @@ DynamicWidget::DynamicWidget( const Tomahawk::dynplaylist_ptr& playlist, QWidget
m_layout->addLayout( m_headerLayout );
m_splitter = new AnimatedSplitter( this );
m_splitter->setOrientation( Qt::Vertical );
m_splitter->setChildrenCollapsible( false );
m_controls = new CollapsibleControls( this );
m_layout->addWidget( m_controls );
m_layout->addWidget( m_splitter );
m_controls = new DynamicControlList( m_splitter );
m_model = new PlaylistModel( this );
m_view = new PlaylistView( this );
m_view->setModel( m_model );
m_view->setContentsMargins( 0, 0, 0, 0 );
m_layout->addWidget( m_view );
m_splitter->addWidget( m_controls );
m_splitter->addWidget( m_view );
m_splitter->setGreedyWidget( 1 );
m_splitter->setHandleWidth( 0 );
m_splitter->setContentsMargins( 0, 0, 0, 0 );
m_splitter->show( 0, false );
loadDynamicPlaylist( playlist );
m_layout->setContentsMargins( 0, 0, 0, 0 );

View File

@@ -38,7 +38,8 @@ class ReadOrWriteWidget;
namespace Tomahawk
{
class DynamicControlList;
class CollapsibleControls;
/**
* This class contains the dynamic playlist config and the playlist view itself
@@ -90,8 +91,7 @@ private:
QPushButton* m_generateButton;
QSpinBox* m_genNumber;
DynamicControlList* m_controls;
AnimatedSplitter* m_splitter;
CollapsibleControls* m_controls;
PlaylistView* m_view;
PlaylistModel* m_model;