mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
Add a Copy Link action and keep Export Playlist for static playlists
This commit is contained in:
@@ -190,6 +190,13 @@ SourceTreeView::setupMenus()
|
|||||||
m_playlistMenu.addSeparator();
|
m_playlistMenu.addSeparator();
|
||||||
|
|
||||||
QAction *copyPlaylistAction = m_playlistMenu.addAction( tr( "&Copy Link" ) );
|
QAction *copyPlaylistAction = m_playlistMenu.addAction( tr( "&Copy Link" ) );
|
||||||
|
|
||||||
|
if ( type == SourcesModel::StaticPlaylist )
|
||||||
|
{
|
||||||
|
QAction* exportPlaylist = m_playlistMenu.addAction( tr( "&Export Playlist") );
|
||||||
|
connect( exportPlaylist, SIGNAL( triggered() ), this, SLOT( exportPlaylist() ) );
|
||||||
|
}
|
||||||
|
|
||||||
QAction *deletePlaylistAction = m_playlistMenu.addAction( tr( "&Delete %1" ).arg( SourcesModel::rowTypeToString( type ) ) );
|
QAction *deletePlaylistAction = m_playlistMenu.addAction( tr( "&Delete %1" ).arg( SourcesModel::rowTypeToString( type ) ) );
|
||||||
|
|
||||||
QString addToText;
|
QString addToText;
|
||||||
@@ -227,9 +234,6 @@ SourceTreeView::setupMenus()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( type == SourcesModel::StaticPlaylist )
|
|
||||||
copyPlaylistAction->setText( tr( "&Copy Playlist Link" ) );
|
|
||||||
|
|
||||||
connect( loadPlaylistAction, SIGNAL( triggered() ), SLOT( loadPlaylist() ) );
|
connect( loadPlaylistAction, SIGNAL( triggered() ), SLOT( loadPlaylist() ) );
|
||||||
connect( renamePlaylistAction, SIGNAL( triggered() ), SLOT( renamePlaylist() ) );
|
connect( renamePlaylistAction, SIGNAL( triggered() ), SLOT( renamePlaylist() ) );
|
||||||
connect( deletePlaylistAction, SIGNAL( triggered() ), SLOT( deletePlaylist() ) );
|
connect( deletePlaylistAction, SIGNAL( triggered() ), SLOT( deletePlaylist() ) );
|
||||||
@@ -398,23 +402,37 @@ SourceTreeView::copyPlaylistLink()
|
|||||||
}
|
}
|
||||||
else if ( type == SourcesModel::StaticPlaylist )
|
else if ( type == SourcesModel::StaticPlaylist )
|
||||||
{
|
{
|
||||||
// Disable toma.hk playlist mode until ready
|
const PlaylistItem* item = itemFromIndex< PlaylistItem >( m_contextMenuIndex );
|
||||||
PlaylistItem* item = itemFromIndex< PlaylistItem >( m_contextMenuIndex );
|
const playlist_ptr playlist = item->playlist();
|
||||||
playlist_ptr playlist = item->playlist();
|
|
||||||
GlobalActionManager::instance()->getShortLink( playlist );
|
|
||||||
/*
|
|
||||||
PlaylistItem* item = itemFromIndex< PlaylistItem >( m_contextMenuIndex );
|
|
||||||
playlist_ptr playlist = item->playlist();
|
|
||||||
|
|
||||||
QString suggestedFilename = TomahawkSettings::instance()->playlistDefaultPath() + "/" + playlist->title();
|
GlobalActionManager::instance()->getShortLink( playlist );
|
||||||
QString filename = QFileDialog::getSaveFileName( TomahawkUtils::tomahawkWindow(), tr( "Save XSPF" ),
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SourceTreeView::exportPlaylist()
|
||||||
|
{
|
||||||
|
const QModelIndex idx = m_contextMenuIndex;
|
||||||
|
if ( !idx.isValid() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
const SourcesModel::RowType type = ( SourcesModel::RowType )model()->data( m_contextMenuIndex, SourcesModel::SourceTreeItemTypeRole ).toInt();
|
||||||
|
Q_ASSERT( type == SourcesModel::StaticPlaylist );
|
||||||
|
if ( type != SourcesModel::StaticPlaylist )
|
||||||
|
return;
|
||||||
|
|
||||||
|
const PlaylistItem* item = itemFromIndex< PlaylistItem >( m_contextMenuIndex );
|
||||||
|
const playlist_ptr playlist = item->playlist();
|
||||||
|
|
||||||
|
const QString suggestedFilename = TomahawkSettings::instance()->playlistDefaultPath() + "/" + playlist->title();
|
||||||
|
const QString filename = QFileDialog::getSaveFileName( TomahawkUtils::tomahawkWindow(), tr( "Save XSPF" ),
|
||||||
suggestedFilename, tr( "Playlists (*.xspf)" ) );
|
suggestedFilename, tr( "Playlists (*.xspf)" ) );
|
||||||
if ( !filename.isEmpty() )
|
if ( !filename.isEmpty() )
|
||||||
{
|
{
|
||||||
QFileInfo playlistAbsoluteFilePath = filename;
|
const QFileInfo playlistAbsoluteFilePath( filename );
|
||||||
TomahawkSettings::instance()->setPlaylistDefaultPath( playlistAbsoluteFilePath.absolutePath() );
|
TomahawkSettings::instance()->setPlaylistDefaultPath( playlistAbsoluteFilePath.absolutePath() );
|
||||||
GlobalActionManager::instance()->savePlaylistToFile( playlist, filename );
|
GlobalActionManager::instance()->savePlaylistToFile( playlist, filename );
|
||||||
} */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -72,6 +72,7 @@ private slots:
|
|||||||
void loadPlaylist();
|
void loadPlaylist();
|
||||||
void deletePlaylist( const QModelIndex& = QModelIndex() );
|
void deletePlaylist( const QModelIndex& = QModelIndex() );
|
||||||
void copyPlaylistLink();
|
void copyPlaylistLink();
|
||||||
|
void exportPlaylist();
|
||||||
void addToLocal();
|
void addToLocal();
|
||||||
|
|
||||||
void latchOnOrCatchUp();
|
void latchOnOrCatchUp();
|
||||||
|
Reference in New Issue
Block a user