[vlc-devel] [PATCH 5/6] qt: playlist: add Play and Add to Playlist action

Victorien Le Couviour--Tuffet victorien.lecouviour.tuffet at gmail.com
Tue Jul 25 18:00:42 CEST 2017


When right-clicking onto an item we either have "Play and Add to Playlist" or
"Play", depending on the place we are, respectively, the Playlist, or somewhere
else.
---
 modules/gui/qt/components/playlist/playlist_model.cpp | 5 ++++-
 modules/gui/qt/components/playlist/standardpanel.cpp  | 3 +++
 modules/gui/qt/components/playlist/vlc_model.hpp      | 3 ++-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/modules/gui/qt/components/playlist/playlist_model.cpp b/modules/gui/qt/components/playlist/playlist_model.cpp
index ebccf8ad76..eeda0e2dc7 100644
--- a/modules/gui/qt/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt/components/playlist/playlist_model.cpp
@@ -939,6 +939,7 @@ bool PLModel::action( QAction *action, const QModelIndexList &indexes )
     switch ( a.action )
     {
 
+    case ACTION_PLAYANDADDTOPLAYLIST:
     case ACTION_PLAY:
         if ( !indexes.empty() && indexes.first().isValid() )
         {
@@ -1030,9 +1031,11 @@ bool PLModel::isSupportedAction( actions action, const QModelIndex &index ) cons
         return getPLRootType() != ROOTTYPE_CURRENT_PLAYING;
     case ACTION_SORT:
         return rowCount();
+    case ACTION_PLAYANDADDTOPLAYLIST:
+        return item && item->parent()->id() != THEPL->p_playing->i_id;
     case ACTION_PLAY:
     {
-        if( !item )
+        if( !item || item->parent()->id() != THEPL->p_playing->i_id )
             return false;
 
         {
diff --git a/modules/gui/qt/components/playlist/standardpanel.cpp b/modules/gui/qt/components/playlist/standardpanel.cpp
index b6dd29fd2e..f27537a42f 100644
--- a/modules/gui/qt/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt/components/playlist/standardpanel.cpp
@@ -186,6 +186,9 @@ bool StandardPLPanel::popup( const QPoint &point )
 
     /* Play/Stream/Info static actions */
 
+    ADD_MENU_ENTRY( QIcon( ":/menu/play" ), qtr("Play and Add to Playlist"),
+                    VLCModelSubInterface::ACTION_PLAYANDADDTOPLAYLIST )
+
     ADD_MENU_ENTRY( QIcon( ":/menu/play" ), qtr(I_POP_PLAY),
                     VLCModelSubInterface::ACTION_PLAY )
 
diff --git a/modules/gui/qt/components/playlist/vlc_model.hpp b/modules/gui/qt/components/playlist/vlc_model.hpp
index d0d3a2821b..ea727eaca6 100644
--- a/modules/gui/qt/components/playlist/vlc_model.hpp
+++ b/modules/gui/qt/components/playlist/vlc_model.hpp
@@ -80,7 +80,8 @@ public:
     virtual QString getTitle( const QModelIndex &index ) const = 0;
     enum actions
     {
-        ACTION_PLAY = 1,
+        ACTION_PLAYANDADDTOPLAYLIST = 1,
+        ACTION_PLAY,
         ACTION_PAUSE,
         ACTION_STREAM,
         ACTION_SAVE,
-- 
2.13.1



More information about the vlc-devel mailing list