mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 07:49:42 +01:00
Adding export to Spotify
This commit is contained in:
parent
fe7b798cda
commit
e93ef1dd6e
@ -298,7 +298,6 @@ ScriptResolver::cmdExited( int code, QProcess::ExitStatus status )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ScriptResolver::resolve( const Tomahawk::query_ptr& query )
|
||||
{
|
||||
|
@ -59,6 +59,7 @@ signals:
|
||||
public slots:
|
||||
virtual void stop();
|
||||
virtual void resolve( const Tomahawk::query_ptr& query );
|
||||
|
||||
virtual void start();
|
||||
|
||||
private slots:
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <QStyledItemDelegate>
|
||||
#include <QSize>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "libtomahawk/pipeline.h"
|
||||
#include "playlist.h"
|
||||
#include "viewmanager.h"
|
||||
#include "sourcesproxymodel.h"
|
||||
@ -40,7 +40,7 @@
|
||||
#include "tomahawksettings.h"
|
||||
#include "globalactionmanager.h"
|
||||
#include "dropjob.h"
|
||||
|
||||
#include "resolversmodel.h"
|
||||
#include "utils/logger.h"
|
||||
#include "items/genericpageitems.h"
|
||||
#include "items/temporarypageitem.h"
|
||||
@ -160,6 +160,16 @@ SourceTreeView::setupMenus()
|
||||
m_copyPlaylistAction = m_playlistMenu.addAction( tr( "&Copy Link" ) );
|
||||
m_deletePlaylistAction = m_playlistMenu.addAction( tr( "&Delete %1" ).arg( SourcesModel::rowTypeToString( type ) ) );
|
||||
|
||||
// Add a menu for spotify export
|
||||
TomahawkSettings* settings = TomahawkSettings::instance();
|
||||
foreach(QString resolver, settings->enabledScriptResolvers() ){
|
||||
if( resolver.contains( "spotify" ) ){
|
||||
QAction *m_addToSpotify = m_playlistMenu.addAction( tr( "Add to &Spotify" ) );
|
||||
connect( m_addToSpotify, SIGNAL( triggered() ), SLOT( addToSpotify() ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QString addToText = QString( "Add to my %1" );
|
||||
if ( type == SourcesModel::StaticPlaylist )
|
||||
addToText = addToText.arg( "Playlists" );
|
||||
@ -242,6 +252,35 @@ SourceTreeView::loadPlaylist()
|
||||
onItemActivated( m_contextMenuIndex );
|
||||
}
|
||||
|
||||
void
|
||||
SourceTreeView::addToSpotify( )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
QModelIndex idx = m_contextMenuIndex;
|
||||
if ( !idx.isValid() )
|
||||
return;
|
||||
|
||||
SourcesModel::RowType type = ( SourcesModel::RowType )model()->data( idx, SourcesModel::SourceTreeItemTypeRole ).toInt();
|
||||
if ( type == SourcesModel::StaticPlaylist )
|
||||
{
|
||||
PlaylistItem* item = itemFromIndex< PlaylistItem >( idx );
|
||||
playlist_ptr playlist = item->playlist();
|
||||
qDebug() << Q_FUNC_INFO << "Static playlist" << playlist->title();
|
||||
qDebug() << Q_FUNC_INFO << playlist->tracks().first()->artist();
|
||||
|
||||
} else if( type == SourcesModel::AutomaticPlaylist || type == SourcesModel::Station )
|
||||
{
|
||||
DynamicPlaylistItem* item = itemFromIndex< DynamicPlaylistItem >( idx );
|
||||
dynplaylist_ptr playlist = item->dynPlaylist();
|
||||
qDebug() << Q_FUNC_INFO << "Dynamic playlist" << playlist->title();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
SourceTreeView::deletePlaylist( const QModelIndex& idxIn )
|
||||
|
@ -27,6 +27,7 @@ class PlaylistModel;
|
||||
class SourcesModel;
|
||||
class SourcesProxyModel;
|
||||
class SourceDelegate;
|
||||
class ResolversModel;
|
||||
|
||||
class SourceTreeView : public QTreeView
|
||||
{
|
||||
@ -53,6 +54,7 @@ private slots:
|
||||
void expandRequest( const QPersistentModelIndex& idx );
|
||||
|
||||
void loadPlaylist();
|
||||
void addToSpotify();
|
||||
void deletePlaylist( const QModelIndex& = QModelIndex() );
|
||||
void copyPlaylistLink();
|
||||
void addToLocal();
|
||||
@ -98,6 +100,7 @@ private:
|
||||
|
||||
bool m_dragging;
|
||||
QRect m_dropRect;
|
||||
ResolversModel* m_resolversModel;
|
||||
QPersistentModelIndex m_dropIndex;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user