[vlc-devel] commit: Clean popup menu (Jean-Philippe Andre )

git version control git at videolan.org
Tue Jun 17 05:36:13 CEST 2008


vlc | branch: master | Jean-Philippe Andre <jpeg at via.ecp.fr> | Mon Jun 16 23:41:16 2008 +0200| [17365ad04c4fecd14bc904bd1e664a0d88159f91]

Clean popup menu

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/gui/qt4/menus.cpp |   84 +++++++++++++++++++++++++++-----------------
 1 files changed, 51 insertions(+), 33 deletions(-)

diff --git a/modules/gui/qt4/menus.cpp b/modules/gui/qt4/menus.cpp
index 34bd957..3152463 100644
--- a/modules/gui/qt4/menus.cpp
+++ b/modules/gui/qt4/menus.cpp
@@ -654,9 +654,11 @@ void QVLCMenu::PopupMenuControlEntries( QMenu *menu,
 
 void QVLCMenu::PopupMenuStaticEntries( intf_thread_t *p_intf, QMenu *menu )
 {
+#if 0
     QMenu *toolsmenu = ToolsMenu( p_intf, menu, false, true );
     toolsmenu->setTitle( qtr( "Tools" ) );
     menu->addMenu( toolsmenu );
+#endif
 
     QMenu *openmenu = new QMenu( qtr( "Open" ), menu );
     openmenu->addAction( qtr( "Open &File..." ), THEDP,
@@ -670,9 +672,11 @@ void QVLCMenu::PopupMenuStaticEntries( intf_thread_t *p_intf, QMenu *menu )
     menu->addMenu( openmenu );
 
     menu->addSeparator();
+#if 0
     QMenu *helpmenu = HelpMenu( menu );
     helpmenu->setTitle( qtr( "Help" ) );
     menu->addMenu( helpmenu );
+#endif
 
     addDPStaticEntry( menu, qtr( "Quit" ), "", "", SLOT( quit() ) , "Ctrl+Q" );
 }
@@ -748,43 +752,57 @@ void QVLCMenu::PopupMenu( intf_thread_t *p_intf, bool show )
 {
     if( show )
     {
-        // create a  popup if there is none
-        if( ! p_intf->p_sys->p_popup_menu )
+        /* Delete and recreate a popup if there is one */
+        if( p_intf->p_sys->p_popup_menu )
+            delete p_intf->p_sys->p_popup_menu;
+
+        QMenu *menu = new QMenu();
+        QMenu *submenu;
+        QAction *action;
+
+        POPUP_BOILERPLATE;
+
+        PopupMenuControlEntries( menu, p_intf, p_input );
+        menu->addSeparator();
+
+        if( p_input )
         {
-            POPUP_BOILERPLATE;
-            if( p_input )
-            {
-                vlc_object_yield( p_input );
-                InputAutoMenuBuilder( VLC_OBJECT( p_input ), objects, varnames );
-
-                /* Audio menu */
-                PUSH_SEPARATOR;
-                vlc_object_t *p_aout = ( vlc_object_t * )
-                    vlc_object_find( p_input, VLC_OBJECT_AOUT, FIND_ANYWHERE );
-                AudioAutoMenuBuilder( p_aout, p_input, objects, varnames );
-                if( p_aout )
-                    vlc_object_release( p_aout );
-
-                /* Video menu */
-                PUSH_SEPARATOR;
-                vlc_object_t *p_vout = ( vlc_object_t * )
-                    vlc_object_find( p_input, VLC_OBJECT_VOUT, FIND_CHILD );
-                VideoAutoMenuBuilder( p_vout, p_input, objects, varnames );
-                if( p_vout )
-                    vlc_object_release( p_vout );
-
-                vlc_object_release( p_input );
-            }
+            vlc_object_yield( p_input );
+            InputAutoMenuBuilder( VLC_OBJECT( p_input ), objects, varnames );
+
+            /* Audio menu */
+            vlc_object_t *p_aout = ( vlc_object_t * )
+                vlc_object_find( p_input, VLC_OBJECT_AOUT, FIND_ANYWHERE );
+            AudioAutoMenuBuilder( p_aout, p_input, objects, varnames );
+            if( p_aout )
+                vlc_object_release( p_aout );
+            submenu = Populate( p_intf, NULL, varnames, objects );
+            varnames.clear(); objects.clear();
+            action = menu->addMenu( submenu );
+            action->setText( qtr( "Audio" ) );
+            if( submenu->isEmpty() )
+                action->setEnabled( false );
 
-            QMenu *menu = new QMenu();
-            Populate( p_intf, menu, varnames, objects );
-            menu->addSeparator();
-            PopupMenuControlEntries( menu, p_intf, p_input );
-            menu->addSeparator();
-            PopupMenuStaticEntries( p_intf, menu );
+            /* Video menu */
+            vlc_object_t *p_vout = ( vlc_object_t * )
+                vlc_object_find( p_input, VLC_OBJECT_VOUT, FIND_CHILD );
+            VideoAutoMenuBuilder( p_vout, p_input, objects, varnames );
+            if( p_vout )
+                vlc_object_release( p_vout );
+            submenu = Populate( p_intf, NULL, varnames, objects );
+            varnames.clear(); objects.clear();
+            action = menu->addMenu( submenu );
+            action->setText( qtr( "Video" ) );
+            if( submenu->isEmpty() )
+                action->setEnabled( false );
 
-            p_intf->p_sys->p_popup_menu = menu;
+            vlc_object_release( p_input );
         }
+
+        menu->addSeparator();
+        PopupMenuStaticEntries( p_intf, menu );
+
+        p_intf->p_sys->p_popup_menu = menu;
         p_intf->p_sys->p_popup_menu->popup( QCursor::pos() );
     }
     else




More information about the vlc-devel mailing list