1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-11 16:44:05 +02:00

Let there be Automatic Playlists and Stations!

This commit is contained in:
Leo Franchi
2011-01-17 19:54:17 -05:00
parent 54dfd42b1c
commit eb3334abf5
5 changed files with 46 additions and 54 deletions

View File

@@ -43,7 +43,6 @@ DynamicWidget::DynamicWidget( const Tomahawk::dynplaylist_ptr& playlist, QWidget
, m_songsSinceLastResolved( 0 )
, m_headerText( 0 )
, m_headerLayout( 0 )
, m_modeCombo( 0 )
, m_generatorCombo( 0 )
, m_logo( 0 )
, m_generateButton( 0 )
@@ -55,13 +54,7 @@ DynamicWidget::DynamicWidget( const Tomahawk::dynplaylist_ptr& playlist, QWidget
m_headerLayout = new QHBoxLayout;
m_headerText = new QLabel( tr( "Type:" ), this );
m_headerLayout->addWidget( m_headerText );
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 );
QComboBox* gen = new QComboBox( this );
foreach( const QString& type, GeneratorFactory::types() )
gen->addItem( type );
@@ -134,13 +127,10 @@ void DynamicWidget::loadDynamicPlaylist(const Tomahawk::dynplaylist_ptr& playlis
if( !m_playlist.isNull() )
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 ) ) );
@@ -189,16 +179,6 @@ DynamicWidget::generateOrStart()
}
}
void
DynamicWidget::modeChanged( int mode )
{
qDebug() << Q_FUNC_INFO;
m_playlist->setMode( mode );
applyModeChange( mode );
controlsChanged();
}
void
DynamicWidget::applyModeChange( int mode )
{

View File

@@ -59,7 +59,6 @@ public slots:
private slots:
void generateOrStart();
void modeChanged(int);
void tracksGenerated( const QList< Tomahawk::query_ptr>& queries );
// used by on demand mode
@@ -86,7 +85,6 @@ private:
QLabel* m_headerText;
QHBoxLayout* m_headerLayout;
ReadOrWriteWidget* m_modeCombo;
ReadOrWriteWidget* m_generatorCombo;
QLabel* m_logo;
QPushButton* m_generateButton;

View File

@@ -166,7 +166,8 @@ TomahawkWindow::setupSignals()
connect( ui->actionRescanCollection, SIGNAL( triggered() ), SLOT( rescanCollectionManually() ) );
connect( ui->actionLoadXSPF, SIGNAL( triggered() ), SLOT( loadSpiff() ));
connect( ui->actionCreatePlaylist, SIGNAL( triggered() ), SLOT( createPlaylist() ));
connect( ui->actionCreateDynamicPlaylist, SIGNAL( triggered() ), SLOT( createDynamicPlaylist() ));
connect( ui->actionCreateAutomaticPlaylist, SIGNAL( triggered() ), SLOT( createAutomaticPlaylist() ));
connect( ui->actionCreate_New_Station, SIGNAL( triggered() ), SLOT( createStation() ));
connect( ui->actionAboutTomahawk, SIGNAL( triggered() ), SLOT( showAboutTomahawk() ) );
connect( ui->actionExit, SIGNAL( triggered() ), APP, SLOT( quit() ) );
connect( ui->statusButton, SIGNAL( clicked() ), APP->sipHandler(), SLOT( toggleConnect() ) );
@@ -315,37 +316,43 @@ TomahawkWindow::loadSpiff()
}
void
TomahawkWindow::createDynamicPlaylist()
TomahawkWindow::createAutomaticPlaylist()
{
createPlaylist( true );
bool ok;
QString name = QInputDialog::getText( this, "Create New Automatic Playlist", "Name:", QLineEdit::Normal, "New Automatic Playlist", &ok );
if ( !ok || name.isEmpty() )
return;
source_ptr author = SourceList::instance()->getLocal();
QString id = uuid();
QString info = ""; // FIXME
QString creator = "someone"; // FIXME
dynplaylist_ptr playlist = DynamicPlaylist::create( author, id, name, info, creator, false );
playlist->setMode( Static );
playlist->createNewRevision( uuid(), playlist->currentrevision(), playlist->type(), playlist->generator()->controls(), playlist->entries() );
}
void TomahawkWindow::createStation()
{
bool ok;
QString name = QInputDialog::getText( this, "Create New Station", "Name:", QLineEdit::Normal, "New Station", &ok );
if ( !ok || name.isEmpty() )
return;
source_ptr author = SourceList::instance()->getLocal();
QString id = uuid();
QString info = ""; // FIXME
QString creator = "someone"; // FIXME
dynplaylist_ptr playlist = DynamicPlaylist::create( author, id, name, info, creator, false );
playlist->setMode( OnDemand );
playlist->createNewRevision( uuid(), playlist->currentrevision(), playlist->type(), playlist->generator()->controls(), playlist->entries() );
}
void
TomahawkWindow::createPlaylist( bool dynamic )
TomahawkWindow::createPlaylist()
{
qDebug() << Q_FUNC_INFO;
if( dynamic )
{
bool ok;
QString name = QInputDialog::getText( this, "Create New Playlist", "Name:", QLineEdit::Normal, "New Playlist", &ok );
if ( !ok || name.isEmpty() )
return;
source_ptr author = SourceList::instance()->getLocal();
QString id = uuid();
QString info = ""; // FIXME
QString creator = "someone"; // FIXME
dynplaylist_ptr playlist = DynamicPlaylist::create( author, id, name, info, creator, false );
if( playlist->mode() == OnDemand )
playlist->createNewRevision( uuid(), playlist->currentrevision(), playlist->type(), playlist->generator()->controls() );
else
playlist->createNewRevision( uuid(), playlist->currentrevision(), playlist->type(), playlist->generator()->controls(), playlist->entries() );
} else
{
PlaylistManager::instance()->show( new NewPlaylistWidget() );
}
PlaylistManager::instance()->show( new NewPlaylistWidget() );
/* bool ok;
QString name = QInputDialog::getText( this, "Create New Playlist", "Name:", QLineEdit::Normal, "New Playlist", &ok );

View File

@@ -41,8 +41,9 @@ protected:
void closeEvent( QCloseEvent* e );
public slots:
void createDynamicPlaylist();
void createPlaylist( bool dynamic = false );
void createAutomaticPlaylist();
void createStation();
void createPlaylist();
void loadSpiff();
void showSettingsDialog();

View File

@@ -84,7 +84,8 @@
<string>&amp;Playlist</string>
</property>
<addaction name="actionCreatePlaylist"/>
<addaction name="actionCreateDynamicPlaylist"/>
<addaction name="actionCreateAutomaticPlaylist"/>
<addaction name="actionCreate_New_Station"/>
<addaction name="separator"/>
<addaction name="actionLoadXSPF"/>
</widget>
@@ -160,9 +161,14 @@
<enum>QAction::AboutRole</enum>
</property>
</action>
<action name="actionCreateDynamicPlaylist">
<action name="actionCreateAutomaticPlaylist">
<property name="text">
<string>Create New &amp;Dynamic Playlist</string>
<string>Create New &amp;Automatic Playlist</string>
</property>
</action>
<action name="actionCreate_New_Station">
<property name="text">
<string>Create New &amp;Station</string>
</property>
</action>
</widget>