[vlc-commits] Qt: fix playlist item menu play&pause actions

Jean-Baptiste Kempf git at videolan.org
Sun May 29 18:28:39 CEST 2016


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Sun May 29 18:27:58 2016 +0200| [ed9557147596aa43d6d8e510fcb523b60a90d44f] | committer: Jean-Baptiste Kempf

Qt: fix playlist item menu play&pause actions

Close #16893

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ed9557147596aa43d6d8e510fcb523b60a90d44f
---

 modules/gui/qt/components/playlist/playlist_model.cpp |   16 +++++++++++++++-
 modules/gui/qt/components/playlist/standardpanel.cpp  |    3 +++
 modules/gui/qt/components/playlist/vlc_model.hpp      |    1 +
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/modules/gui/qt/components/playlist/playlist_model.cpp b/modules/gui/qt/components/playlist/playlist_model.cpp
index e7c9286..d215603 100644
--- a/modules/gui/qt/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt/components/playlist/playlist_model.cpp
@@ -913,7 +913,18 @@ bool PLModel::action( QAction *action, const QModelIndexList &indexes )
     case ACTION_PLAY:
         if ( !indexes.empty() && indexes.first().isValid() )
         {
-            activateItem( indexes.first() );
+            if( isCurrent( indexes.first() ) )
+                playlist_Resume(THEPL);
+            else
+                activateItem( indexes.first() );
+            return true;
+        }
+        break;
+
+    case ACTION_PAUSE:
+        if ( !indexes.empty() && indexes.first().isValid() )
+        {
+            playlist_Pause(THEPL);
             return true;
         }
         break;
@@ -994,6 +1005,9 @@ bool PLModel::isSupportedAction( actions action, const QModelIndex &index ) cons
     case ACTION_SORT:
         return rowCount() && !item->readOnly();
     case ACTION_PLAY:
+        return !isCurrent( index ) || playlist_Status(THEPL) == PLAYLIST_PAUSED;
+    case ACTION_PAUSE:
+        return isCurrent( index ) && playlist_Status(THEPL) == PLAYLIST_RUNNING;
     case ACTION_STREAM:
     case ACTION_SAVE:
     case ACTION_INFO:
diff --git a/modules/gui/qt/components/playlist/standardpanel.cpp b/modules/gui/qt/components/playlist/standardpanel.cpp
index 4e6e609..4f04823 100644
--- a/modules/gui/qt/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt/components/playlist/standardpanel.cpp
@@ -189,6 +189,9 @@ bool StandardPLPanel::popup( const QPoint &point )
     ADD_MENU_ENTRY( QIcon( ":/menu/play" ), qtr(I_POP_PLAY),
                     VLCModelSubInterface::ACTION_PLAY )
 
+    ADD_MENU_ENTRY( QIcon( ":/menu/pause" ), qtr("Pause"),
+                    VLCModelSubInterface::ACTION_PAUSE )
+
     ADD_MENU_ENTRY( QIcon( ":/menu/stream" ), qtr(I_POP_STREAM),
                     VLCModelSubInterface::ACTION_STREAM )
 
diff --git a/modules/gui/qt/components/playlist/vlc_model.hpp b/modules/gui/qt/components/playlist/vlc_model.hpp
index 532cf39..b6f3f85 100644
--- a/modules/gui/qt/components/playlist/vlc_model.hpp
+++ b/modules/gui/qt/components/playlist/vlc_model.hpp
@@ -81,6 +81,7 @@ public:
     enum actions
     {
         ACTION_PLAY = 1,
+        ACTION_PAUSE,
         ACTION_STREAM,
         ACTION_SAVE,
         ACTION_INFO,



More information about the vlc-commits mailing list