mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-11 11:32:22 +02:00
Add follow option to context menu, not quite working yet...
This commit is contained in:
parent
570913a3b9
commit
541fe95789
@ -37,6 +37,14 @@ Tomahawk::result_ptr
|
||||
SourcePlaylistInterface::siblingItem( int itemsAway )
|
||||
{
|
||||
Q_UNUSED( itemsAway );
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
Pipeline::instance()->resolve( m_source->currentTrack(), true );
|
||||
if ( m_source->currentTrack()->results().empty() )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << " Results were empty for current track";
|
||||
return Tomahawk::result_ptr();
|
||||
}
|
||||
|
||||
return m_source->currentTrack()->results().first();
|
||||
}
|
||||
|
||||
@ -44,6 +52,14 @@ SourcePlaylistInterface::siblingItem( int itemsAway )
|
||||
Tomahawk::result_ptr
|
||||
SourcePlaylistInterface::nextItem()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
Pipeline::instance()->resolve( m_source->currentTrack(), true );
|
||||
if ( m_source->currentTrack()->results().empty() )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << " Results were empty for current track";
|
||||
return Tomahawk::result_ptr();
|
||||
}
|
||||
|
||||
return m_source->currentTrack()->results().first();
|
||||
}
|
||||
|
||||
@ -58,5 +74,6 @@ SourcePlaylistInterface::tracks()
|
||||
void
|
||||
SourcePlaylistInterface::onSourcePlaybackStarted( const Tomahawk::query_ptr& query ) const
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
Pipeline::instance()->resolve( query, true );
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "sourcelist.h"
|
||||
#include "sourcetree/items/playlistitems.h"
|
||||
#include "sourcetree/items/collectionitem.h"
|
||||
#include "audio/audioengine.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
@ -125,7 +126,8 @@ SourceTreeView::setupMenus()
|
||||
{
|
||||
m_playlistMenu.clear();
|
||||
m_roPlaylistMenu.clear();
|
||||
|
||||
m_followMenu.clear();
|
||||
|
||||
bool readonly = true;
|
||||
SourcesModel::RowType type = ( SourcesModel::RowType )model()->data( m_contextMenuIndex, SourcesModel::SourceTreeItemTypeRole ).toInt();
|
||||
if ( type == SourcesModel::StaticPlaylist || type == SourcesModel::AutomaticPlaylist || type == SourcesModel::Station )
|
||||
@ -139,6 +141,8 @@ SourceTreeView::setupMenus()
|
||||
}
|
||||
}
|
||||
|
||||
m_followAction = m_followMenu.addAction( tr( "&Follow Music Stream" ) );
|
||||
|
||||
m_loadPlaylistAction = m_playlistMenu.addAction( tr( "&Load Playlist" ) );
|
||||
m_renamePlaylistAction = m_playlistMenu.addAction( tr( "&Rename Playlist" ) );
|
||||
m_playlistMenu.addSeparator();
|
||||
@ -168,7 +172,8 @@ SourceTreeView::setupMenus()
|
||||
connect( m_renamePlaylistAction, SIGNAL( triggered() ), SLOT( renamePlaylist() ) );
|
||||
connect( m_deletePlaylistAction, SIGNAL( triggered() ), SLOT( deletePlaylist() ) );
|
||||
connect( m_copyPlaylistAction, SIGNAL( triggered() ), SLOT( copyPlaylistLink() ) );
|
||||
connect( m_addToLocalAction, SIGNAL( triggered() ), SLOT( addToLocal() ) );
|
||||
connect( m_addToLocalAction, SIGNAL( triggered() ), SLOT( addToLocal() ) );
|
||||
connect( m_followAction, SIGNAL( triggered() ), SLOT( follow() ) );
|
||||
}
|
||||
|
||||
|
||||
@ -304,6 +309,24 @@ void SourceTreeView::addToLocal()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourceTreeView::follow()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
QModelIndex idx = m_contextMenuIndex;
|
||||
if ( !idx.isValid() )
|
||||
return;
|
||||
|
||||
SourcesModel::RowType type = ( SourcesModel::RowType )model()->data( m_contextMenuIndex, SourcesModel::SourceTreeItemTypeRole ).toInt();
|
||||
if( type == SourcesModel::Collection )
|
||||
{
|
||||
CollectionItem* item = itemFromIndex< CollectionItem >( m_contextMenuIndex );
|
||||
source_ptr source = item->source();
|
||||
AudioEngine::instance()->playItem( source->getPlaylistInterface().data(), source->getPlaylistInterface()->nextItem() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourceTreeView::renamePlaylist()
|
||||
{
|
||||
@ -335,6 +358,10 @@ SourceTreeView::onCustomContextMenu( const QPoint& pos )
|
||||
else
|
||||
m_roPlaylistMenu.exec( mapToGlobal( pos ) );
|
||||
}
|
||||
else if ( model()->data( m_contextMenuIndex, SourcesModel::SourceTreeItemTypeRole ) == SourcesModel::Collection )
|
||||
{
|
||||
m_followMenu.exec( mapToGlobal( pos ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,6 +56,8 @@ private slots:
|
||||
void copyPlaylistLink();
|
||||
void addToLocal();
|
||||
|
||||
void follow();
|
||||
|
||||
void onCustomContextMenu( const QPoint& pos );
|
||||
protected:
|
||||
// void drawBranches( QPainter* painter, const QRect& rect, const QModelIndex& index ) const {}
|
||||
@ -81,11 +83,13 @@ private:
|
||||
|
||||
QMenu m_playlistMenu;
|
||||
QMenu m_roPlaylistMenu;
|
||||
QMenu m_followMenu;
|
||||
QAction* m_loadPlaylistAction;
|
||||
QAction* m_renamePlaylistAction;
|
||||
QAction* m_deletePlaylistAction;
|
||||
QAction* m_copyPlaylistAction;
|
||||
QAction* m_addToLocalAction;
|
||||
QAction* m_followAction;
|
||||
|
||||
bool m_dragging;
|
||||
QRect m_dropRect;
|
||||
|
Loading…
x
Reference in New Issue
Block a user