]> git.sesse.net Git - vlc/commitdiff
Qt: fix navigation menu rebuilding
authorJean-Baptiste Kempf <jb@videolan.org>
Tue, 28 Feb 2012 02:37:42 +0000 (03:37 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Tue, 28 Feb 2012 02:37:42 +0000 (03:37 +0100)
Close #6219

modules/gui/qt4/menus.cpp
modules/gui/qt4/menus.hpp

index 44654a4e4f5f2d0a8a67698daf7dd6805a5341c1..8959a6a995fc420c1f210ba7919d45addaf7f775 100644 (file)
@@ -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();
index b880985e2d02c69e9b8deae616758aa1a309e3a4..3ccee3b9481037d85a6731543f1b759dc7b22165 100644 (file)
@@ -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)