]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/menus.cpp
Qt4: remove useless alive check on input
[vlc] / modules / gui / qt4 / menus.cpp
index 44654a4e4f5f2d0a8a67698daf7dd6805a5341c1..a9ff53fe90320b1eb30d4a3e1e222e3d2accf868 100644 (file)
@@ -49,6 +49,7 @@
 #include "extensions_manager.hpp"                 /* Extensions menu */
 #include "util/qmenuview.hpp"                     /* Simple Playlist menu */
 #include "components/playlist/playlist_model.hpp" /* PLModel getter */
+#include "components/playlist/standardpanel.hpp"  /* PLView getter */
 
 #include <QMenu>
 #include <QMenuBar>
@@ -90,7 +91,7 @@ QAction *addDPStaticEntry( QMenu *menu,
                        const char *icon,
                        const char *member,
                        const char *shortcut = NULL,
-                       QAction::MenuRole = QAction::NoRole
+                       QAction::MenuRole role = QAction::NoRole
                        )
 {
     QAction *action = NULL;
@@ -111,6 +112,11 @@ QAction *addDPStaticEntry( QMenu *menu,
         else
             action = menu->addAction( text, THEDP, member );
     }
+#ifdef __APPLE__
+    action->setMenuRole( role );
+#else
+    Q_UNUSED( role );
+#endif
     action->setData( VLCMenuBar::ACTION_STATIC );
     return action;
 }
@@ -249,8 +255,8 @@ static int AudioAutoMenuBuilder( audio_output_t *p_object,
         QVector<const char *> &varnames )
 {
     PUSH_INPUTVAR( "audio-es" );
-    PUSH_VAR( "audio-channels" );
-    PUSH_VAR( "audio-device" );
+    PUSH_VAR( "stereo-mode" );
+    PUSH_VAR( "device" );
     PUSH_VAR( "visual" );
     return VLC_SUCCESS;
 }
