mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 22:26:32 +02:00
Add context menu item to create track links
This commit is contained in:
@@ -39,7 +39,6 @@ SET( tomahawkSources ${tomahawkSources}
|
|||||||
|
|
||||||
musicscanner.cpp
|
musicscanner.cpp
|
||||||
shortcuthandler.cpp
|
shortcuthandler.cpp
|
||||||
globalactionmanager.cpp
|
|
||||||
scanmanager.cpp
|
scanmanager.cpp
|
||||||
tomahawkapp.cpp
|
tomahawkapp.cpp
|
||||||
main.cpp
|
main.cpp
|
||||||
@@ -82,7 +81,6 @@ SET( tomahawkHeaders ${tomahawkHeaders}
|
|||||||
musicscanner.h
|
musicscanner.h
|
||||||
scanmanager.h
|
scanmanager.h
|
||||||
shortcuthandler.h
|
shortcuthandler.h
|
||||||
globalactionmanager.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
IF(LIBLASTFM_FOUND)
|
IF(LIBLASTFM_FOUND)
|
||||||
|
@@ -29,6 +29,7 @@ set( libSources
|
|||||||
source.cpp
|
source.cpp
|
||||||
viewpage.cpp
|
viewpage.cpp
|
||||||
viewmanager.cpp
|
viewmanager.cpp
|
||||||
|
globalactionmanager.cpp
|
||||||
|
|
||||||
sip/SipPlugin.cpp
|
sip/SipPlugin.cpp
|
||||||
sip/SipHandler.cpp
|
sip/SipHandler.cpp
|
||||||
@@ -183,6 +184,7 @@ set( libHeaders
|
|||||||
source.h
|
source.h
|
||||||
viewpage.h
|
viewpage.h
|
||||||
viewmanager.h
|
viewmanager.h
|
||||||
|
globalactionmanager.h
|
||||||
|
|
||||||
artist.h
|
artist.h
|
||||||
album.h
|
album.h
|
||||||
|
@@ -31,6 +31,8 @@
|
|||||||
|
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <Playlist.h>
|
#include <Playlist.h>
|
||||||
|
#include <qclipboard.h>
|
||||||
|
#include <qapplication.h>
|
||||||
|
|
||||||
GlobalActionManager* GlobalActionManager::s_instance = 0;
|
GlobalActionManager* GlobalActionManager::s_instance = 0;
|
||||||
|
|
||||||
@@ -53,6 +55,28 @@ GlobalActionManager::GlobalActionManager( QObject* parent )
|
|||||||
GlobalActionManager::~GlobalActionManager()
|
GlobalActionManager::~GlobalActionManager()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
QUrl
|
||||||
|
GlobalActionManager::openLinkFromQuery( const Tomahawk::query_ptr& query ) const
|
||||||
|
{
|
||||||
|
QUrl link( "tomahawk://open/track/" );
|
||||||
|
if( !query->track().isEmpty() )
|
||||||
|
link.addQueryItem( "title", query->track() );
|
||||||
|
if( !query->artist().isEmpty() )
|
||||||
|
link.addQueryItem( "artist", query->artist() );
|
||||||
|
if( !query->album().isEmpty() )
|
||||||
|
link.addQueryItem( "album", query->album() );
|
||||||
|
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
GlobalActionManager::copyToClipboard( const Tomahawk::query_ptr& query ) const
|
||||||
|
{
|
||||||
|
QClipboard* cb = QApplication::clipboard();
|
||||||
|
cb->setText( openLinkFromQuery( query ).toEncoded() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
GlobalActionManager::parseTomahawkLink( const QString& url )
|
GlobalActionManager::parseTomahawkLink( const QString& url )
|
||||||
{
|
{
|
@@ -21,17 +21,21 @@
|
|||||||
#define GLOBALACTIONMANAGER_H
|
#define GLOBALACTIONMANAGER_H
|
||||||
|
|
||||||
#include "playlist.h"
|
#include "playlist.h"
|
||||||
|
#include "dllmacro.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
class GlobalActionManager : public QObject
|
class DLLEXPORT GlobalActionManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static GlobalActionManager* instance();
|
static GlobalActionManager* instance();
|
||||||
virtual ~GlobalActionManager();
|
virtual ~GlobalActionManager();
|
||||||
|
|
||||||
|
QUrl openLinkFromQuery( const Tomahawk::query_ptr& query ) const;
|
||||||
|
void copyToClipboard( const Tomahawk::query_ptr& query ) const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
bool parseTomahawkLink( const QString& link );
|
bool parseTomahawkLink( const QString& link );
|
||||||
void waitingForResolved( bool );
|
void waitingForResolved( bool );
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -83,7 +83,10 @@ CollectionView::setupMenus()
|
|||||||
|
|
||||||
m_playItemAction = m_itemMenu.addAction( tr( "&Play" ) );
|
m_playItemAction = m_itemMenu.addAction( tr( "&Play" ) );
|
||||||
m_addItemsToQueueAction = m_itemMenu.addAction( tr( "Add to &Queue" ) );
|
m_addItemsToQueueAction = m_itemMenu.addAction( tr( "Add to &Queue" ) );
|
||||||
// m_itemMenu.addSeparator();
|
m_itemMenu.addSeparator();
|
||||||
|
|
||||||
|
foreach( QAction* a, actions() )
|
||||||
|
m_itemMenu.addAction( a );
|
||||||
// m_addItemsToPlaylistAction = m_itemMenu.addAction( tr( "&Add to Playlist" ) );
|
// m_addItemsToPlaylistAction = m_itemMenu.addAction( tr( "&Add to Playlist" ) );
|
||||||
|
|
||||||
connect( m_playItemAction, SIGNAL( triggered() ), SLOT( playItem() ) );
|
connect( m_playItemAction, SIGNAL( triggered() ), SLOT( playItem() ) );
|
||||||
|
@@ -30,6 +30,12 @@ using namespace Tomahawk;
|
|||||||
|
|
||||||
PlaylistView::PlaylistView( QWidget* parent )
|
PlaylistView::PlaylistView( QWidget* parent )
|
||||||
: TrackView( parent )
|
: TrackView( parent )
|
||||||
|
, m_model( 0 )
|
||||||
|
, m_itemMenu( 0 )
|
||||||
|
, m_playItemAction( 0 )
|
||||||
|
, m_addItemsToQueueAction( 0 )
|
||||||
|
, m_addItemsToPlaylistAction( 0 )
|
||||||
|
, m_deleteItemsAction( 0 )
|
||||||
{
|
{
|
||||||
setProxyModel( new PlaylistProxyModel( this ) );
|
setProxyModel( new PlaylistProxyModel( this ) );
|
||||||
|
|
||||||
@@ -84,6 +90,9 @@ PlaylistView::setupMenus()
|
|||||||
m_playItemAction = m_itemMenu.addAction( tr( "&Play" ) );
|
m_playItemAction = m_itemMenu.addAction( tr( "&Play" ) );
|
||||||
m_addItemsToQueueAction = m_itemMenu.addAction( tr( "Add to &Queue" ) );
|
m_addItemsToQueueAction = m_itemMenu.addAction( tr( "Add to &Queue" ) );
|
||||||
m_itemMenu.addSeparator();
|
m_itemMenu.addSeparator();
|
||||||
|
|
||||||
|
foreach( QAction* a, actions() )
|
||||||
|
m_itemMenu.addAction( a );
|
||||||
// m_addItemsToPlaylistAction = m_itemMenu.addAction( tr( "&Add to Playlist" ) );
|
// m_addItemsToPlaylistAction = m_itemMenu.addAction( tr( "&Add to Playlist" ) );
|
||||||
// m_itemMenu.addSeparator();
|
// m_itemMenu.addSeparator();
|
||||||
m_deleteItemsAction = m_itemMenu.addAction( i > 1 ? tr( "&Delete Items" ) : tr( "&Delete Item" ) );
|
m_deleteItemsAction = m_itemMenu.addAction( i > 1 ? tr( "&Delete Items" ) : tr( "&Delete Item" ) );
|
||||||
@@ -144,7 +153,6 @@ PlaylistView::deleteItems()
|
|||||||
proxyModel()->removeIndexes( selectedIndexes() );
|
proxyModel()->removeIndexes( selectedIndexes() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistView::onTrackCountChanged( unsigned int tracks )
|
PlaylistView::onTrackCountChanged( unsigned int tracks )
|
||||||
{
|
{
|
||||||
|
@@ -65,7 +65,6 @@ private slots:
|
|||||||
void deleteItems();
|
void deleteItems();
|
||||||
|
|
||||||
void onDeleted();
|
void onDeleted();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupMenus();
|
void setupMenus();
|
||||||
|
|
||||||
|
@@ -33,7 +33,8 @@
|
|||||||
#include "queueview.h"
|
#include "queueview.h"
|
||||||
#include "trackmodel.h"
|
#include "trackmodel.h"
|
||||||
#include "trackproxymodel.h"
|
#include "trackproxymodel.h"
|
||||||
#include <track.h>
|
#include "track.h"
|
||||||
|
#include "globalactionmanager.h"
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
@@ -77,6 +78,10 @@ TrackView::TrackView( QWidget* parent )
|
|||||||
setFont( f );
|
setFont( f );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
QAction* createLinkAction = new QAction( tr( "Copy track link" ), this );
|
||||||
|
connect( createLinkAction, SIGNAL( triggered( bool ) ), this, SLOT( copyLink() ) );
|
||||||
|
addAction( createLinkAction );
|
||||||
|
|
||||||
connect( this, SIGNAL( doubleClicked( QModelIndex ) ), SLOT( onItemActivated( QModelIndex ) ) );
|
connect( this, SIGNAL( doubleClicked( QModelIndex ) ), SLOT( onItemActivated( QModelIndex ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,7 +178,6 @@ TrackView::onItemResized( const QModelIndex& index )
|
|||||||
m_delegate->updateRowSize( index );
|
m_delegate->updateRowSize( index );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TrackView::playItem()
|
TrackView::playItem()
|
||||||
{
|
{
|
||||||
@@ -341,6 +345,16 @@ TrackView::onFilterChanged( const QString& )
|
|||||||
m_overlay->hide();
|
m_overlay->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TrackView::copyLink()
|
||||||
|
{
|
||||||
|
TrackModelItem* item = model()->itemFromIndex( proxyModel()->mapToSource( contextMenuIndex() ) );
|
||||||
|
if ( item && !item->query().isNull() )
|
||||||
|
{
|
||||||
|
GlobalActionManager::instance()->copyToClipboard( item->query() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TrackView::startDrag( Qt::DropActions supportedActions )
|
TrackView::startDrag( Qt::DropActions supportedActions )
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
|
||||||
|
class QAction;
|
||||||
class LoadingSpinner;
|
class LoadingSpinner;
|
||||||
class PlaylistInterface;
|
class PlaylistInterface;
|
||||||
class TrackHeader;
|
class TrackHeader;
|
||||||
@@ -80,6 +81,7 @@ private slots:
|
|||||||
|
|
||||||
void onFilterChanged( const QString& filter );
|
void onFilterChanged( const QString& filter );
|
||||||
|
|
||||||
|
void copyLink();
|
||||||
private:
|
private:
|
||||||
QString m_guid;
|
QString m_guid;
|
||||||
TrackModel* m_model;
|
TrackModel* m_model;
|
||||||
|
Reference in New Issue
Block a user