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 )
QMenu *VLCMenuBar::RebuildNavigMenu( intf_thread_t *p_intf, QMenu *menu, bool b_keep )
{
/* */
input_thread_t *p_object;
QVector<vlc_object_t *> objects;
......@@ -724,20 +723,22 @@ QMenu *VLCMenuBar::RebuildNavigMenu( intf_thread_t *p_intf, QMenu *menu, bool b_
PUSH_VAR( "prev-chapter" );
PUSH_VAR( "next-chapter" );
/* */
EnableStaticEntries( menu, (p_object != NULL ) );
Populate( p_intf, menu, varnames, objects );
/* Remove playback actions to recreate them */
if( !b_keep )
{
QList< QAction* > actions = menu->actions();
if( actions.count() > 4 )
for( int i = actions.count() - 1 ; i >= actions.count() - 1 - 4 ; --i )
for( int i = 0; i < actions.count(); i++ )
if( actions[i]->data().toInt() & ACTION_DELETE_ON_REBUILD )
delete actions[i];
}
PopupMenuPlaylistEntries( menu, p_intf, p_object );
/* */
EnableStaticEntries( menu, (p_object != NULL ) );
return Populate( p_intf, menu, varnames, objects );
return menu;
}
/**
......@@ -792,28 +793,30 @@ void VLCMenuBar::PopupMenuPlaylistEntries( QMenu *menu,
}
else
{
addMIMStaticEntry( p_intf, menu, qtr( "Pause" ),
action = addMIMStaticEntry( p_intf, menu, qtr( "Pause" ),
":/menu/pause", SLOT( togglePlayPause() ) );
}
action->setData( ACTION_DELETE_ON_REBUILD );
/* Stop */
action = addMIMStaticEntry( p_intf, menu, qtr( "&Stop" ),
":/menu/stop", SLOT( stop() ), true );
if( !p_input )
action->setEnabled( false );
action->setData( ACTION_DELETE_ON_REBUILD );
/* Next / Previous */
bool bPlaylistEmpty = THEMIM->hasEmptyPlaylist();
action = addMIMStaticEntry( p_intf, menu, qtr( "Pre&vious" ),
":/menu/previous", SLOT( prev() ), true );
action->setEnabled( !bPlaylistEmpty );
action->setData( ACTION_NO_CLEANUP );
action->setData( ACTION_NO_CLEANUP + ACTION_DELETE_ON_REBUILD );
CONNECT( THEMIM, playlistNotEmpty(bool), action, setEnabled(bool) );
action = addMIMStaticEntry( p_intf, menu, qtr( "Ne&xt" ),
":/menu/next", SLOT( next() ), true );
action->setEnabled( !bPlaylistEmpty );
action->setData( ACTION_NO_CLEANUP );
action->setData( ACTION_NO_CLEANUP + ACTION_DELETE_ON_REBUILD );
CONNECT( THEMIM, playlistNotEmpty(bool), action, setEnabled(bool) );
menu->addSeparator();
......
......@@ -94,7 +94,8 @@ public:
ACTION_ALWAYS_ENABLED = 0x1,
ACTION_MANAGED = 0x2, /* managed using EnableStatic(bool)? */
ACTION_NO_CLEANUP = 0x4,
ACTION_STATIC = 0x6 /* legacy shortcut */
ACTION_STATIC = 0x6, /* legacy shortcut */
ACTION_DELETE_ON_REBUILD = 0x8
};
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