[vlc-commits] Qt: fix navigation menu rebuilding

Jean-Baptiste Kempf git at videolan.org
Tue Feb 28 03:38:23 CET 2012


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Tue Feb 28 03:37:42 2012 +0100| [fd7e3ccc211703d018d454625a37a1ca662b7b15] | committer: Jean-Baptiste Kempf

Qt: fix navigation menu rebuilding

Close #6219

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

 modules/gui/qt4/menus.cpp |   21 ++++++++++++---------
 modules/gui/qt4/menus.hpp |    3 ++-
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/modules/gui/qt4/menus.cpp b/modules/gui/qt4/menus.cpp
index 44654a4..8959a6a 100644
--- a/modules/gui/qt4/menus.cpp
+++ b/modules/gui/qt4/menus.cpp
@@ -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();
diff --git a/modules/gui/qt4/menus.hpp b/modules/gui/qt4/menus.hpp
index b880985..3ccee3b 100644
--- a/modules/gui/qt4/menus.hpp
+++ b/modules/gui/qt4/menus.hpp
@@ -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)
 



More information about the vlc-commits mailing list