]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/menus.cpp
qt4: metaChanged -> currentMetaChanged
[vlc] / modules / gui / qt4 / menus.cpp
index 8863a4d68719d841ebeda810e9c623a05a9d6e3d..948fcee36168ce71f06147c14cc69165ee5a2656 100644 (file)
@@ -64,6 +64,9 @@
   Just before one of those menus are aboutToShow(), they are rebuild.
   */
 
+#define STATIC_ENTRY "__static__"
+#define ENTRY_ALWAYS_ENABLED "__ignore__"
+
 enum
 {
     ITEM_NORMAL,
@@ -87,9 +90,9 @@ void addDPStaticEntry( QMenu *menu,
                        const char *shortcut = NULL )
 {
     QAction *action = NULL;
-    if( !EMPTY_STR( icon ) > 0 )
+    if( !EMPTY_STR( icon ) )
     {
-        if( !EMPTY_STR( shortcut ) > 0 )
+        if( !EMPTY_STR( shortcut ) )
             action = menu->addAction( QIcon( icon ), text, THEDP,
                                       member, qtr( shortcut ) );
         else
@@ -97,22 +100,23 @@ void addDPStaticEntry( QMenu *menu,
     }
     else
     {
-        if( !EMPTY_STR( shortcut ) > 0 )
+        if( !EMPTY_STR( shortcut ) )
             action = menu->addAction( text, THEDP, member, qtr( shortcut ) );
         else
             action = menu->addAction( text, THEDP, member );
     }
-    action->setData( true );
+    action->setData( STATIC_ENTRY );
 }
 
 /***
  * Same for MIM
  ***/
-void addMIMStaticEntry( intf_thread_t *p_intf,
-                        QMenu *menu,
-                        const QString text,
-                        const char *icon,
-                        const char *member )
+QAction* addMIMStaticEntry( intf_thread_t *p_intf,
+                            QMenu *menu,
+                            const QString text,
+                            const char *icon,
+                            const char *member,
+                            bool bStatic = false )
 {
     QAction *action;
     if( strlen( icon ) > 0 )
@@ -122,9 +126,10 @@ void addMIMStaticEntry( intf_thread_t *p_intf,
     }
     else
     {
-        menu->addAction( text, THEMIM, member );
+        action = menu->addAction( text, THEMIM, member );
     }
-    action->setData( "ignore" );
+    action->setData( bStatic ? STATIC_ENTRY : ENTRY_ALWAYS_ENABLED );
+    return action;
 }
 
 /**
@@ -138,9 +143,10 @@ void EnableStaticEntries( QMenu *menu, bool enable = true )
     QList< QAction* > actions = menu->actions();
     for( int i = 0; i < actions.size(); ++i )
     {
-        actions[i]->setEnabled( actions[i]->data().toString() == "ignore" ||
-                /* Be careful here, because data("string").toBool is true */
-                ( enable && (actions[i]->data().toString() == "true" ) ) );
+        actions[i]->setEnabled( actions[i]->data().toString()
+                                == ENTRY_ALWAYS_ENABLED ||
+            /* Be careful here, because data("string").toBool is true */
+            ( enable && (actions[i]->data().toString() == STATIC_ENTRY ) ) );
     }
 }
 
@@ -156,7 +162,7 @@ int DeleteNonStaticEntries( QMenu *menu )
     QList< QAction* > actions = menu->actions();
     for( int i = 0; i < actions.size(); ++i )
     {
-        if( !actions[i]->data().toBool() )
+        if( actions[i]->data().toString() != STATIC_ENTRY )
             delete actions[i];
         else
             i_ret++;
@@ -496,13 +502,13 @@ QMenu *QVLCMenu::AudioMenu( intf_thread_t *p_intf, QMenu * current )
 
         QAction *action = current->addAction( qtr( "Increase Volume" ),
                 ActionsManager::getInstance( p_intf ), SLOT( AudioUp() ) );
-        action->setData( true );
+        action->setData( STATIC_ENTRY );
         action = current->addAction( qtr( "Decrease Volume" ),
                 ActionsManager::getInstance( p_intf ), SLOT( AudioDown() ) );
-        action->setData( true );
+        action->setData( STATIC_ENTRY );
         action = current->addAction( qtr( "Mute" ),
                 ActionsManager::getInstance( p_intf ), SLOT( toggleMuteAudio() ) );
-        action->setData( true );
+        action->setData( STATIC_ENTRY );
     }
 
     p_input = THEMIM->getInput();
@@ -603,7 +609,8 @@ QMenu *QVLCMenu::NavigMenu( intf_thread_t *p_intf, QMenu *menu )
     PopupMenuPlaylistControlEntries( menu, p_intf );
     PopupMenuControlEntries( menu, p_intf );
 
-    return menu;
+    EnableStaticEntries( menu, ( THEMIM->getInput() != NULL ) );
+    return RebuildNavigMenu( p_intf, menu );
 }
 
 QMenu *QVLCMenu::RebuildNavigMenu( intf_thread_t *p_intf, QMenu *menu )
@@ -737,36 +744,36 @@ void QVLCMenu::PopupMenuControlEntries( QMenu *menu, intf_thread_t *p_intf )
     action = menu->addAction( qtr( "&Faster" ), THEMIM->getIM(),
                               SLOT( faster() ) );
     action->setIcon( QIcon( ":/faster") );
-    action->setData( true );
+    action->setData( STATIC_ENTRY );
 
     action = menu->addAction( qtr( "Faster (fine)" ), THEMIM->getIM(),
                               SLOT( littlefaster() ) );
-    action->setData( true );
+    action->setData( STATIC_ENTRY );
 
     action = menu->addAction( qtr( "N&ormal Speed" ), THEMIM->getIM(),
                               SLOT( normalRate() ) );
-    action->setData( true );
+    action->setData( STATIC_ENTRY );
 
     action = menu->addAction( qtr( "Slower (fine)" ), THEMIM->getIM(),
                               SLOT( littleslower() ) );
-    action->setData( true );
+    action->setData( STATIC_ENTRY );
 
     action = menu->addAction( qtr( "Slo&wer" ), THEMIM->getIM(),
                               SLOT( slower() ) );
     action->setIcon( QIcon( ":/slower") );
-    action->setData( true );
+    action->setData( STATIC_ENTRY );
 
     menu->addSeparator();
 
     action = menu->addAction( qtr( "&Jump Forward" ), THEMIM->getIM(),
              SLOT( jumpFwd() ) );
     action->setIcon( QIcon( ":/skip_fw") );
-    action->setData( true );
+    action->setData( STATIC_ENTRY );
 
     action = menu->addAction( qtr( "Jump Bac&kward" ), THEMIM->getIM(),
              SLOT( jumpBwd() ) );
     action->setIcon( QIcon( ":/skip_back") );
-    action->setData( true );
+    action->setData( STATIC_ENTRY );
     addDPStaticEntry( menu, qtr( I_MENU_GOTOTIME ),"",
                       SLOT( gotoTimeDialog() ), "Ctrl+T" );
     menu->addSeparator();
@@ -776,13 +783,19 @@ void QVLCMenu::PopupMenuControlEntries( QMenu *menu, intf_thread_t *p_intf )
 void QVLCMenu::PopupMenuPlaylistControlEntries( QMenu *menu,
                                                 intf_thread_t *p_intf )
 {
-    addMIMStaticEntry( p_intf, menu, qtr( "&Stop" ), ":/stop", SLOT( stop() ) );
+    bool bEnable = THEMIM->getInput() != NULL;
+    QAction *action =
+            addMIMStaticEntry( p_intf, menu, qtr( "&Stop" ), ":/stop",
+                               SLOT( stop() ), true );
+    /* Disable Stop in the right-click popup menu */
+    if( !bEnable )
+        action->setEnabled( false );
 
     /* Next / Previous */
     addMIMStaticEntry( p_intf, menu, qtr( "Pre&vious" ),
-            ":/previous", SLOT( prev() ) );
+        ":/previous", SLOT( prev() ) );
     addMIMStaticEntry( p_intf, menu, qtr( "Ne&xt" ),
-            ":/next", SLOT( next() ) );
+        ":/next", SLOT( next() ) );
     menu->addSeparator();
 }
 
@@ -877,21 +890,18 @@ void QVLCMenu::MiscPopupMenu( intf_thread_t *p_intf )
 /* Main Menu that sticks everything together  */
 void QVLCMenu::PopupMenu( intf_thread_t *p_intf, bool show )
 {
-    /* Destroy popup menu if there is one */
+    /* Delete old popup if there is one */
+    if( p_intf->p_sys->p_popup_menu )
+        delete p_intf->p_sys->p_popup_menu;
+
     if( !show )
     {
-        delete p_intf->p_sys->p_popup_menu;
         p_intf->p_sys->p_popup_menu = NULL;
         return;
     }
 
-    /* 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;
     bool b_isFullscreen = false;
     MainInterface *mi = p_intf->p_sys->p_mi;
@@ -904,6 +914,7 @@ void QVLCMenu::PopupMenu( intf_thread_t *p_intf, bool show )
 
     if( p_input )
     {
+        QMenu *submenu;
         vout_thread_t *p_vout = THEMIM->getVout();
 
         /* Add a fullscreen switch button, since it is the most used function */
@@ -951,22 +962,28 @@ void QVLCMenu::PopupMenu( intf_thread_t *p_intf, bool show )
     /* Add some special entries for windowed mode: Interface Menu */
     if( !b_isFullscreen )
     {
-        submenu = new QMenu( qtr( "Interface" ), menu );
+        QMenu *submenu = new QMenu( qtr( "Interface" ), menu );
         QMenu *tools = ToolsMenu( submenu );
         submenu->addSeparator();
 
         /* In skins interface, append some items */
         if( !mi )
         {
-            objects.clear(); varnames.clear();
 
             vlc_object_t *p_object = ( vlc_object_t* )
                 vlc_object_find_name( p_intf, "skins2", FIND_PARENT );
             if( p_object )
             {
+                objects.clear(); varnames.clear();
                 objects.push_back( p_object );
                 varnames.push_back( "intf-skins" );
                 Populate( p_intf, submenu, varnames, objects );
+
+                objects.clear(); varnames.clear();
+                objects.push_back( p_object );
+                varnames.push_back( "intf-skins-interactive" );
+                Populate( p_intf, submenu, varnames, objects );
+
                 vlc_object_release( p_object );
             }
             else
@@ -1032,6 +1049,9 @@ void QVLCMenu::updateSystrayMenu( MainInterface *mi,
     mi->getSysTray()->setContextMenu( sysMenu );
 }
 
+#undef CREATE_POPUP
+#undef POPUP_BOILERPLATE
+
 #undef PUSH_VAR
 #undef PUSH_SEPARATOR
 
@@ -1233,6 +1253,8 @@ void QVLCMenu::UpdateItem( intf_thread_t *p_intf, QMenu *menu,
     FREENULL( text.psz_string );
 }
 
+#undef TEXT_OR_VAR
+
 
 int QVLCMenu::CreateChoicesMenu( QMenu *submenu, const char *psz_var,
         vlc_object_t *p_object, bool b_root )
@@ -1387,6 +1409,7 @@ void QVLCMenu::updateRecents( intf_thread_t *p_intf )
         QList<QString> l = rmrl->recents();
 
         recentsMenu->clear();
+
         if( !l.size() )
         {
             action = recentsMenu->addAction( qtr(" - Empty - ") );