mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-21 16:31:58 +02:00
ugly gui for basic functionality
This commit is contained in:
parent
4460f3ce60
commit
a1a01784ee
@ -20,3 +20,8 @@ void GeneratorFactory::registerFactory ( const QString& type, GeneratorFactoryIn
|
||||
{
|
||||
s_factories.insert( type, interface );
|
||||
}
|
||||
|
||||
QStringList GeneratorFactory::types()
|
||||
{
|
||||
return s_factories.keys();
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ class GeneratorFactory
|
||||
public:
|
||||
static geninterface_ptr create( const QString& type );
|
||||
static void registerFactory( const QString& type, GeneratorFactoryInterface* interface );
|
||||
static QStringList types();
|
||||
|
||||
private:
|
||||
static QHash<QString, GeneratorFactoryInterface*> s_factories;
|
||||
|
@ -61,6 +61,11 @@ Tomahawk::EchonestControl::toENParam() const
|
||||
void
|
||||
Tomahawk::EchonestControl::updateWidgets()
|
||||
{
|
||||
if( !m_input.isNull() )
|
||||
delete m_input.data();
|
||||
if( !m_match.isNull() )
|
||||
delete m_match.data();
|
||||
|
||||
// make sure the widgets are the proper kind for the selected type, and hook up to their slots
|
||||
if( selectedType() == "Artist" ) {
|
||||
QComboBox* match = new QComboBox();
|
||||
@ -75,6 +80,8 @@ Tomahawk::EchonestControl::updateWidgets()
|
||||
connect( match, SIGNAL( currentIndexChanged(int) ), this, SLOT( updateData() ) );
|
||||
connect( input, SIGNAL( textChanged(QString) ), this, SLOT( updateData() ) );
|
||||
|
||||
match->hide();
|
||||
input->hide();
|
||||
m_match = QWeakPointer< QWidget >( match );
|
||||
m_input = QWeakPointer< QWidget >( input );
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ DynamicControlWidget::DynamicControlWidget( const Tomahawk::dyncontrol_ptr& cont
|
||||
m_typeSelector = new QComboBox( this );
|
||||
|
||||
m_layout->setMargin( 0 );
|
||||
m_layout->setSpacing( 0 );
|
||||
setContentsMargins( 0, 0, 0, 0 );
|
||||
|
||||
m_plusButton= new QToolButton( this );
|
||||
@ -66,13 +67,12 @@ DynamicControlWidget::DynamicControlWidget( const Tomahawk::dyncontrol_ptr& cont
|
||||
|
||||
connect( m_typeSelector, SIGNAL( currentIndexChanged( QString ) ), SLOT( typeSelectorChanged( QString ) ) );
|
||||
|
||||
m_layout->addWidget( m_typeSelector, 0, Qt::AlignLeft );
|
||||
if( !control.isNull() ) {
|
||||
foreach( const QString& type, control->typeSelectors() )
|
||||
m_typeSelector->addItem( type );
|
||||
|
||||
m_layout->insertWidget( 0, m_typeSelector, 0, Qt::AlignLeft );
|
||||
m_layout->insertWidget( 1, m_control->matchSelector(), 0, Qt::AlignCenter );
|
||||
m_layout->insertWidget( 2, m_control->inputField(), 1, Qt::AlignAbsolute );
|
||||
typeSelectorChanged( m_control->selectedType() );
|
||||
}
|
||||
|
||||
if( m_showCollapse ) {
|
||||
@ -80,7 +80,7 @@ DynamicControlWidget::DynamicControlWidget( const Tomahawk::dyncontrol_ptr& cont
|
||||
m_plusButton->show();
|
||||
}
|
||||
if( m_showPlus ) {
|
||||
m_layout->insertWidget( 4, m_plusButton, 0, Qt::AlignRight );
|
||||
m_layout->insertWidget( m_showCollapse ? 4 : 3, m_plusButton, 0, Qt::AlignRight );
|
||||
m_plusButton->show();
|
||||
}
|
||||
|
||||
@ -97,15 +97,25 @@ DynamicControlWidget::typeSelectorChanged( QString type )
|
||||
{
|
||||
Q_ASSERT( m_layout );
|
||||
// remove the two widgets, change the control,and re-add the new ones
|
||||
if( m_layout->count() >= 4 )
|
||||
{
|
||||
m_layout->removeWidget( m_control->matchSelector() );
|
||||
m_layout->removeWidget( m_control->inputField() );
|
||||
|
||||
if( m_layout->indexOf( m_control->matchSelector() ) > -1 ) m_layout->removeWidget( m_control->matchSelector() );
|
||||
if( m_layout->indexOf( m_control->inputField() ) > -1 ) m_layout->removeWidget( m_control->inputField() );
|
||||
|
||||
m_control->setSelectedType( type );
|
||||
|
||||
if( m_control->matchSelector() ) {
|
||||
m_control->matchSelector()->show();
|
||||
m_layout->insertWidget( 1, m_control->matchSelector(), 0 );
|
||||
}
|
||||
if( m_control->inputField() ) {
|
||||
m_control->inputField()->show();
|
||||
m_layout->insertWidget( 2, m_control->inputField(), 1 );
|
||||
}
|
||||
|
||||
m_control->setSelectedType( type );
|
||||
m_layout->insertWidget( 1, m_control->matchSelector(), 0, Qt::AlignCenter );
|
||||
m_layout->insertWidget( 2, m_control->inputField(), 1, Qt::AlignAbsolute );
|
||||
qDebug() << m_layout->count();
|
||||
for( int i = 0; i < m_layout->count(); i++ ){
|
||||
qDebug() << i << ( m_layout->itemAt( i )->widget() ? m_layout->itemAt( i )->widget()->metaObject()->className() : "null" ) << m_layout->stretch( i ) << m_layout->itemAt( i )->sizeHint();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -114,7 +124,7 @@ DynamicControlWidget::setShowPlusButton(bool show)
|
||||
|
||||
if( m_showPlus != show ) {
|
||||
if( show ) {
|
||||
m_layout->insertWidget( m_layout->count() - 1, m_plusButton, 0, Qt::AlignRight );
|
||||
m_layout->insertWidget( m_showCollapse ? 4 : 3, m_plusButton, 0, Qt::AlignRight );
|
||||
m_plusButton->show();
|
||||
} else {
|
||||
m_layout->removeWidget( m_plusButton );
|
||||
@ -149,9 +159,7 @@ DynamicControlWidget::setShowCollapseButton(bool show)
|
||||
}
|
||||
|
||||
void
|
||||
DynamicControlWidget::paintEvent(QPaintEvent* e)
|
||||
DynamicControlWidget::paintEvent(QPaintEvent* )
|
||||
{
|
||||
QPainter p;
|
||||
p.fillRect( e->rect(), Qt::yellow );
|
||||
}
|
||||
|
||||
|
@ -24,28 +24,55 @@
|
||||
#include "playlistmodel.h"
|
||||
#include "trackproxymodel.h"
|
||||
#include "dynamic/GeneratorInterface.h"
|
||||
#include <QComboBox>
|
||||
#include "dynamic/GeneratorFactory.h"
|
||||
#include <QPushButton>
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
DynamicWidget::DynamicWidget( const Tomahawk::dynplaylist_ptr& playlist, QWidget* parent )
|
||||
: QWidget(parent)
|
||||
, m_header( 0 )
|
||||
, m_playlist( playlist )
|
||||
, m_layout( new QVBoxLayout )
|
||||
, m_headerText( 0 )
|
||||
, m_headerLayout( 0 )
|
||||
, m_modeCombo( 0 )
|
||||
, m_generatorCombo( 0 )
|
||||
, m_logo( 0 )
|
||||
, m_generateButton( 0 )
|
||||
, m_controls( 0 )
|
||||
, m_splitter( 0 )
|
||||
, m_view( 0 )
|
||||
, m_model()
|
||||
{
|
||||
setLayout( new QVBoxLayout );
|
||||
{
|
||||
m_headerLayout = new QHBoxLayout;
|
||||
m_headerText = new QLabel( "Dynamic Playlist Type:", this );
|
||||
m_headerLayout->addWidget( m_headerText );
|
||||
m_modeCombo = new QComboBox( this );
|
||||
m_modeCombo->addItem( "Static", 0 );
|
||||
m_modeCombo->addItem( "On Demand", 1 );
|
||||
m_headerLayout->addWidget( m_modeCombo );
|
||||
m_generatorCombo = new QComboBox( this );
|
||||
foreach( const QString& type, GeneratorFactory::types() )
|
||||
m_generatorCombo->addItem( type );
|
||||
m_headerLayout->addWidget( m_generatorCombo );
|
||||
|
||||
m_header = new QLabel( "TODO DYN PLAYLIST HEADER", this );
|
||||
layout()->addWidget( m_header );
|
||||
m_headerLayout->addSpacing( 1 );
|
||||
|
||||
m_generateButton = new QPushButton( this );
|
||||
m_generateButton->hide();
|
||||
if( playlist->mode() == Static ) {
|
||||
m_generateButton->show();
|
||||
m_headerLayout->addWidget( m_generateButton );
|
||||
}
|
||||
|
||||
m_layout->addLayout( m_headerLayout );
|
||||
|
||||
m_splitter = new AnimatedSplitter( this );
|
||||
m_splitter->setOrientation( Qt::Vertical );
|
||||
m_splitter->setChildrenCollapsible( false );
|
||||
|
||||
layout()->addWidget( m_splitter );
|
||||
m_layout->addWidget( m_splitter );
|
||||
m_controls = new DynamicControlList( m_splitter );
|
||||
m_model = new PlaylistModel( this );
|
||||
m_view = new PlaylistView( this );
|
||||
@ -63,6 +90,7 @@ DynamicWidget::DynamicWidget( const Tomahawk::dynplaylist_ptr& playlist, QWidget
|
||||
m_model->loadPlaylist( m_playlist );
|
||||
}
|
||||
|
||||
setLayout( m_layout );
|
||||
}
|
||||
|
||||
DynamicWidget::~DynamicWidget()
|
||||
|
@ -20,6 +20,10 @@
|
||||
#include <QWidget>
|
||||
#include <tomahawk/typedefs.h>
|
||||
|
||||
class QVBoxLayout;
|
||||
class QHBoxLayout;
|
||||
class QPushButton;
|
||||
class QComboBox;
|
||||
class PlaylistInterface;
|
||||
class PlaylistModel;
|
||||
class PlaylistView;
|
||||
@ -46,8 +50,15 @@ public:
|
||||
PlaylistInterface* playlistInterface() const;
|
||||
|
||||
private:
|
||||
QLabel* m_header;
|
||||
dynplaylist_ptr m_playlist;
|
||||
QVBoxLayout* m_layout;
|
||||
|
||||
QLabel* m_headerText;
|
||||
QHBoxLayout* m_headerLayout;
|
||||
QComboBox* m_modeCombo;
|
||||
QComboBox* m_generatorCombo;
|
||||
QLabel* m_logo;
|
||||
QPushButton* m_generateButton;
|
||||
|
||||
DynamicControlList* m_controls;
|
||||
AnimatedSplitter* m_splitter;
|
||||
|
Loading…
x
Reference in New Issue
Block a user