[vlc-commits] Adding "save to playlist" menu item in submenu Recents.
Gal Vinograd
git at videolan.org
Sat Oct 12 23:51:48 CEST 2013
vlc | branch: master | Gal Vinograd <bl3nderb at aol.com> | Sat Oct 12 23:24:18 2013 +0200| [2dd0fa30e2b614bd22c74a70eb5e991b36b9cf38] | committer: 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: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2dd0fa30e2b614bd22c74a70eb5e991b36b9cf38
---
modules/gui/qt4/dialogs_provider.cpp | 25 ++++++++++++++++++++++---
modules/gui/qt4/dialogs_provider.hpp | 4 +++-
modules/gui/qt4/menus.cpp | 3 ++-
modules/gui/qt4/recents.cpp | 17 +++++++++++++++++
modules/gui/qt4/recents.hpp | 2 +-
5 files changed, 45 insertions(+), 6 deletions(-)
diff --git a/modules/gui/qt4/dialogs_provider.cpp b/modules/gui/qt4/dialogs_provider.cpp
index 524f476..cc68160 100644
--- a/modules/gui/qt4/dialogs_provider.cpp
+++ b/modules/gui/qt4/dialogs_provider.cpp
@@ -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
****************************************************************************/
diff --git a/modules/gui/qt4/dialogs_provider.hpp b/modules/gui/qt4/dialogs_provider.hpp
index ef23c4b..00bd37c 100644
--- a/modules/gui/qt4/dialogs_provider.hpp
+++ b/modules/gui/qt4/dialogs_provider.hpp
@@ -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();
diff --git a/modules/gui/qt4/menus.cpp b/modules/gui/qt4/menus.cpp
index 59804ea..688306f 100644
--- a/modules/gui/qt4/menus.cpp
+++ b/modules/gui/qt4/menus.cpp
@@ -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 );
}
}
diff --git a/modules/gui/qt4/recents.cpp b/modules/gui/qt4/recents.cpp
index 75839e8..316b6ee 100755
--- a/modules/gui/qt4/recents.cpp
+++ b/modules/gui/qt4/recents.cpp
@@ -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;
+}
diff --git a/modules/gui/qt4/recents.hpp b/modules/gui/qt4/recents.hpp
index 30bd7c9..ebcf747 100644
--- a/modules/gui/qt4/recents.hpp
+++ b/modules/gui/qt4/recents.hpp
@@ -52,7 +52,7 @@ public:
void addRecent( const QString & );
QStringList recents();
-
+ playlist_item_t *toPlaylist(int length);
QSignalMapper *signalMapper;
private:
More information about the vlc-commits
mailing list