@@ -408,7 +414,7 @@ QMenu *VLCMenuBar::ToolsMenu( QMenu *menu )
 
 #ifdef ENABLE_VLM
     addDPStaticEntry( menu, qtr( I_MENU_VLM ), "", SLOT( vlmDialog() ),
-        "Ctrl+W" );
+        "Ctrl+Shift+W" );
 #endif
 
     addDPStaticEntry( menu, qtr( "Program Guide" ), "", SLOT( epgDialog() ),
@@ -469,13 +475,16 @@ QMenu *VLCMenuBar::ViewMenu( intf_thread_t *p_intf, QMenu *current, MainInterfac
             qtr( "Play&list" ), mi,
             SLOT( togglePlaylist() ), qtr( "Ctrl+L" ) );
 
+    if( mi->getPlaylistView() )
+        menu->addMenu( StandardPLPanel::viewSelectionMenu( mi->getPlaylistView() ) );
     menu->addSeparator();
 
     /* Minimal View */
     action = menu->addAction( qtr( "Mi&nimal Interface" ) );
     action->setShortcut( qtr( "Ctrl+H" ) );
     action->setCheckable( true );
-    action->setChecked( (mi->getControlsVisibilityStatus() & CONTROLS_HIDDEN ) );
+    action->setChecked( (mi->getControlsVisibilityStatus()
+                         & MainInterface::CONTROLS_HIDDEN ) );
 
     CONNECT( action, triggered( bool ), mi, toggleMinimalView( bool ) );
     CONNECT( mi, minimalViewToggled( bool ), action, setChecked( bool ) );
@@ -492,7 +501,7 @@ QMenu *VLCMenuBar::ViewMenu( intf_thread_t *p_intf, QMenu *current, MainInterfac
     action = menu->addAction( qtr( "&Advanced Controls" ), mi,
             SLOT( toggleAdvancedButtons() ) );
     action->setCheckable( true );
-    if( mi->getControlsVisibilityStatus() & CONTROLS_ADVANCED )
+    if( mi->getControlsVisibilityStatus() & MainInterface::CONTROLS_ADVANCED )
         action->setChecked( true );
 
     /* Docked Playlist */
@@ -588,8 +597,8 @@ QMenu *VLCMenuBar::AudioMenu( intf_thread_t *p_intf, QMenu * current )
     if( current->isEmpty() )
     {
         addActionWithSubmenu( current, "audio-es", qtr( "Audio &Track" ) );
-        addActionWithSubmenu( current, "audio-channels", qtr( "Audio &Channels" ) );
-        addActionWithSubmenu( current, "audio-device", qtr( "Audio &Device" ) );
+        addActionWithSubmenu( current, "stereo-mode", qtr( "&Stereo Mode" ) );
+        addActionWithSubmenu( current, "device", qtr( "Audio &Device" ) );
         current->addSeparator();
 
         addActionWithSubmenu( current, "visual", qtr( "&Visualizations" ) );
@@ -612,7 +621,7 @@ QMenu *VLCMenuBar::AudioMenu( intf_thread_t *p_intf, QMenu * current )
 QMenu *VLCMenuBar::SubtitleMenu( QMenu *current )
 {
     QAction *action;
-    QMenu *submenu = new QMenu( qtr( "&Subtitles Track" ), current );
+    QMenu *submenu = new QMenu( qtr( "&Subtitle Track" ), current );
     action = current->addMenu( submenu );
     action->setData( "spu-es" );
     addDPStaticEntry( submenu, qtr( "Open File..." ), "",
@@ -707,7 +716,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 +732,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 +802,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();
@@ -879,8 +891,10 @@ void VLCMenuBar::PopupMenuControlEntries( QMenu *menu, intf_thread_t *p_intf,
     action->setIcon( QIcon( ":/toolbar/skip_back") );
 #endif
     action->setData( ACTION_STATIC );
-    addDPStaticEntry( menu, qtr( I_MENU_GOTOTIME ),"",
-                      SLOT( gotoTimeDialog() ), "Ctrl+T" );
+
+    action = menu->addAction( qtr( I_MENU_GOTOTIME ), THEDP, SLOT( gotoTimeDialog() ), qtr( "Ctrl+T" ) );
+    action->setData( ACTION_ALWAYS_ENABLED );
+
     menu->addSeparator();
 }
 
@@ -945,6 +959,7 @@ void VLCMenuBar::MiscPopupMenu( intf_thread_t *p_intf, bool show )
 {
     POPUP_BOILERPLATE
 
+    menu = new QMenu();
     if( p_input )
     {
         varnames.append( "audio-es" );
@@ -952,7 +967,6 @@ void VLCMenuBar::MiscPopupMenu( intf_thread_t *p_intf, bool show )
         menu->addSeparator();
     }
 
-    menu = new QMenu();
     Populate( p_intf, menu, varnames, objects );
 
     menu->addSeparator();
@@ -1498,13 +1512,18 @@ void VLCMenuBar::DoAction( QObject *data )
     MenuItemData *itemData = qobject_cast<MenuItemData *>( data );
     vlc_object_t *p_object = itemData->p_obj;
     if( p_object == NULL ) return;
+    const char *var = itemData->psz_var;
+    vlc_value_t val = itemData->val;
 
     /* Preserve settings across vouts via the playlist object: */
-    if( !strcmp( itemData->psz_var, "fullscreen" )
-     || !strcmp( itemData->psz_var, "video-on-top" ) )
-        var_Set( pl_Get( p_object ), itemData->psz_var, itemData->val );
+    if( !strcmp( var, "fullscreen" )
+     || !strcmp( var, "video-on-top" ) )
+        var_Set( pl_Get( p_object ), var, val );
 
-    var_Set( p_object, itemData->psz_var, itemData->val );
+    if ((var_Type( p_object, var) & VLC_VAR_CLASS) == VLC_VAR_VOID)
+        var_TriggerCallback( p_object, var );
+    else
+        var_Set( p_object, var, val );
 }
 
 void VLCMenuBar::updateRecents( intf_thread_t *p_intf )