mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 00:24:12 +02:00
Make read-onl denamic playlists only use QLabels not editable widgets
This commit is contained in:
@@ -98,6 +98,7 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
|
||||
dynamic/widgets/DynamicWidget.cpp
|
||||
dynamic/widgets/DynamicControlWidget.cpp
|
||||
dynamic/widgets/DynamicControlList.cpp
|
||||
dynamic/widgets/ReadOrWriteWidget.cpp
|
||||
|
||||
widgets/newplaylistwidget.cpp
|
||||
widgets/welcomewidget.cpp
|
||||
@@ -181,6 +182,7 @@ SET( tomahawkHeadersGui ${tomahawkHeadersGui}
|
||||
dynamic/widgets/DynamicWidget.h
|
||||
dynamic/widgets/DynamicControlWidget.h
|
||||
dynamic/widgets/DynamicControlList.h
|
||||
dynamic/widgets/ReadOrWriteWidget.h
|
||||
|
||||
widgets/newplaylistwidget.h
|
||||
widgets/welcomewidget.h
|
||||
|
@@ -36,20 +36,22 @@ DynamicControlList::DynamicControlList()
|
||||
|
||||
DynamicControlList::DynamicControlList( AnimatedSplitter* parent )
|
||||
: AnimatedWidget( parent )
|
||||
, m_isLocal( true )
|
||||
, m_layout( new QVBoxLayout )
|
||||
, m_summaryWidget( 0 )
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
DynamicControlList::DynamicControlList( const geninterface_ptr& generator, const QList< dyncontrol_ptr >& controls, AnimatedSplitter* parent)
|
||||
DynamicControlList::DynamicControlList( const geninterface_ptr& generator, const QList< dyncontrol_ptr >& controls, AnimatedSplitter* parent, bool isLocal )
|
||||
: AnimatedWidget(parent)
|
||||
, m_generator( generator )
|
||||
, m_isLocal( isLocal )
|
||||
, m_layout( new QVBoxLayout )
|
||||
, m_summaryWidget( 0 )
|
||||
{
|
||||
init();
|
||||
setControls( generator, controls );
|
||||
setControls( generator, controls, m_isLocal );
|
||||
}
|
||||
|
||||
DynamicControlList::~DynamicControlList()
|
||||
@@ -80,21 +82,22 @@ DynamicControlList::init()
|
||||
}
|
||||
|
||||
void
|
||||
DynamicControlList::setControls( const geninterface_ptr& generator, const QList< dyncontrol_ptr >& controls)
|
||||
DynamicControlList::setControls( const geninterface_ptr& generator, const QList< dyncontrol_ptr >& controls, bool isLocal )
|
||||
{
|
||||
if( !m_controls.isEmpty() ) {
|
||||
qDeleteAll( m_controls );
|
||||
m_controls.clear();
|
||||
}
|
||||
m_isLocal = isLocal;
|
||||
m_generator = generator;
|
||||
if( controls.isEmpty() ) {
|
||||
m_controls << new DynamicControlWidget( generator->createControl(), false, false, false, this );
|
||||
m_controls << new DynamicControlWidget( generator->createControl(), false, false, false, isLocal, this );
|
||||
connect( m_controls.last(), SIGNAL( addNewControl() ), this, SLOT( addNewControl() ) );
|
||||
connect( m_controls.last(), SIGNAL( removeControl() ), this, SLOT( removeControl() ) );
|
||||
} else
|
||||
{
|
||||
foreach( const dyncontrol_ptr& control, controls ) {
|
||||
m_controls << new DynamicControlWidget( control, false, false, false, this );
|
||||
m_controls << new DynamicControlWidget( control, false, false, false, isLocal, this );
|
||||
connect( m_controls.last(), SIGNAL( addNewControl() ), this, SLOT( addNewControl() ) );
|
||||
connect( m_controls.last(), SIGNAL( removeControl() ), this, SLOT( removeControl() ) );
|
||||
}
|
||||
@@ -143,7 +146,7 @@ void DynamicControlList::addNewControl()
|
||||
m_controls.last()->setShowPlusButton( false );
|
||||
m_controls.last()->setShowMinusButton( true );
|
||||
dyncontrol_ptr control = m_generator->createControl();
|
||||
m_controls.append( new DynamicControlWidget( control, true, false, true, this ) );
|
||||
m_controls.append( new DynamicControlWidget( control, true, false, true, m_isLocal, 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() ) );
|
||||
|
@@ -39,10 +39,10 @@ class DynamicControlList : public AnimatedWidget
|
||||
public:
|
||||
DynamicControlList(); // bad compiler!
|
||||
explicit DynamicControlList(AnimatedSplitter* parent );
|
||||
explicit DynamicControlList( const geninterface_ptr& generator, const QList< dyncontrol_ptr >& controls, AnimatedSplitter* parent );
|
||||
explicit DynamicControlList( const geninterface_ptr& generator, const QList< dyncontrol_ptr >& controls, AnimatedSplitter* parent, bool isLocal );
|
||||
virtual ~DynamicControlList();
|
||||
|
||||
void setControls( const geninterface_ptr& generator, const QList< dyncontrol_ptr >& controls );
|
||||
void setControls( const geninterface_ptr& generator, const QList< dyncontrol_ptr >& controls, bool isLocal );
|
||||
|
||||
virtual void paintEvent(QPaintEvent* );
|
||||
|
||||
@@ -59,7 +59,9 @@ public slots:
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
||||
geninterface_ptr m_generator;
|
||||
bool m_isLocal;
|
||||
|
||||
QVBoxLayout* m_layout;
|
||||
QList< DynamicControlWidget* > m_controls;
|
||||
|
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "tomahawk/tomahawkapp.h"
|
||||
#include "dynamic/DynamicControl.h"
|
||||
#include "dynamic/widgets/ReadOrWriteWidget.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QComboBox>
|
||||
@@ -29,41 +30,52 @@
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
DynamicControlWidget::DynamicControlWidget( const Tomahawk::dyncontrol_ptr& control, bool showPlus, bool showMinus, bool showCollapse, QWidget* parent )
|
||||
DynamicControlWidget::DynamicControlWidget( const Tomahawk::dyncontrol_ptr& control, bool showPlus, bool showMinus, bool showCollapse, bool isLocal, QWidget* parent )
|
||||
: QWidget(parent)
|
||||
, m_showPlus( showPlus )
|
||||
, m_showMinus( showMinus )
|
||||
, m_showCollapse( showCollapse )
|
||||
, m_isLocal( isLocal )
|
||||
, m_plusButton( 0 )
|
||||
, m_minusButton( 0 )
|
||||
, m_collapseButton( 0 )
|
||||
, m_control( control )
|
||||
, m_typeSelector( 0 )
|
||||
, m_matchSelector( 0 )
|
||||
, m_entryWidget( 0 )
|
||||
, m_layout( 0 )
|
||||
{
|
||||
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
|
||||
setMouseTracking( true );
|
||||
|
||||
m_layout = new QHBoxLayout;
|
||||
m_typeSelector = new QComboBox( this );
|
||||
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 );
|
||||
|
||||
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( 2 );
|
||||
if( m_isLocal )
|
||||
{
|
||||
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( 2 );
|
||||
}
|
||||
|
||||
m_collapseButton = initButton();
|
||||
m_collapseButton->setIcon( QIcon( RESPATH "images/arrow-up-double.png" ) );
|
||||
@@ -74,28 +86,32 @@ DynamicControlWidget::DynamicControlWidget( const Tomahawk::dyncontrol_ptr& cont
|
||||
m_collapseL->setCurrentIndex( 1 );
|
||||
|
||||
connect( m_collapseButton, SIGNAL( clicked( bool ) ), this, SIGNAL( collapse() ) );
|
||||
connect( m_typeSelector, SIGNAL( activated( QString) ), SLOT( typeSelectorChanged( QString ) ) );
|
||||
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 );
|
||||
|
||||
if( !control.isNull() ) {
|
||||
foreach( const QString& type, control->typeSelectors() )
|
||||
m_typeSelector->addItem( type );
|
||||
typeSelector->addItem( type );
|
||||
}
|
||||
|
||||
typeSelectorChanged( m_control.isNull() ? "" : m_control->selectedType(), true );
|
||||
|
||||
|
||||
m_layout->addLayout( m_collapseL, 0 );
|
||||
m_layout->addLayout( m_plusL, 0 );
|
||||
|
||||
if( m_isLocal )
|
||||
{
|
||||
m_layout->addLayout( m_plusL, 0 );
|
||||
|
||||
if( m_showPlus )
|
||||
m_plusL->setCurrentIndex( 0 );
|
||||
if( m_showMinus )
|
||||
m_plusL->setCurrentIndex( 1 );
|
||||
}
|
||||
|
||||
if( m_showCollapse )
|
||||
m_collapseL->setCurrentIndex( 0 );
|
||||
if( m_showPlus )
|
||||
m_plusL->setCurrentIndex( 0 );
|
||||
if( m_showMinus )
|
||||
m_plusL->setCurrentIndex( 1 );
|
||||
|
||||
setLayout( m_layout );
|
||||
}
|
||||
|
||||
@@ -141,19 +157,24 @@ void
|
||||
DynamicControlWidget::typeSelectorChanged( const QString& type, bool firstLoad )
|
||||
{
|
||||
Q_ASSERT( m_layout );
|
||||
m_layout->removeWidget( m_control->matchSelector() );
|
||||
m_layout->removeWidget( m_control->inputField() );
|
||||
m_layout->removeWidget( m_matchSelector );
|
||||
m_layout->removeWidget( m_entryWidget );
|
||||
|
||||
if( m_control->selectedType() == type && !firstLoad )
|
||||
m_control->setSelectedType( type );
|
||||
|
||||
m_typeSelector->setLabel( type );
|
||||
if( m_control->matchSelector() ) {
|
||||
m_layout->insertWidget( 1, m_control->matchSelector(), 0 );
|
||||
m_control->matchSelector()->show();
|
||||
m_matchSelector->setWritableWidget( m_control->matchSelector() );
|
||||
m_matchSelector->setLabel( m_control->match() );
|
||||
m_matchSelector->setWritable( m_isLocal );
|
||||
m_layout->insertWidget( 1, m_matchSelector, 0 );
|
||||
}
|
||||
if( m_control->inputField() ) {
|
||||
m_layout->insertWidget( 2, m_control->inputField(), 1 );
|
||||
m_control->inputField()->show();
|
||||
m_entryWidget->setWritableWidget( m_control->inputField() );
|
||||
m_entryWidget->setLabel( m_control->input() );
|
||||
m_entryWidget->setWritable( m_isLocal );
|
||||
m_layout->insertWidget( 2, m_entryWidget, 1 );
|
||||
}
|
||||
|
||||
emit changed();
|
||||
@@ -163,7 +184,7 @@ void
|
||||
DynamicControlWidget::setShowPlusButton(bool show)
|
||||
{
|
||||
|
||||
if( m_showPlus != show ) {
|
||||
if( m_showPlus != show && m_isLocal ) {
|
||||
show ? m_plusL->setCurrentIndex( 0 ) : m_plusL->setCurrentIndex( 2 );
|
||||
}
|
||||
|
||||
@@ -190,7 +211,7 @@ DynamicControlWidget::setShowMinusButton(bool show)
|
||||
void
|
||||
DynamicControlWidget::enterEvent(QEvent* ev)
|
||||
{
|
||||
if( m_showMinus )
|
||||
if( m_showMinus && m_isLocal )
|
||||
m_plusL->setCurrentIndex( 1 );
|
||||
|
||||
if( ev )
|
||||
@@ -200,7 +221,7 @@ DynamicControlWidget::enterEvent(QEvent* ev)
|
||||
void
|
||||
DynamicControlWidget::leaveEvent(QEvent* ev)
|
||||
{
|
||||
if( m_showMinus )
|
||||
if( m_showMinus && m_isLocal )
|
||||
m_plusL->setCurrentIndex( 2 );
|
||||
|
||||
if( ev )
|
||||
|
@@ -21,12 +21,13 @@
|
||||
|
||||
#include "typedefs.h"
|
||||
|
||||
class ReadOrWriteWidget;
|
||||
class QStackedLayout;
|
||||
class QEvent;
|
||||
class QToolButton;
|
||||
class QHBoxLayout;
|
||||
class QComboBox;
|
||||
class QLabel;
|
||||
class QLabel;;
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
@@ -38,7 +39,7 @@ class DynamicControlWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DynamicControlWidget( const dyncontrol_ptr& control, bool showPlus = false, bool showMinus = false, bool showCollapse = false, QWidget* parent = 0);
|
||||
explicit DynamicControlWidget( const dyncontrol_ptr& control, bool showPlus = false, bool showMinus = false, bool showCollapse = false, bool isLocal = false, QWidget* parent = 0);
|
||||
virtual ~DynamicControlWidget();
|
||||
|
||||
void setShowPlusButton( bool show );
|
||||
@@ -67,6 +68,8 @@ private:
|
||||
bool m_showPlus;
|
||||
bool m_showMinus;
|
||||
bool m_showCollapse;
|
||||
bool m_isLocal;
|
||||
|
||||
// i hate qlayout
|
||||
QStackedLayout* m_plusL;
|
||||
QToolButton* m_plusButton;
|
||||
@@ -75,7 +78,9 @@ private:
|
||||
QToolButton* m_collapseButton;
|
||||
|
||||
dyncontrol_ptr m_control;
|
||||
QComboBox* m_typeSelector;
|
||||
ReadOrWriteWidget* m_typeSelector;
|
||||
ReadOrWriteWidget* m_matchSelector;
|
||||
ReadOrWriteWidget* m_entryWidget;
|
||||
QHBoxLayout* m_layout;
|
||||
};
|
||||
|
||||
|
@@ -30,6 +30,7 @@
|
||||
#include "dynamic/GeneratorFactory.h"
|
||||
#include "pipeline.h"
|
||||
#include "audioengine.h"
|
||||
#include "ReadOrWriteWidget.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
@@ -54,16 +55,19 @@ DynamicWidget::DynamicWidget( const Tomahawk::dynplaylist_ptr& playlist, QWidget
|
||||
m_headerLayout = new QHBoxLayout;
|
||||
m_headerText = new QLabel( tr( "Type:" ), this );
|
||||
m_headerLayout->addWidget( m_headerText );
|
||||
m_modeCombo = new QComboBox( this );
|
||||
m_modeCombo->addItem( tr( "On Demand" ), OnDemand );
|
||||
m_modeCombo->addItem( tr( "Static" ), Static );
|
||||
connect( m_modeCombo, SIGNAL( activated( int ) ), this, SLOT( modeChanged( int ) ) );
|
||||
QComboBox* mode = new QComboBox( this );
|
||||
mode->addItem( tr( "On Demand" ), OnDemand );
|
||||
mode->addItem( tr( "Static" ), Static );
|
||||
connect( mode, SIGNAL( activated( int ) ), this, SLOT( modeChanged( int ) ) );
|
||||
m_modeCombo = new ReadOrWriteWidget( mode, playlist->author()->isLocal(), this );
|
||||
m_headerLayout->addWidget( m_modeCombo );
|
||||
|
||||
m_generatorCombo = new QComboBox( this );
|
||||
QComboBox* gen = new QComboBox( this );
|
||||
foreach( const QString& type, GeneratorFactory::types() )
|
||||
m_generatorCombo->addItem( type );
|
||||
gen->addItem( type );
|
||||
m_generatorCombo = new ReadOrWriteWidget( gen, playlist->author()->isLocal(), this );
|
||||
m_headerLayout->addWidget( m_generatorCombo );
|
||||
|
||||
m_generateButton = new QPushButton( tr( "Generate" ), this );
|
||||
connect( m_generateButton, SIGNAL( clicked( bool ) ), this, SLOT( generateOrStart() ) );
|
||||
m_headerLayout->addWidget( m_generateButton );
|
||||
@@ -125,9 +129,14 @@ void DynamicWidget::loadDynamicPlaylist(const Tomahawk::dynplaylist_ptr& playlis
|
||||
m_model->loadPlaylist( m_playlist );
|
||||
|
||||
if( !m_playlist.isNull() )
|
||||
m_controls->setControls( m_playlist->generator(), m_playlist->generator()->controls() );
|
||||
m_modeCombo->setCurrentIndex( static_cast<int>( playlist->mode() ) );
|
||||
m_controls->setControls( m_playlist->generator(), m_playlist->generator()->controls(), m_playlist->author()->isLocal() );
|
||||
qobject_cast<QComboBox*>( m_modeCombo->writableWidget() )->setCurrentIndex( static_cast<int>( playlist->mode() ) );
|
||||
|
||||
m_generatorCombo->setWritable( playlist->author()->isLocal() );
|
||||
m_generatorCombo->setLabel( qobject_cast< QComboBox* >( m_generatorCombo->writableWidget() )->currentText() );
|
||||
m_modeCombo->setWritable( playlist->author()->isLocal() );
|
||||
m_modeCombo->setLabel( qobject_cast< QComboBox* >( m_modeCombo->writableWidget() )->currentText() );
|
||||
|
||||
applyModeChange( m_playlist->mode() );
|
||||
connect( m_playlist->generator().data(), SIGNAL( generated( QList<Tomahawk::query_ptr> ) ), this, SLOT( tracksGenerated( QList<Tomahawk::query_ptr> ) ) );
|
||||
connect( m_playlist.data(), SIGNAL( dynamicRevisionLoaded( Tomahawk::DynamicPlaylistRevision ) ), this, SLOT( onRevisionLoaded( Tomahawk::DynamicPlaylistRevision ) ) );
|
||||
|
@@ -33,6 +33,7 @@ class PlaylistModel;
|
||||
class PlaylistView;
|
||||
class AnimatedSplitter;
|
||||
class QLabel;
|
||||
class ReadOrWriteWidget;
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
@@ -85,8 +86,8 @@ private:
|
||||
|
||||
QLabel* m_headerText;
|
||||
QHBoxLayout* m_headerLayout;
|
||||
QComboBox* m_modeCombo;
|
||||
QComboBox* m_generatorCombo;
|
||||
ReadOrWriteWidget* m_modeCombo;
|
||||
ReadOrWriteWidget* m_generatorCombo;
|
||||
QLabel* m_logo;
|
||||
QPushButton* m_generateButton;
|
||||
QSpinBox* m_genNumber;
|
||||
|
96
src/dynamic/widgets/ReadOrWriteWidget.cpp
Normal file
96
src/dynamic/widgets/ReadOrWriteWidget.cpp
Normal file
@@ -0,0 +1,96 @@
|
||||
/****************************************************************************************
|
||||
* Copyright (c) 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 "ReadOrWriteWidget.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QStackedLayout>
|
||||
#include <QDebug>
|
||||
|
||||
ReadOrWriteWidget::ReadOrWriteWidget( QWidget* writableWidget, bool writable, QWidget* parent)
|
||||
: QWidget( parent )
|
||||
, m_writableWidget( writableWidget )
|
||||
, m_label( 0 )
|
||||
, m_layout( 0 )
|
||||
, m_writable( writable )
|
||||
{
|
||||
m_label = new QLabel( QString(), this );
|
||||
|
||||
m_layout = new QStackedLayout( this );
|
||||
if( writableWidget )
|
||||
m_layout->addWidget( writableWidget );
|
||||
|
||||
m_layout->addWidget( m_label );
|
||||
|
||||
setWritable( m_writable );
|
||||
|
||||
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
|
||||
}
|
||||
|
||||
void
|
||||
ReadOrWriteWidget::setWritable( bool write )
|
||||
{
|
||||
m_writable = write;
|
||||
if( m_writableWidget && write )
|
||||
m_layout->setCurrentWidget( m_writableWidget );
|
||||
else
|
||||
m_layout->setCurrentWidget( m_label );
|
||||
}
|
||||
|
||||
void
|
||||
ReadOrWriteWidget::setWritableWidget( QWidget* w )
|
||||
{
|
||||
if( m_writableWidget ) {
|
||||
m_layout->removeWidget( m_writableWidget );
|
||||
}
|
||||
|
||||
m_writableWidget = w;
|
||||
m_layout->insertWidget( 0, m_writableWidget );
|
||||
}
|
||||
|
||||
bool
|
||||
ReadOrWriteWidget::writable() const
|
||||
{
|
||||
return m_writable;
|
||||
}
|
||||
|
||||
QWidget*
|
||||
ReadOrWriteWidget::writableWidget() const
|
||||
{
|
||||
return m_writableWidget;
|
||||
}
|
||||
|
||||
QString
|
||||
ReadOrWriteWidget::label() const
|
||||
{
|
||||
return m_label->text();
|
||||
}
|
||||
|
||||
void
|
||||
ReadOrWriteWidget::setLabel( const QString& label )
|
||||
{
|
||||
m_label->setText( label );
|
||||
}
|
||||
|
||||
QSize ReadOrWriteWidget::sizeHint() const
|
||||
{
|
||||
if( m_writableWidget ) {
|
||||
return m_writableWidget->sizeHint();
|
||||
} else {
|
||||
return m_label->sizeHint();
|
||||
}
|
||||
}
|
||||
|
54
src/dynamic/widgets/ReadOrWriteWidget.h
Normal file
54
src/dynamic/widgets/ReadOrWriteWidget.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/****************************************************************************************
|
||||
* Copyright (c) 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 READ_OR_WRITE_WIDGET_H
|
||||
#define READ_OR_WRITE_WIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QStackedLayout;
|
||||
class QLabel;
|
||||
|
||||
/**
|
||||
* Utility class for encapsulating either a QLabel (read-only) or an editable widget (combobox, lineedit, etc)
|
||||
*/
|
||||
|
||||
class ReadOrWriteWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ReadOrWriteWidget( QWidget* writableWidget, bool writable, QWidget* parent = 0 );
|
||||
|
||||
void setWritable( bool write );
|
||||
bool writable() const;
|
||||
|
||||
void setWritableWidget( QWidget* w );
|
||||
QWidget* writableWidget() const;
|
||||
|
||||
void setLabel( const QString& label );
|
||||
QString label() const;
|
||||
|
||||
virtual QSize sizeHint() const;
|
||||
|
||||
private:
|
||||
QWidget* m_writableWidget;
|
||||
QLabel* m_label;
|
||||
QStackedLayout* m_layout;
|
||||
|
||||
bool m_writable;
|
||||
};
|
||||
|
||||
#endif
|
@@ -85,7 +85,7 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
|
||||
}
|
||||
|
||||
Tomahawk::query_ptr query = Tomahawk::query_ptr( new Tomahawk::Query( t ) );
|
||||
t["score"] = 1.0;
|
||||
t.insert( "score", 1.0);
|
||||
|
||||
Tomahawk::result_ptr result = Tomahawk::result_ptr( new Tomahawk::Result( t, m_collection ) );
|
||||
result->setAttributes( attr );
|
||||
|
@@ -101,6 +101,7 @@ Tomahawk::EchonestControl::updateWidgets()
|
||||
|
||||
match->addItem( "Limit To", Echonest::DynamicPlaylist::ArtistType );
|
||||
match->addItem( "Similar To", Echonest::DynamicPlaylist::ArtistRadioType );
|
||||
m_matchString = match->itemText( 0 );
|
||||
|
||||
input->setPlaceholderText( "Artist name" );
|
||||
input->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Fixed );
|
||||
|
Reference in New Issue
Block a user