]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/menus.cpp
Qt: Menu: change icon quit(cross) -> exit
[vlc] / modules / gui / qt4 / menus.cpp
index 55ae7b7195827a1b3c28aaccfa2bc98964504db3..e366e4ea9881601e41ca7b37f6989f9439b51768 100644 (file)
 #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>
 #include <QAction>
 #include <QActionGroup>
 #include <QSignalMapper>
-#include <QSystemTrayIcon>
 #include <QStatusBar>
-#include <QFontMetrics>
 
 /*
   This file defines the main menus and the pop-up menu (right-click menu)
@@ -92,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;
@@ -113,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;
 }
@@ -233,9 +237,6 @@ static int VideoAutoMenuBuilder( vout_thread_t *p_object,
     PUSH_VAR( "fullscreen" );
     PUSH_VAR( "video-on-top" );
     PUSH_VAR( "video-wallpaper" );
-#ifdef WIN32
-    PUSH_VAR( "direct3d-desktop" );
-#endif
     PUSH_VAR( "video-snapshot" );
     PUSH_VAR( "zoom" );
     PUSH_VAR( "autoscale" );
@@ -254,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;
 }
@@ -391,7 +392,7 @@ QMenu *VLCMenuBar::FileMenu( intf_thread_t *p_intf, QWidget *parent, MainInterfa
     }
 
     addDPStaticEntry( menu, qtr( "&Quit" ) ,
-        ":/menu/quit", SLOT( quit() ), "Ctrl+Q" );
+        ":/menu/exit", SLOT( quit() ), "Ctrl+Q" );
     return menu;
 }
 
@@ -413,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() ),
@@ -474,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 ) );
@@ -497,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 */
@@ -567,17 +571,17 @@ void VLCMenuBar::ExtensionsMenu( intf_thread_t *p_intf, QMenu *extMenu )
 
 static inline void VolumeEntries( intf_thread_t *p_intf, QMenu *current )
 {
-        current->addSeparator();
+    current->addSeparator();
 
-        QAction *action = current->addAction( qtr( "Increase Volume" ),
+    QAction *action = current->addAction( qtr( "&Increase Volume" ),
                 ActionsManager::getInstance( p_intf ), SLOT( AudioUp() ) );
-        action->setData( VLCMenuBar::ACTION_STATIC );
-        action = current->addAction( qtr( "Decrease Volume" ),
+    action->setData( VLCMenuBar::ACTION_STATIC );
+    action = current->addAction( qtr( "&Decrease Volume" ),
                 ActionsManager::getInstance( p_intf ), SLOT( AudioDown() ) );
-        action->setData( VLCMenuBar::ACTION_STATIC );
-        action = current->addAction( qtr( "Mute" ),
+    action->setData( VLCMenuBar::ACTION_STATIC );
+    action = current->addAction( qtr( "&Mute" ),
                 ActionsManager::getInstance( p_intf ), SLOT( toggleMuteAudio() ) );
-        action->setData( VLCMenuBar::ACTION_STATIC );
+    action->setData( VLCMenuBar::ACTION_STATIC );
 }
 
 /**
@@ -593,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" ) );
@@ -617,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..." ), "",
@@ -648,13 +652,8 @@ QMenu *VLCMenuBar::VideoMenu( intf_thread_t *p_intf, QMenu *current, bool b_subt
         addActionWithCheckbox( current, "fullscreen", qtr( "&Fullscreen" ) );
         addActionWithCheckbox( current, "autoscale", qtr( "Always Fit &Window" ) );
         addActionWithCheckbox( current, "video-on-top", qtr( "Always &on Top" ) );
-#ifdef WIN32
-        addActionWithCheckbox( current, "direct3d-desktop", qtr( "Display on &Desktop" ) );
-#endif
-
-#ifdef WIN32
         addActionWithCheckbox( current, "video-wallpaper", qtr( "Set as Wall&paper" ) );
-#endif
+
         current->addSeparator();
         /* Size modifiers */
         addActionWithSubmenu( current, "zoom", qtr( "&Zoom" ) );
@@ -708,14 +707,14 @@ QMenu *VLCMenuBar::NavigMenu( intf_thread_t *p_intf, QMenu *menu )
     action->setData( "bookmark" );
 
     menu->addSeparator();
-    PopupMenuPlaylistControlEntries( menu, p_intf );
+
     PopupMenuControlEntries( menu, p_intf );
 
     EnableStaticEntries( menu, ( THEMIM->getInput() != NULL ) );
-    return RebuildNavigMenu( p_intf, menu );
+    return RebuildNavigMenu( p_intf, menu, true );
 }
 
-QMenu *VLCMenuBar::RebuildNavigMenu( 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;
@@ -727,16 +726,28 @@ QMenu *VLCMenuBar::RebuildNavigMenu( intf_thread_t *p_intf, QMenu *menu )
 
     InputAutoMenuBuilder( p_object, objects, varnames );
 
-    menu->addSeparator();
-
     /* Title and so on */
     PUSH_VAR( "prev-title" );
     PUSH_VAR( "next-title" );
     PUSH_VAR( "prev-chapter" );
     PUSH_VAR( "next-chapter" );
 
+    /* */
     EnableStaticEntries( menu, (p_object != NULL ) );
-    return Populate( p_intf, menu, varnames, objects );
+    Populate( p_intf, menu, varnames, objects );
+
+    /* Remove playback actions to recreate them */
+    if( !b_keep )
+    {
+        QList< QAction* > actions = menu->actions();
+        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 );
+
+    return menu;
 }
 
 /**
@@ -774,7 +785,7 @@ QMenu *VLCMenuBar::HelpMenu( QWidget *parent )
     Populate( p_intf, menu, varnames, objects ); \
     menu->popup( QCursor::pos() ); \
 
-void VLCMenuBar::PopupPlayEntries( QMenu *menu,
+void VLCMenuBar::PopupMenuPlaylistEntries( QMenu *menu,
                                         intf_thread_t *p_intf,
                                         input_thread_t *p_input )
 {
@@ -783,7 +794,7 @@ void VLCMenuBar::PopupPlayEntries( QMenu *menu,
     /* Play or Pause action and icon */
     if( !p_input || var_GetInteger( p_input, "state" ) != PLAYING_S )
     {
-        action = menu->addAction( qtr( "Play" ),
+        action = menu->addAction( qtr( "&Play" ),
                 ActionsManager::getInstance( p_intf ), SLOT( play() ) );
 #ifndef __APPLE__ /* No icons in menus in Mac */
         action->setIcon( QIcon( ":/menu/play" ) );
@@ -791,16 +802,40 @@ void VLCMenuBar::PopupPlayEntries( QMenu *menu,
     }
     else
     {
-         addMIMStaticEntry( p_intf, menu, qtr( "Pause" ),
-                    ":/menu/pause", SLOT( togglePlayPause() ) );
+        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_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_DELETE_ON_REBUILD );
+    CONNECT( THEMIM, playlistNotEmpty(bool), action, setEnabled(bool) );
+
+    menu->addSeparator();
 }
 
 void VLCMenuBar::PopupMenuControlEntries( QMenu *menu, intf_thread_t *p_intf,
                                         bool b_normal )
 {
     QAction *action;
-    QMenu *rateMenu = new QMenu( "Sp&eed" );
+    QMenu *rateMenu = new QMenu( qtr( "Sp&eed" ), menu );
     rateMenu->setTearOffEnabled( true );
 
     if( b_normal )
@@ -856,42 +891,16 @@ 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" );
-    menu->addSeparator();
-}
-
-void VLCMenuBar::PopupMenuPlaylistControlEntries( QMenu *menu,
-                                                intf_thread_t *p_intf )
-{
-    bool bEnable = THEMIM->getInput() != NULL;
-    bool bPlaylistEmpty = THEMIM->hasEmptyPlaylist();
-    QAction *action =
-            addMIMStaticEntry( p_intf, menu, qtr( "&Stop" ), ":/menu/stop",
-                               SLOT( stop() ), true );
-    /* Disable Stop in the right-click popup menu */
-    if( !bEnable )
-        action->setEnabled( false );
 
-    /* Next / Previous */
-    action = addMIMStaticEntry( p_intf, menu, qtr( "Pre&vious" ),
-        ":/menu/previous", SLOT( prev() ), true );
-    action->setEnabled( !bPlaylistEmpty );
-    action->setData( ACTION_NO_CLEANUP );
-    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 );
-    CONNECT( THEMIM, playlistNotEmpty(bool), action, setEnabled(bool) );
+    action = menu->addAction( qtr( I_MENU_GOTOTIME ), THEDP, SLOT( gotoTimeDialog() ), qtr( "Ctrl+T" ) );
+    action->setData( ACTION_ALWAYS_ENABLED );
 
     menu->addSeparator();
 }
 
 void VLCMenuBar::PopupMenuStaticEntries( QMenu *menu )
 {
-    QMenu *openmenu = new QMenu( qtr( "Open Media" ), menu );
+    QMenu *openmenu = new QMenu( qtr( "Open Media" ), menu );
     addDPStaticEntry( openmenu, qtr( "&Open File..." ),
         ":/type/file-asym", SLOT( openFileDialog() ) );
     addDPStaticEntry( openmenu, qtr( I_OP_OPDIR ),
@@ -911,7 +920,7 @@ void VLCMenuBar::PopupMenuStaticEntries( QMenu *menu )
     menu->addMenu( helpmenu );
 #endif
 
-    addDPStaticEntry( menu, qtr( "Quit" ), ":/menu/quit",
+    addDPStaticEntry( menu, qtr( "Quit" ), ":/menu/exit",
                       SLOT( quit() ), "Ctrl+Q", QAction::QuitRole );
 }
 
@@ -950,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" );
@@ -957,12 +967,10 @@ void VLCMenuBar::MiscPopupMenu( intf_thread_t *p_intf, bool show )
         menu->addSeparator();
     }
 
-    menu = new QMenu();
     Populate( p_intf, menu, varnames, objects );
 
     menu->addSeparator();
-    PopupPlayEntries( menu, p_intf, p_input );
-    PopupMenuPlaylistControlEntries( menu, p_intf);
+    PopupMenuPlaylistEntries( menu, p_intf, p_input );
 
     menu->addSeparator();
     PopupMenuControlEntries( menu, p_intf );
@@ -979,13 +987,12 @@ void VLCMenuBar::PopupMenu( intf_thread_t *p_intf, bool show )
     POPUP_BOILERPLATE
 
     /* */
-    menu = new QMenu( );
+    menu = new QMenu();
     QAction *action;
     bool b_isFullscreen = false;
     MainInterface *mi = p_intf->p_sys->p_mi;
 
-    PopupPlayEntries( menu, p_intf, p_input );
-    PopupMenuPlaylistControlEntries( menu, p_intf );
+    PopupMenuPlaylistEntries( menu, p_intf, p_input );
     menu->addSeparator();
 
     if( p_input )
@@ -1080,7 +1087,7 @@ void VLCMenuBar::PopupMenu( intf_thread_t *p_intf, bool show )
     }
 
     /* */
-    QMenuView *plMenu = new QMenuView( menu );
+    QMenuView *plMenu = new QMenuView( menu, 25 );
     plMenu->setTitle( qtr("Playlist") );
     PLModel *model = PLModel::getPLModel( p_intf );
     plMenu->setModel( model );
@@ -1117,28 +1124,27 @@ void VLCMenuBar::updateSystrayMenu( MainInterface *mi,
     if( mi->isVisible() || b_force_visible )
     {
         sysMenu->addAction( QIcon( ":/logo/vlc16.png" ),
-                            qtr( "Hide VLC media player in taskbar" ), mi,
+                            qtr( "&Hide VLC media player in taskbar" ), mi,
                             SLOT( hideUpdateSystrayMenu() ) );
     }
     else
     {
         sysMenu->addAction( QIcon( ":/logo/vlc16.png" ),
-                            qtr( "Show VLC media player" ), mi,
+                            qtr( "Sho&w VLC media player" ), mi,
                             SLOT( showUpdateSystrayMenu() ) );
     }
     sysMenu->addSeparator();
 #endif
 
-    PopupPlayEntries( sysMenu, p_intf, p_input );
-    PopupMenuPlaylistControlEntries( sysMenu, p_intf);
+    PopupMenuPlaylistEntries( sysMenu, p_intf, p_input );
     PopupMenuControlEntries( sysMenu, p_intf, false );
 
     VolumeEntries( p_intf, sysMenu );
     sysMenu->addSeparator();
-    addDPStaticEntry( sysMenu, qtr( "&Open Media" ),
+    addDPStaticEntry( sysMenu, qtr( "&Open Media" ),
             ":/type/file-wide", SLOT( openFileDialog() ) );
     addDPStaticEntry( sysMenu, qtr( "&Quit" ) ,
-            ":/menu/quit", SLOT( quit() ) );
+            ":/menu/exit", SLOT( quit() ) );
 
     /* Set the menu */
     mi->getSysTray()->setContextMenu( sysMenu );
@@ -1393,7 +1399,7 @@ int VLCMenuBar::CreateChoicesMenu( QMenu *submenu, const char *psz_var,
 
 #define CURVAL val_list.p_list->p_values[i]
 #define CURTEXT text_list.p_list->p_values[i].psz_string
-#define RADIO_OR_COMMAND  ( i_type & VLC_VAR_ISCOMMAND ) ? ITEM_NORMAL : ITEM_RADIO
+#define RADIO_OR_COMMAND  ( i_type & ( VLC_VAR_ISCOMMAND | VLC_VAR_HASCHOICE ) ) ? ITEM_RADIO : ITEM_NORMAL
 
     for( i = 0; i < val_list.p_list->i_count; i++ )
     {
@@ -1506,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 )