Commit 2dd0fa30 authored by Gal Vinograd's avatar Gal Vinograd Committed by Jean-Baptiste Kempf

Adding "save to playlist" menu item in submenu Recents.

adding RecentsMRL::toPlaylist()
refactoring functions to eliminate repeating code
refactoring public DialogProvider::saveAPlaylist() to private DialogProvider::saveAPlaylist(playlist_t *p_playlist, playlist_item_t *p_node)
and making new DialogProvider::savePlayingToPlaylist() and DialogProvider::saveRecentsToPlaylist()

this commit includes fixes related to Jean-Baptiste Kempf code review.
 - fixing whitespace problem
 - RecentsMRL::toPlaylist null handling
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 14cbf5d1
......@@ -580,7 +580,7 @@ void DialogsProvider::openAPlaylist()
}
}
void DialogsProvider::saveAPlaylist()
void DialogsProvider::saveAPlaylist(playlist_t *p_playlist, playlist_item_t *p_node)
{
static const struct
{
......@@ -646,12 +646,31 @@ void DialogsProvider::saveAPlaylist()
if ( psz_selected_module )
{
playlist_Export( THEPL, qtu( toNativeSeparators( file ) ),
THEPL->p_playing, psz_selected_module );
playlist_Export( p_playlist, qtu( toNativeSeparators( file ) ),
p_node, psz_selected_module );
getSettings()->setValue( "last-playlist-ext", psz_last_playlist_ext );
}
}
void DialogsProvider::savePlayingToPlaylist()
{
saveAPlaylist(THEPL, THEPL->p_playing);
}
void DialogsProvider::saveRecentsToPlaylist()
{
playlist_item_t *p_node_recents = RecentsMRL::getInstance(p_intf)->toPlaylist(0);
if (p_node_recents == NULL)
{
msg_Warn(p_intf, "cannot create playlist from recents");
return;
}
saveAPlaylist(THEPL, p_node_recents);
playlist_NodeDelete(THEPL, p_node_recents, true, false);
}
/****************************************************************************
* Sout emulation
****************************************************************************/
......
......@@ -111,6 +111,7 @@ private:
void openDialog( int );
void addFromSimple( bool, bool );
void saveAPlaylist(playlist_t *p_playlist, playlist_item_t *p_node);
public slots:
void playMRL( const QString & );
......@@ -161,7 +162,8 @@ public slots:
void openAndTranscodingDialogs();
void openAPlaylist();
void saveAPlaylist();
void savePlayingToPlaylist();
void saveRecentsToPlaylist();
void loadSubtitlesFile();
......
......@@ -374,7 +374,7 @@ QMenu *VLCMenuBar::FileMenu( intf_thread_t *p_intf, QWidget *parent, MainInterfa
}
menu->addSeparator();
addDPStaticEntry( menu, qtr( I_PL_SAVE ), "", SLOT( saveAPlaylist() ),
addDPStaticEntry( menu, qtr( I_PL_SAVE ), "", SLOT( savePlayingToPlaylist() ),
"Ctrl+Y" );
#ifdef ENABLE_SOUT
......@@ -1626,6 +1626,7 @@ void VLCMenuBar::updateRecents( intf_thread_t *p_intf )
recentsMenu->addSeparator();
recentsMenu->addAction( qtr("&Clear"), rmrl, SLOT( clear() ) );
addDPStaticEntry( recentsMenu, qtr("&Save To Playlist"), "", SLOT( saveRecentsToPlaylist() ), "" );
recentsMenu->setEnabled( true );
}
}
......
......@@ -149,3 +149,20 @@ void RecentsMRL::save()
getSettings()->setValue( "RecentsMRL/list", *stack );
}
playlist_item_t *RecentsMRL::toPlaylist(int length)
{
playlist_item_t *p_node_recent = playlist_NodeCreate(THEPL, _("Recently Played"), THEPL->p_root, PLAYLIST_END, PLAYLIST_RO_FLAG, NULL);
if ( p_node_recent == NULL ) return NULL;
if (length == 0 || stack->count() < length)
length = stack->count();
for (int i = 0; i < length; i++)
{
input_item_t *p_input = input_item_New(qtu(stack->at(i)), NULL);
playlist_NodeAddInput(THEPL, p_input, p_node_recent, PLAYLIST_APPEND, PLAYLIST_END, false);
}
return p_node_recent;
}
......@@ -52,7 +52,7 @@ public:
void addRecent( const QString & );
QStringList recents();
playlist_item_t *toPlaylist(int length);
QSignalMapper *signalMapper;
private:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment