[vlc-devel] [PATCH 16/18] gui/qt: fix #17184 (missing entries in context-menu)
Filip Roséen
filip at videolabs.io
Wed Jul 20 04:37:06 CEST 2016
This patch fixes the regression where certain entities on the
context-menu when dealing with the playlist are not displayed if you
right-click somewhere where there is no item:
- https://trac.videolan.org/vlc/ticket/17184
Actions that are not bound to a single entity are now displayed
correctly (vlc 2.2.4 has been used as reference), with two minor
differences:
* ACTION_PAUSE will now be shown if the current item is being
played, and;
* ACTION_PLAY will not show if the item is already playing.
refs #17184
---
.../gui/qt/components/playlist/playlist_model.cpp | 133 +++++++++++++--------
1 file changed, 85 insertions(+), 48 deletions(-)
diff --git a/modules/gui/qt/components/playlist/playlist_model.cpp b/modules/gui/qt/components/playlist/playlist_model.cpp
index 3f03209..11fc79b 100644
--- a/modules/gui/qt/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt/components/playlist/playlist_model.cpp
@@ -1001,57 +1001,94 @@ bool PLModel::action( QAction *action, const QModelIndexList &indexes )
bool PLModel::isSupportedAction( actions action, const QModelIndex &index ) const
{
- if( !index.isValid() )
- return false;
-
- const PLItem *item = getItem( index );
+ vlc_playlist_locker pl_lock ( THEPL );
+
+ bool const b_readonly = THEPL->p_root->i_flags & PLAYLIST_RO_FLAG;
+ AbstractPLItem * item = VLCModel::getItem( index );
- switch ( action )
+ switch( action )
{
- case ACTION_ADDTOPLAYLIST:
- /* Only if we are not already in Current Playing */
- if ( getPLRootType() == ROOTTYPE_CURRENT_PLAYING ) return false;
- if( index != rootIndex() )
- return ( item->id( PLAYLIST_ID ) != THEPL->p_playing->i_id );
- case ACTION_SORT:
- return rowCount() && !item->readOnly();
- case ACTION_PLAY:
- {
- PL_LOCK;
- bool b_ret = !isCurrent( index ) || playlist_Status(THEPL) == PLAYLIST_PAUSED;
- PL_UNLOCK;
- return b_ret;
- }
- case ACTION_PAUSE:
- {
- PL_LOCK;
- bool b_ret = isCurrent( index ) && playlist_Status(THEPL) == PLAYLIST_RUNNING;
- PL_UNLOCK;
- return b_ret;
- }
- case ACTION_STREAM:
- case ACTION_SAVE:
- case ACTION_INFO:
- return index != rootIndex();
- case ACTION_REMOVE:
- return index != rootIndex() && !item->readOnly();
- case ACTION_EXPLORE:
- return getURI( index ).startsWith( "file://" );
- case ACTION_CREATENODE:
- return ( isTree() && !item->readOnly() );
- case ACTION_RENAMENODE:
- return ( index != rootIndex() ) && !isLeaf( index ) && !item->readOnly();
- case ACTION_CLEAR:
- return rowCount() && !item->readOnly();
- case ACTION_ENQUEUEFILE:
- case ACTION_ENQUEUEDIR:
- case ACTION_ENQUEUEGENERIC:
- return !item->readOnly();
- case ACTION_SAVETOPLAYLIST:
- return rowCount() > 0;
- default:
- return false;
+ case ACTION_ADDTOPLAYLIST:
+ {
+ if( getPLRootType() == ROOTTYPE_CURRENT_PLAYING )
+ return false;
+
+ if( index == rootIndex() )
+ return false;
+
+ return item && item->id( PLAYLIST_ID ) != THEPL->p_playing->i_id;
+ }
+ case ACTION_SORT:
+ {
+ return rowCount() && b_readonly;
+ }
+ case ACTION_PLAY:
+ {
+ if( playlist_Status( THEPL ) == PLAYLIST_RUNNING )
+ {
+ if( isCurrent( index ) )
+ return false;
+ }
+
+ return index.isValid();;
+ }
+ case ACTION_PAUSE:
+ {
+ if( !isCurrent( index ) )
+ return false;
+
+ return playlist_Status( THEPL ) == PLAYLIST_RUNNING;
+ }
+ case ACTION_STREAM:
+ case ACTION_SAVE:
+ case ACTION_INFO:
+ {
+ return index != rootIndex();
+ }
+ case ACTION_REMOVE:
+ {
+ if( index == rootIndex() )
+ return false;
+
+ return item && !item->readOnly();
+ }
+ case ACTION_EXPLORE:
+ {
+ return getURI( index ).startsWith( "file:///" );
+ }
+ case ACTION_CREATENODE:
+ {
+ return isTree() && !b_readonly;
+ }
+ case ACTION_RENAMENODE:
+ {
+ if( index == rootIndex() || item == NULL )
+ return false;
+
+ input_item_t* p_iitem = item->inputItem();
+
+ if( p_iitem == NULL )
+ return false;
+
+ return p_iitem->i_type == ITEM_TYPE_NODE
+ || p_iitem->i_type == ITEM_TYPE_DIRECTORY;
+ }
+ case ACTION_CLEAR:
+ {
+ return rowCount() && !b_readonly;
+ }
+ case ACTION_ENQUEUEGENERIC:
+ case ACTION_ENQUEUEFILE:
+ case ACTION_ENQUEUEDIR:
+ {
+ return !b_readonly;
+ }
+ case ACTION_SAVETOPLAYLIST:
+ {
+ return rowCount();
+ }
}
+
return false;
}
--
2.9.0
More information about the vlc-devel
mailing list