[vlc-devel] [PATCH] Adding "save to playlist" menu item in submenu Recents.

Jean-Baptiste Kempf jb at videolan.org
Sun Oct 6 19:58:59 CEST 2013


On 02 Oct, bl3nder wrote :
> -    CONNECT( SDMapper, mapped (QString), this, SDMenuAction( QString ) );
> +    CONNECT( SDMapper, mapped (QString), this, SDMenuAction( QString ) ); 

No trailing spaces.

> -void DialogsProvider::saveAPlaylist()
> +void DialogsProvider::saveAPlaylist(playlist_t *p_playlist, playlist_item_t *p_node)
>  {
>      static const struct
>      {
> @@ -646,12 +646,24 @@ 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 );
>      }
>  }

OK.

> +void DialogsProvider::savePlayingToPlaylist()
> +{
> +	saveAPlaylist(THEPL, THEPL->p_playing);

No tabs!

> +}
> +
> +void DialogsProvider::saveRecentsToPlaylist()
> +{
> +	playlist_item_t *p_node_recents = RecentsMRL::getInstance(p_intf)->toPlaylist(0);
> +	saveAPlaylist(THEPL, p_node_recents);
> +	playlist_NodeDelete(THEPL, p_node_recents, true, false);
> +}

Idem

>  /****************************************************************************
>   * Sout emulation
>   ****************************************************************************/
> diff --git a/modules/gui/qt4/dialogs_provider.hpp b/modules/gui/qt4/dialogs_provider.hpp
> index ef23c4b..aa789be 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();  

No trailing spaces!

>              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..6388901 100755
> --- a/modules/gui/qt4/recents.cpp
> +++ b/modules/gui/qt4/recents.cpp
> @@ -149,3 +149,18 @@ 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);		

Can it 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;
> +}

Tabs, tabs everywhere!


> diff --git a/modules/gui/qt4/recents.hpp b/modules/gui/qt4/recents.hpp
> index 30bd7c9..29805a3 100644
> --- a/modules/gui/qt4/recents.hpp
> +++ b/modules/gui/qt4/recents.hpp
> @@ -52,9 +52,9 @@ public:
>  
>      void addRecent( const QString & );
>      QStringList recents();
> -
> +    playlist_item_t *toPlaylist(int length);
> +   

Trailing spaces

>      QSignalMapper *signalMapper;
> -

Why ?

-- 
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device



More information about the vlc-devel mailing list