Commit fd7e3ccc authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt: fix navigation menu rebuilding

Close #6219
parent 3f5029f8
...@@ -707,7 +707,6 @@ QMenu *VLCMenuBar::NavigMenu( intf_thread_t *p_intf, QMenu *menu ) ...@@ -707,7 +707,6 @@ QMenu *VLCMenuBar::NavigMenu( intf_thread_t *p_intf, QMenu *menu )
QMenu *VLCMenuBar::RebuildNavigMenu( intf_thread_t *p_intf, QMenu *menu, bool b_keep ) QMenu *VLCMenuBar::RebuildNavigMenu( intf_thread_t *p_intf, QMenu *menu, bool b_keep )
{ {
/* */ /* */
input_thread_t *p_object; input_thread_t *p_object;
QVector<vlc_object_t *> objects; QVector<vlc_object_t *> objects;
...@@ -724,20 +723,22 @@ QMenu *VLCMenuBar::RebuildNavigMenu( intf_thread_t *p_intf, QMenu *menu, bool b_ ...@@ -724,20 +723,22 @@ QMenu *VLCMenuBar::RebuildNavigMenu( intf_thread_t *p_intf, QMenu *menu, bool b_
PUSH_VAR( "prev-chapter" ); PUSH_VAR( "prev-chapter" );
PUSH_VAR( "next-chapter" ); PUSH_VAR( "next-chapter" );
/* */
EnableStaticEntries( menu, (p_object != NULL ) );
Populate( p_intf, menu, varnames, objects );
/* Remove playback actions to recreate them */ /* Remove playback actions to recreate them */
if( !b_keep ) if( !b_keep )
{ {
QList< QAction* > actions = menu->actions(); QList< QAction* > actions = menu->actions();
if( actions.count() > 4 ) for( int i = 0; i < actions.count(); i++ )
for( int i = actions.count() - 1 ; i >= actions.count() - 1 - 4 ; --i ) if( actions[i]->data().toInt() & ACTION_DELETE_ON_REBUILD )
delete actions[i]; delete actions[i];
} }
PopupMenuPlaylistEntries( menu, p_intf, p_object ); PopupMenuPlaylistEntries( menu, p_intf, p_object );
/* */ return menu;
EnableStaticEntries( menu, (p_object != NULL ) );
return Populate( p_intf, menu, varnames, objects );
} }
/** /**
...@@ -792,28 +793,30 @@ void VLCMenuBar::PopupMenuPlaylistEntries( QMenu *menu, ...@@ -792,28 +793,30 @@ void VLCMenuBar::PopupMenuPlaylistEntries( QMenu *menu,
} }
else else
{ {
addMIMStaticEntry( p_intf, menu, qtr( "Pause" ), action = addMIMStaticEntry( p_intf, menu, qtr( "Pause" ),
":/menu/pause", SLOT( togglePlayPause() ) ); ":/menu/pause", SLOT( togglePlayPause() ) );
} }
action->setData( ACTION_DELETE_ON_REBUILD );
/* Stop */ /* Stop */
action = addMIMStaticEntry( p_intf, menu, qtr( "&Stop" ), action = addMIMStaticEntry( p_intf, menu, qtr( "&Stop" ),
":/menu/stop", SLOT( stop() ), true ); ":/menu/stop", SLOT( stop() ), true );
if( !p_input ) if( !p_input )
action->setEnabled( false ); action->setEnabled( false );
action->setData( ACTION_DELETE_ON_REBUILD );
/* Next / Previous */ /* Next / Previous */
bool bPlaylistEmpty = THEMIM->hasEmptyPlaylist(); bool bPlaylistEmpty = THEMIM->hasEmptyPlaylist();
action = addMIMStaticEntry( p_intf, menu, qtr( "Pre&vious" ), action = addMIMStaticEntry( p_intf, menu, qtr( "Pre&vious" ),
":/menu/previous", SLOT( prev() ), true ); ":/menu/previous", SLOT( prev() ), true );
action->setEnabled( !bPlaylistEmpty ); action->setEnabled( !bPlaylistEmpty );
action->setData( ACTION_NO_CLEANUP ); action->setData( ACTION_NO_CLEANUP + ACTION_DELETE_ON_REBUILD );
CONNECT( THEMIM, playlistNotEmpty(bool), action, setEnabled(bool) ); CONNECT( THEMIM, playlistNotEmpty(bool), action, setEnabled(bool) );
action = addMIMStaticEntry( p_intf, menu, qtr( "Ne&xt" ), action = addMIMStaticEntry( p_intf, menu, qtr( "Ne&xt" ),
":/menu/next", SLOT( next() ), true ); ":/menu/next", SLOT( next() ), true );
action->setEnabled( !bPlaylistEmpty ); action->setEnabled( !bPlaylistEmpty );
action->setData( ACTION_NO_CLEANUP ); action->setData( ACTION_NO_CLEANUP + ACTION_DELETE_ON_REBUILD );
CONNECT( THEMIM, playlistNotEmpty(bool), action, setEnabled(bool) ); CONNECT( THEMIM, playlistNotEmpty(bool), action, setEnabled(bool) );
menu->addSeparator(); menu->addSeparator();
......
...@@ -94,7 +94,8 @@ public: ...@@ -94,7 +94,8 @@ public:
ACTION_ALWAYS_ENABLED = 0x1, ACTION_ALWAYS_ENABLED = 0x1,
ACTION_MANAGED = 0x2, /* managed using EnableStatic(bool)? */ ACTION_MANAGED = 0x2, /* managed using EnableStatic(bool)? */
ACTION_NO_CLEANUP = 0x4, ACTION_NO_CLEANUP = 0x4,
ACTION_STATIC = 0x6 /* legacy shortcut */ ACTION_STATIC = 0x6, /* legacy shortcut */
ACTION_DELETE_ON_REBUILD = 0x8
}; };
Q_DECLARE_FLAGS(actionflags, actionflag) Q_DECLARE_FLAGS(actionflags, actionflag)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment