1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright © 2006-2011 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Jean-Baptiste Kempf <jb@videolan.org>
9 * Jean-Philippe André <jpeg@videolan.org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * ( at your option ) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
27 * - Remove static currentGroup
30 #define __STDC_FORMAT_MACROS 1
31 #define __STDC_CONSTANT_MACROS 1
37 #include <vlc_common.h>
38 #include <vlc_intf_strings.h>
39 #include <vlc_vout.h> /* vout_thread_t */
40 #include <vlc_aout.h> /* audio_output_t */
44 #include "main_interface.hpp" /* View modifications */
45 #include "dialogs_provider.hpp" /* Dialogs display */
46 #include "input_manager.hpp" /* Input Management */
47 #include "recents.hpp" /* Recent Items */
48 #include "actions_manager.hpp" /* Actions Management: play+volume */
49 #include "extensions_manager.hpp" /* Extensions menu */
50 #include "util/qmenuview.hpp" /* Simple Playlist menu */
51 #include "components/playlist/playlist_model.hpp" /* PLModel getter */
52 #include "components/playlist/standardpanel.hpp" /* PLView getter */
57 #include <QActionGroup>
58 #include <QSignalMapper>
62 This file defines the main menus and the pop-up menu (right-click menu)
63 and the systray menu (in that order in the file)
65 There are 4 menus that have to be rebuilt everytime there are called:
66 Audio, Video, Navigation, view
67 4 functions are building those menus: AudioMenu, VideoMenu, NavigMenu, View
68 and 3 functions associated are collecting the objects :
69 InputAutoMenuBuilder, AudioAutoMenuBuilder, VideoAutoMenuBuilder.
71 A QSignalMapper decides when to rebuild those menus cf MenuFunc in the .hpp
72 Just before one of those menus are aboutToShow(), they are rebuild.
77 ITEM_NORMAL, /* not a checkbox, nor a radio */
78 ITEM_CHECK, /* Checkbox */
79 ITEM_RADIO /* Radiobox */
82 static QActionGroup *currentGroup;
84 QMenu *VLCMenuBar::recentsMenu = NULL;
85 QMenu *VLCMenuBar::audioDeviceMenu = NULL;
88 * @brief Add static entries to DP in menus
90 QAction *addDPStaticEntry( QMenu *menu,
94 const char *shortcut = NULL,
95 QAction::MenuRole role = QAction::NoRole
98 QAction *action = NULL;
99 #ifndef __APPLE__ /* We don't set icons in menus in MacOS X */
100 if( !EMPTY_STR( icon ) )
102 if( !EMPTY_STR( shortcut ) )
103 action = menu->addAction( QIcon( icon ), text, THEDP,
104 member, qtr( shortcut ) );
106 action = menu->addAction( QIcon( icon ), text, THEDP, member );
111 if( !EMPTY_STR( shortcut ) )
112 action = menu->addAction( text, THEDP, member, qtr( shortcut ) );
114 action = menu->addAction( text, THEDP, member );
117 action->setMenuRole( role );
121 action->setData( VLCMenuBar::ACTION_STATIC );
126 * @brief Add static entries to MIM in menus
128 QAction* addMIMStaticEntry( intf_thread_t *p_intf,
133 bool bStatic = false )
136 #ifndef __APPLE__ /* We don't set icons in menus in MacOS X */
137 if( !EMPTY_STR( icon ) )
139 action = menu->addAction( text, THEMIM, member );
140 action->setIcon( QIcon( icon ) );
145 action = menu->addAction( text, THEMIM, member );
147 action->setData( VLCMenuBar::ACTION_STATIC |
148 ( bStatic ) ? VLCMenuBar::ACTION_ALWAYS_ENABLED
149 : VLCMenuBar::ACTION_NONE
155 * @brief Enable all static entries of a menu, disable the others
156 * @param menu the menu in which the entries will be disabled
157 * @param enable if false, disable all entries
159 void VLCMenuBar::EnableStaticEntries( QMenu *menu, bool enable = true )
163 QList< QAction* > actions = menu->actions();
164 for( int i = 0; i < actions.count(); ++i )
166 int actionflags = actions[i]->data().toInt();
167 if ( actionflags & ACTION_MANAGED )
168 actions[i]->setEnabled(
169 ( actionflags & ACTION_ALWAYS_ENABLED )
177 * \return Number of static entries
179 inline int DeleteNonStaticEntries( QMenu *menu )
181 if( !menu ) return VLC_EGENERIC;
185 QList< QAction* > actions = menu->actions();
186 for( int i = 0; i < actions.count(); ++i )
188 if( actions[i]->data().toInt() & VLCMenuBar::ACTION_NO_CLEANUP )
197 * \return QAction associated to psz_var variable
199 static QAction * FindActionWithVar( QMenu *menu, const char *psz_var )
201 QList< QAction* > actions = menu->actions();
202 for( int i = 0; i < actions.count(); ++i )
204 if( actions[i]->data().toString() == psz_var )
210 /*****************************************************************************
211 * Definitions of variables for the dynamic menus
212 *****************************************************************************/
213 #define PUSH_VAR( var ) varnames.append( var ); \
214 objects.append( VLC_OBJECT(p_object) )
216 #define PUSH_INPUTVAR( var ) varnames.append( var ); \
217 objects.append( VLC_OBJECT(p_input) );
219 static int InputAutoMenuBuilder( input_thread_t *p_object,
220 QVector<vlc_object_t *> &objects,
221 QVector<const char *> &varnames )
223 PUSH_VAR( "bookmark" );
225 PUSH_VAR( "chapter" );
226 PUSH_VAR( "program" );
230 static int VideoAutoMenuBuilder( vout_thread_t *p_object,
231 input_thread_t *p_input,
232 QVector<vlc_object_t *> &objects,
233 QVector<const char *> &varnames )
235 PUSH_INPUTVAR( "video-es" );
236 PUSH_VAR( "fullscreen" );
237 PUSH_VAR( "video-on-top" );
238 PUSH_VAR( "video-wallpaper" );
239 PUSH_VAR( "video-snapshot" );
241 PUSH_VAR( "autoscale" );
242 PUSH_VAR( "aspect-ratio" );
244 PUSH_VAR( "deinterlace" );
245 PUSH_VAR( "deinterlace-mode" );
246 PUSH_VAR( "postprocess" );
251 static int SubsAutoMenuBuilder( input_thread_t *p_object,
252 QVector<vlc_object_t *> &objects,
253 QVector<const char *> &varnames )
255 PUSH_VAR( "spu-es" );
262 static int AudioAutoMenuBuilder( audio_output_t *p_object,
263 input_thread_t *p_input,
264 QVector<vlc_object_t *> &objects,
265 QVector<const char *> &varnames )
267 PUSH_INPUTVAR( "audio-es" );
268 PUSH_VAR( "stereo-mode" );
269 PUSH_VAR( "visual" );
273 /*****************************************************************************
276 *****************************************************************************/
279 static inline void addMenuToMainbar( QMenu *func, QString title, QMenuBar *bar ) {
280 func->setTitle( title );
285 #define BAR_DADD( func, title, id ) { \
286 QMenu *_menu = func; _menu->setTitle( title ); bar->addMenu( _menu ); \
287 MenuFunc *f = new MenuFunc( _menu, id ); \
288 CONNECT( _menu, aboutToShow(), THEDP->menusUpdateMapper, map() ); \
289 THEDP->menusUpdateMapper->setMapping( _menu, f ); }
291 // Add a simple action
292 static inline void addAction( QMenu *_menu, QVariant val, QString title ) {
293 QAction *_action = new QAction( title, _menu );
294 _action->setData( val );
295 _menu->addAction( _action );
298 // Add an action with a submenu
299 static inline QMenu *addActionWithSubmenu( QMenu *_menu, QVariant val, QString title ) {
300 QAction *_action = new QAction( title, _menu );
301 QMenu *_submenu = new QMenu( _menu );
302 _action->setData( val );
303 _action->setMenu( _submenu );
304 _menu->addAction( _action );
308 // Add an action that is a checkbox
309 static inline void addActionWithCheckbox( QMenu *_menu, QVariant val, QString title ) {
310 QAction *_action = new QAction( title, _menu );
311 _action->setData( val );
312 _action->setCheckable( true );
313 _menu->addAction( _action );
317 * Main Menu Bar Creation
319 void VLCMenuBar::createMenuBar( MainInterface *mi,
320 intf_thread_t *p_intf )
322 /* QMainWindows->menuBar()
323 gives the QProcess::destroyed timeout issue on Cleanlooks style with
324 setDesktopAware set to false */
325 QMenuBar *bar = mi->menuBar();
327 addMenuToMainbar( FileMenu( p_intf, bar, mi ), qtr( "&Media" ), bar );
329 /* Dynamic menus, rebuilt before being showed */
330 BAR_DADD( NavigMenu( p_intf, bar ), qtr( "P&layback" ), 3 );
331 BAR_DADD( AudioMenu( p_intf, bar ), qtr( "&Audio" ), 1 );
332 BAR_DADD( VideoMenu( p_intf, bar ), qtr( "&Video" ), 2 );
333 BAR_DADD( SubtitleMenu( p_intf, bar ), qtr( "Subti&tle" ), 5 );
335 addMenuToMainbar( ToolsMenu( p_intf, bar ), qtr( "T&ools" ), bar );
337 /* View menu, a bit different */
338 BAR_DADD( ViewMenu( p_intf, NULL, mi ), qtr( "V&iew" ), 4 );
340 addMenuToMainbar( HelpMenu( bar ), qtr( "&Help" ), bar );
345 * Media ( File ) Menu
346 * Opening, streaming and quit
348 QMenu *VLCMenuBar::FileMenu( intf_thread_t *p_intf, QWidget *parent, MainInterface *mi )
350 QMenu *menu = new QMenu( parent );
353 addDPStaticEntry( menu, qtr( "Open &File..." ),
354 ":/type/file-asym", SLOT( simpleOpenDialog() ), "Ctrl+O" );
355 addDPStaticEntry( menu, qtr( "&Open Multiple Files..." ),
356 ":/type/file-asym", SLOT( openFileDialog() ), "Ctrl+Shift+O" );
357 addDPStaticEntry( menu, qtr( I_OP_OPDIR ),
358 ":/type/folder-grey", SLOT( PLOpenDir() ), "Ctrl+F" );
359 addDPStaticEntry( menu, qtr( "Open &Disc..." ),
360 ":/type/disc", SLOT( openDiscDialog() ), "Ctrl+D" );
361 addDPStaticEntry( menu, qtr( "Open &Network Stream..." ),
362 ":/type/network", SLOT( openNetDialog() ), "Ctrl+N" );
363 addDPStaticEntry( menu, qtr( "Open &Capture Device..." ),
364 ":/type/capture-card", SLOT( openCaptureDialog() ), "Ctrl+C" );
366 addDPStaticEntry( menu, qtr( "Open &Location from clipboard" ),
367 NULL, SLOT( openUrlDialog() ), "Ctrl+V" );
369 if( var_InheritBool( p_intf, "qt-recentplay" ) )
371 recentsMenu = new QMenu( qtr( "Open &Recent Media" ), menu );
372 updateRecents( p_intf );
373 menu->addMenu( recentsMenu );
375 menu->addSeparator();
377 addDPStaticEntry( menu, qtr( I_PL_SAVE ), "", SLOT( saveAPlaylist() ),
381 addDPStaticEntry( menu, qtr( "Conve&rt / Save..." ), "",
382 SLOT( openAndTranscodingDialogs() ), "Ctrl+R" );
383 addDPStaticEntry( menu, qtr( "&Stream..." ),
384 ":/menu/stream", SLOT( openAndStreamingDialogs() ), "Ctrl+S" );
385 menu->addSeparator();
388 action = addMIMStaticEntry( p_intf, menu, qtr( "Quit at the end of playlist" ), "",
389 SLOT( activatePlayQuit( bool ) ) );
390 action->setCheckable( true );
391 action->setChecked( THEMIM->getPlayExitState() );
393 if( mi->getSysTray() )
395 action = menu->addAction( qtr( "Close to systray"), mi,
396 SLOT( toggleUpdateSystrayMenu() ) );
399 addDPStaticEntry( menu, qtr( "&Quit" ) ,
400 ":/menu/exit", SLOT( quit() ), "Ctrl+Q" );
405 * Tools, like Media Information, Preferences or Messages
407 QMenu *VLCMenuBar::ToolsMenu( intf_thread_t *p_intf, QMenu *menu )
409 addDPStaticEntry( menu, qtr( "&Effects and Filters"), ":/menu/settings",
410 SLOT( extendedDialog() ), "Ctrl+E" );
412 addDPStaticEntry( menu, qtr( "&Track Synchronization"), ":/menu/settings",
413 SLOT( synchroDialog() ), "" );
415 addDPStaticEntry( menu, qtr( I_MENU_INFO ) , ":/menu/info",
416 SLOT( mediaInfoDialog() ), "Ctrl+I" );
417 addDPStaticEntry( menu, qtr( I_MENU_CODECINFO ) ,
418 ":/menu/info", SLOT( mediaCodecDialog() ), "Ctrl+J" );
421 addDPStaticEntry( menu, qtr( I_MENU_VLM ), "", SLOT( vlmDialog() ),
425 addDPStaticEntry( menu, qtr( "Program Guide" ), "", SLOT( epgDialog() ),
428 addDPStaticEntry( menu, qtr( I_MENU_MSG ),
429 ":/menu/messages", SLOT( messagesDialog() ), "Ctrl+M" );
431 addDPStaticEntry( menu, qtr( "Plu&gins and extensions" ),
432 "", SLOT( pluginDialog() ) );
433 menu->addSeparator();
435 if( !p_intf->p_sys->b_isDialogProvider )
436 addDPStaticEntry( menu, qtr( "Customi&ze Interface..." ),
437 ":/menu/preferences", SLOT( toolbarDialog() ) );
439 addDPStaticEntry( menu, qtr( "&Preferences" ),
440 ":/menu/preferences", SLOT( prefsDialog() ), "Ctrl+P", QAction::PreferencesRole );
447 * Interface modification, load other interfaces, activate Extensions
448 * \param current, set to NULL for menu creation, else for menu update
450 QMenu *VLCMenuBar::ViewMenu( intf_thread_t *p_intf, QMenu *current, MainInterface *_mi )
455 MainInterface *mi = _mi ? _mi : p_intf->p_sys->p_mi;
460 menu = new QMenu( qtr( "&View" ), mi );
466 //HACK menu->clear() does not delete submenus
467 QList<QAction*> actions = menu->actions();
468 foreach( QAction *a, actions )
470 QMenu *m = a->menu();
471 if( a->parent() == menu ) delete a;
472 else menu->removeAction( a );
473 if( m && m->parent() == menu ) delete m;
479 QIcon( ":/menu/playlist_menu" ),
481 qtr( "Play&list" ), mi,
482 SLOT( togglePlaylist() ), qtr( "Ctrl+L" ) );
484 /* Docked Playlist */
485 action = menu->addAction( qtr( "Docked Playlist" ) );
486 action->setCheckable( true );
487 action->setChecked( mi->isPlDocked() );
488 CONNECT( action, triggered( bool ), mi, dockPlaylist( bool ) );
490 if( mi->getPlaylistView() )
491 menu->addMenu( StandardPLPanel::viewSelectionMenu( mi->getPlaylistView() ) );
493 menu->addSeparator();
496 action = menu->addAction( qtr( "Mi&nimal Interface" ) );
497 action->setShortcut( qtr( "Ctrl+H" ) );
498 action->setCheckable( true );
499 action->setChecked( (mi->getControlsVisibilityStatus()
500 & MainInterface::CONTROLS_HIDDEN ) );
502 CONNECT( action, triggered( bool ), mi, toggleMinimalView( bool ) );
503 CONNECT( mi, minimalViewToggled( bool ), action, setChecked( bool ) );
505 /* FullScreen View */
506 action = menu->addAction( qtr( "&Fullscreen Interface" ), mi,
507 SLOT( toggleInterfaceFullScreen() ), QString( "F11" ) );
508 action->setCheckable( true );
509 action->setChecked( mi->isInterfaceFullScreen() );
510 CONNECT( mi, fullscreenInterfaceToggled( bool ),
511 action, setChecked( bool ) );
513 /* Advanced Controls */
514 action = menu->addAction( qtr( "&Advanced Controls" ), mi,
515 SLOT( toggleAdvancedButtons() ) );
516 action->setCheckable( true );
517 if( mi->getControlsVisibilityStatus() & MainInterface::CONTROLS_ADVANCED )
518 action->setChecked( true );
520 action = menu->addAction( qtr( "Status Bar" ) );
521 action->setCheckable( true );
522 action->setChecked( mi->statusBar()->isVisible() );
523 CONNECT( action, triggered( bool ), mi, setStatusBarVisibility( bool) );
524 #if 0 /* For Visualisations. Not yet working */
525 adv = menu->addAction( qtr( "Visualizations selector" ), mi,
527 adv->setCheckable( true );
528 if( visual_selector_enabled ) adv->setChecked( true );
531 menu->addSeparator();
533 InterfacesMenu( p_intf, menu );
534 menu->addSeparator();
537 ExtensionsMenu( p_intf, menu );
543 * Interface Sub-Menu, to list extras interface and skins
545 QMenu *VLCMenuBar::InterfacesMenu( intf_thread_t *p_intf, QMenu *current )
547 QVector<vlc_object_t *> objects;
548 QVector<const char *> varnames;
549 varnames.append( "intf-add" );
550 objects.append( VLC_OBJECT(p_intf) );
552 return Populate( p_intf, current, varnames, objects );
556 * Extensions menu: populate the current menu with extensions
558 void VLCMenuBar::ExtensionsMenu( intf_thread_t *p_intf, QMenu *extMenu )
560 /* Get ExtensionsManager and load extensions if needed */
561 ExtensionsManager *extMgr = ExtensionsManager::getInstance( p_intf );
563 if( !var_InheritBool( p_intf, "qt-autoload-extensions")
564 && !extMgr->isLoaded() )
569 if( !extMgr->isLoaded() && !extMgr->cannotLoad() )
571 extMgr->loadExtensions();
574 /* Let the ExtensionsManager build itself the menu */
575 extMenu->addSeparator();
576 extMgr->menu( extMenu );
579 static inline void VolumeEntries( intf_thread_t *p_intf, QMenu *current )
581 current->addSeparator();
583 QAction *action = current->addAction( qtr( "&Increase Volume" ),
584 ActionsManager::getInstance( p_intf ), SLOT( AudioUp() ) );
585 action->setData( VLCMenuBar::ACTION_STATIC );
586 action = current->addAction( qtr( "&Decrease Volume" ),
587 ActionsManager::getInstance( p_intf ), SLOT( AudioDown() ) );
588 action->setData( VLCMenuBar::ACTION_STATIC );
589 action = current->addAction( qtr( "&Mute" ),
590 ActionsManager::getInstance( p_intf ), SLOT( toggleMuteAudio() ) );
591 action->setData( VLCMenuBar::ACTION_STATIC );
597 QMenu *VLCMenuBar::AudioMenu( intf_thread_t *p_intf, QMenu * current )
599 QVector<vlc_object_t *> objects;
600 QVector<const char *> varnames;
601 audio_output_t *p_aout;
602 input_thread_t *p_input;
604 if( current->isEmpty() )
606 addActionWithSubmenu( current, "audio-es", qtr( "Audio &Track" ) );
607 audioDeviceMenu = current->addMenu( qtr( "Audio &Device" ) );
608 addActionWithSubmenu( current, "stereo-mode", qtr( "&Stereo Mode" ) );
609 current->addSeparator();
611 addActionWithSubmenu( current, "visual", qtr( "&Visualizations" ) );
612 VolumeEntries( p_intf, current );
615 p_input = THEMIM->getInput();
616 p_aout = THEMIM->getAout();
617 EnableStaticEntries( current, ( p_aout != NULL ) );
618 AudioAutoMenuBuilder( p_aout, p_input, objects, varnames );
619 updateAudioDevice( p_intf, p_aout, audioDeviceMenu );
622 vlc_object_release( p_aout );
625 return Populate( p_intf, current, varnames, objects );
629 QMenu *VLCMenuBar::SubtitleMenu( intf_thread_t *p_intf, QMenu *current )
631 input_thread_t *p_input;
632 QVector<vlc_object_t *> objects;
633 QVector<const char *> varnames;
635 if( current->isEmpty() )
637 addDPStaticEntry( current, qtr( "Add &Subtitle File..." ), "",
638 SLOT( loadSubtitlesFile() ) );
639 addActionWithSubmenu( current, "spu-es", qtr( "Sub &Track" ) );
640 current->addSeparator();
643 p_input = THEMIM->getInput();
644 SubsAutoMenuBuilder( p_input, objects, varnames );
646 return Populate( p_intf, current, varnames, objects );
651 * Subtitles are part of Video.
653 QMenu *VLCMenuBar::VideoMenu( intf_thread_t *p_intf, QMenu *current )
655 vout_thread_t *p_vout;
656 input_thread_t *p_input;
657 QVector<vlc_object_t *> objects;
658 QVector<const char *> varnames;
660 if( current->isEmpty() )
662 addActionWithSubmenu( current, "video-es", qtr( "Video &Track" ) );
664 current->addSeparator();
665 /* Surface modifiers */
666 addActionWithCheckbox( current, "fullscreen", qtr( "&Fullscreen" ) );
667 addActionWithCheckbox( current, "autoscale", qtr( "Always Fit &Window" ) );
668 addActionWithCheckbox( current, "video-on-top", qtr( "Always &on Top" ) );
669 addActionWithCheckbox( current, "video-wallpaper", qtr( "Set as Wall&paper" ) );
671 current->addSeparator();
673 addActionWithSubmenu( current, "zoom", qtr( "&Zoom" ) );
674 addActionWithSubmenu( current, "aspect-ratio", qtr( "&Aspect Ratio" ) );
675 addActionWithSubmenu( current, "crop", qtr( "&Crop" ) );
677 current->addSeparator();
678 /* Rendering modifiers */
679 addActionWithSubmenu( current, "deinterlace", qtr( "&Deinterlace" ) );
680 addActionWithSubmenu( current, "deinterlace-mode", qtr( "&Deinterlace mode" ) );
681 addActionWithSubmenu( current, "postprocess", qtr( "&Post processing" ) );
683 current->addSeparator();
685 addAction( current, "video-snapshot", qtr( "Take &Snapshot" ) );
688 p_input = THEMIM->getInput();
690 p_vout = THEMIM->getVout();
691 VideoAutoMenuBuilder( p_vout, p_input, objects, varnames );
694 vlc_object_release( p_vout );
696 return Populate( p_intf, current, varnames, objects );
701 * For DVD, MP4, MOV and other chapter based format
703 QMenu *VLCMenuBar::NavigMenu( intf_thread_t *p_intf, QMenu *menu )
708 addActionWithSubmenu( menu, "title", qtr( "T&itle" ) );
709 submenu = addActionWithSubmenu( menu, "chapter", qtr( "&Chapter" ) );
710 submenu->setTearOffEnabled( true );
711 addActionWithSubmenu( menu, "program", qtr( "&Program" ) );
713 submenu = new QMenu( qtr( I_MENU_BOOKMARK ), menu );
714 submenu->setTearOffEnabled( true );
715 addDPStaticEntry( submenu, qtr( "&Manage" ), "",
716 SLOT( bookmarksDialog() ), "Ctrl+B" );
717 submenu->addSeparator();
718 action = menu->addMenu( submenu );
719 action->setData( "bookmark" );
721 menu->addSeparator();
723 PopupMenuControlEntries( menu, p_intf );
725 EnableStaticEntries( menu, ( THEMIM->getInput() != NULL ) );
726 return RebuildNavigMenu( p_intf, menu, true );
729 QMenu *VLCMenuBar::RebuildNavigMenu( intf_thread_t *p_intf, QMenu *menu, bool b_keep )
732 input_thread_t *p_object;
733 QVector<vlc_object_t *> objects;
734 QVector<const char *> varnames;
736 /* Get the input and hold it */
737 p_object = THEMIM->getInput();
739 InputAutoMenuBuilder( p_object, objects, varnames );
741 /* Title and so on */
742 PUSH_VAR( "prev-title" );
743 PUSH_VAR( "next-title" );
744 PUSH_VAR( "prev-chapter" );
745 PUSH_VAR( "next-chapter" );
748 EnableStaticEntries( menu, (p_object != NULL ) );
749 Populate( p_intf, menu, varnames, objects );
751 /* Remove playback actions to recreate them */
754 QList< QAction* > actions = menu->actions();
755 for( int i = 0; i < actions.count(); i++ )
756 if( actions[i]->data().toInt() & ACTION_DELETE_ON_REBUILD )
760 PopupMenuPlaylistEntries( menu, p_intf, p_object );
768 QMenu *VLCMenuBar::HelpMenu( QWidget *parent )
770 QMenu *menu = new QMenu( parent );
771 addDPStaticEntry( menu, qtr( "&Help..." ) ,
772 ":/menu/help", SLOT( helpDialog() ), "F1" );
774 addDPStaticEntry( menu, qtr( "Check for &Updates..." ) , "",
775 SLOT( updateDialog() ) );
777 menu->addSeparator();
778 addDPStaticEntry( menu, qtr( I_MENU_ABOUT ), ":/menu/info",
779 SLOT( aboutDialog() ), "Shift+F1", QAction::AboutRole );
783 /*****************************************************************************
784 * Popup menus - Right Click menus *
785 *****************************************************************************/
786 #define POPUP_BOILERPLATE \
787 static QMenu* menu = NULL; \
788 delete menu; menu = NULL; \
791 QVector<vlc_object_t *> objects; \
792 QVector<const char *> varnames; \
793 input_thread_t *p_input = THEMIM->getInput();
795 #define CREATE_POPUP \
796 menu = new QMenu(); \
797 Populate( p_intf, menu, varnames, objects ); \
798 menu->popup( QCursor::pos() ); \
800 void VLCMenuBar::PopupMenuPlaylistEntries( QMenu *menu,
801 intf_thread_t *p_intf,
802 input_thread_t *p_input )
806 /* Play or Pause action and icon */
807 if( !p_input || var_GetInteger( p_input, "state" ) != PLAYING_S )
809 action = menu->addAction( qtr( "&Play" ),
810 ActionsManager::getInstance( p_intf ), SLOT( play() ) );
811 #ifndef __APPLE__ /* No icons in menus in Mac */
812 action->setIcon( QIcon( ":/menu/play" ) );
817 action = addMIMStaticEntry( p_intf, menu, qtr( "Pause" ),
818 ":/menu/pause", SLOT( togglePlayPause() ) );
820 action->setData( ACTION_DELETE_ON_REBUILD );
823 action = addMIMStaticEntry( p_intf, menu, qtr( "&Stop" ),
824 ":/menu/stop", SLOT( stop() ), true );
826 action->setEnabled( false );
827 action->setData( ACTION_DELETE_ON_REBUILD );
829 /* Next / Previous */
830 bool bPlaylistEmpty = THEMIM->hasEmptyPlaylist();
831 action = addMIMStaticEntry( p_intf, menu, qtr( "Pre&vious" ),
832 ":/menu/previous", SLOT( prev() ), true );
833 action->setEnabled( !bPlaylistEmpty );
834 action->setData( ACTION_NO_CLEANUP + ACTION_DELETE_ON_REBUILD );
835 CONNECT( THEMIM, playlistNotEmpty(bool), action, setEnabled(bool) );
837 action = addMIMStaticEntry( p_intf, menu, qtr( "Ne&xt" ),
838 ":/menu/next", SLOT( next() ), true );
839 action->setEnabled( !bPlaylistEmpty );
840 action->setData( ACTION_NO_CLEANUP + ACTION_DELETE_ON_REBUILD );
841 CONNECT( THEMIM, playlistNotEmpty(bool), action, setEnabled(bool) );
843 menu->addSeparator();
846 void VLCMenuBar::PopupMenuControlEntries( QMenu *menu, intf_thread_t *p_intf,
850 QMenu *rateMenu = new QMenu( qtr( "Sp&eed" ), menu );
851 rateMenu->setTearOffEnabled( true );
856 action = rateMenu->addAction( qtr( "&Faster" ), THEMIM->getIM(),
858 #ifndef __APPLE__ /* No icons in menus in Mac */
859 action->setIcon( QIcon( ":/toolbar/faster2") );
861 action->setData( ACTION_STATIC );
864 action = rateMenu->addAction( qtr( "Faster (fine)" ), THEMIM->getIM(),
865 SLOT( littlefaster() ) );
866 action->setData( ACTION_STATIC );
868 action = rateMenu->addAction( qtr( "N&ormal Speed" ), THEMIM->getIM(),
869 SLOT( normalRate() ) );
870 action->setData( ACTION_STATIC );
872 action = rateMenu->addAction( qtr( "Slower (fine)" ), THEMIM->getIM(),
873 SLOT( littleslower() ) );
874 action->setData( ACTION_STATIC );
878 action = rateMenu->addAction( qtr( "Slo&wer" ), THEMIM->getIM(),
880 #ifndef __APPLE__ /* No icons in menus in Mac */
881 action->setIcon( QIcon( ":/toolbar/slower2") );
883 action->setData( ACTION_STATIC );
886 action = menu->addMenu( rateMenu );
887 action->setData( ACTION_STATIC );
889 menu->addSeparator();
891 if( !b_normal ) return;
893 action = menu->addAction( qtr( "&Jump Forward" ), THEMIM->getIM(),
895 #ifndef __APPLE__ /* No icons in menus in Mac */
896 action->setIcon( QIcon( ":/toolbar/skip_fw") );
898 action->setData( ACTION_STATIC );
900 action = menu->addAction( qtr( "Jump Bac&kward" ), THEMIM->getIM(),
902 #ifndef __APPLE__ /* No icons in menus in Mac */
903 action->setIcon( QIcon( ":/toolbar/skip_back") );
905 action->setData( ACTION_STATIC );
907 action = menu->addAction( qtr( I_MENU_GOTOTIME ), THEDP, SLOT( gotoTimeDialog() ), qtr( "Ctrl+T" ) );
908 action->setData( ACTION_ALWAYS_ENABLED );
910 menu->addSeparator();
913 void VLCMenuBar::PopupMenuStaticEntries( QMenu *menu )
915 QMenu *openmenu = new QMenu( qtr( "Open Media" ), menu );
916 addDPStaticEntry( openmenu, qtr( I_OP_OPF ),
917 ":/type/file-asym", SLOT( openFileDialog() ) );
918 addDPStaticEntry( openmenu, qtr( I_OP_OPDIR ),
919 ":/type/folder-grey", SLOT( PLOpenDir() ) );
920 addDPStaticEntry( openmenu, qtr( "Open &Disc..." ),
921 ":/type/disc", SLOT( openDiscDialog() ) );
922 addDPStaticEntry( openmenu, qtr( "Open &Network..." ),
923 ":/type/network", SLOT( openNetDialog() ) );
924 addDPStaticEntry( openmenu, qtr( "Open &Capture Device..." ),
925 ":/type/capture-card", SLOT( openCaptureDialog() ) );
926 menu->addMenu( openmenu );
928 menu->addSeparator();
930 QMenu *helpmenu = HelpMenu( menu );
931 helpmenu->setTitle( qtr( "Help" ) );
932 menu->addMenu( helpmenu );
935 addDPStaticEntry( menu, qtr( "Quit" ), ":/menu/exit",
936 SLOT( quit() ), "Ctrl+Q", QAction::QuitRole );
939 /* Video Tracks and Subtitles tracks */
940 void VLCMenuBar::VideoPopupMenu( intf_thread_t *p_intf, bool show )
945 vout_thread_t *p_vout = THEMIM->getVout();
948 VideoAutoMenuBuilder( p_vout, p_input, objects, varnames );
949 vlc_object_release( p_vout );
956 void VLCMenuBar::AudioPopupMenu( intf_thread_t *p_intf, bool show )
961 audio_output_t *p_aout = THEMIM->getAout();
962 AudioAutoMenuBuilder( p_aout, p_input, objects, varnames );
964 vlc_object_release( p_aout );
969 /* Navigation stuff, and general menus ( open ), used only for skins */
970 void VLCMenuBar::MiscPopupMenu( intf_thread_t *p_intf, bool show )
977 varnames.append( "audio-es" );
978 InputAutoMenuBuilder( p_input, objects, varnames );
979 menu->addSeparator();
982 Populate( p_intf, menu, varnames, objects );
984 menu->addSeparator();
985 PopupMenuPlaylistEntries( menu, p_intf, p_input );
987 menu->addSeparator();
988 PopupMenuControlEntries( menu, p_intf );
990 menu->addSeparator();
991 PopupMenuStaticEntries( menu );
993 menu->popup( QCursor::pos() );
996 /* Main Menu that sticks everything together */
997 void VLCMenuBar::PopupMenu( intf_thread_t *p_intf, bool show )
1004 bool b_isFullscreen = false;
1005 MainInterface *mi = p_intf->p_sys->p_mi;
1007 PopupMenuPlaylistEntries( menu, p_intf, p_input );
1008 menu->addSeparator();
1013 vout_thread_t *p_vout = THEMIM->getVout();
1015 /* Add a fullscreen switch button, since it is the most used function */
1018 vlc_value_t val; var_Get( p_vout, "fullscreen", &val );
1020 b_isFullscreen = !( !val.b_bool );
1021 if( b_isFullscreen )
1024 CreateAndConnect( menu, "fullscreen",
1025 qtr( "Leave Fullscreen" ),"" , ITEM_NORMAL,
1026 VLC_OBJECT(p_vout), val, VLC_VAR_BOOL, b_isFullscreen );
1028 vlc_object_release( p_vout );
1030 menu->addSeparator();
1034 InputAutoMenuBuilder( p_input, objects, varnames );
1037 submenu = new QMenu( menu );
1038 action = menu->addMenu( AudioMenu( p_intf, submenu ) );
1039 action->setText( qtr( "&Audio" ) );
1040 if( action->menu()->isEmpty() )
1041 action->setEnabled( false );
1044 submenu = new QMenu( menu );
1045 action = menu->addMenu( VideoMenu( p_intf, submenu ) );
1046 action->setText( qtr( "&Video" ) );
1047 if( action->menu()->isEmpty() )
1048 action->setEnabled( false );
1050 submenu = SubtitleMenu( p_intf, menu );
1051 submenu->setTitle( qtr( "Subti&tle") );
1052 UpdateItem( p_intf, menu, "spu-es", VLC_OBJECT(p_input), true );
1054 /* Playback menu for chapters */
1055 submenu = new QMenu( menu );
1056 action = menu->addMenu( NavigMenu( p_intf, submenu ) );
1057 action->setText( qtr( "&Playback" ) );
1058 if( action->menu()->isEmpty() )
1059 action->setEnabled( false );
1062 menu->addSeparator();
1064 /* Add some special entries for windowed mode: Interface Menu */
1065 if( !b_isFullscreen )
1067 QMenu *submenu = new QMenu( qtr( "T&ools" ), menu );
1068 /*QMenu *tools =*/ ToolsMenu( p_intf, submenu );
1069 submenu->addSeparator();
1071 /* In skins interface, append some items */
1074 submenu->setTitle( qtr( "Interface" ) );
1075 if( p_intf->p_sys->b_isDialogProvider )
1077 /* list of skins available */
1078 vlc_object_t* p_object = p_intf->p_parent;
1080 objects.clear(); varnames.clear();
1081 objects.append( p_object );
1082 varnames.append( "intf-skins" );
1083 Populate( p_intf, submenu, varnames, objects );
1085 objects.clear(); varnames.clear();
1086 objects.append( p_object );
1087 varnames.append( "intf-skins-interactive" );
1088 Populate( p_intf, submenu, varnames, objects );
1090 submenu->addSeparator();
1093 ExtensionsMenu( p_intf, submenu );
1097 msg_Warn( p_intf, "could not find parent interface" );
1101 QMenu *bar = menu; // Needed for next macro
1102 BAR_DADD( ViewMenu( p_intf, NULL, mi ), qtr( "V&iew" ), 4 );
1105 menu->addMenu( submenu );
1109 QMenuView *plMenu = new QMenuView( menu, 25 );
1110 plMenu->setTitle( qtr("Playlist") );
1111 PLModel *model = PLModel::getPLModel( p_intf );
1112 plMenu->setModel( model );
1113 CONNECT( plMenu, activated(const QModelIndex&),
1114 model, activateItem(const QModelIndex&));
1115 menu->addMenu( plMenu );
1117 /* Static entries for ending, like open */
1118 PopupMenuStaticEntries( menu );
1120 menu->popup( QCursor::pos() );
1124 #undef POPUP_BOILERPLATE
1127 /************************************************************************
1129 ************************************************************************/
1131 void VLCMenuBar::updateSystrayMenu( MainInterface *mi,
1132 intf_thread_t *p_intf,
1133 bool b_force_visible )
1135 input_thread_t *p_input = THEMIM->getInput();
1137 /* Get the systray menu and clean it */
1138 QMenu *sysMenu = mi->getSysTrayMenu();
1142 /* Hide / Show VLC and cone */
1143 if( mi->isVisible() || b_force_visible )
1145 sysMenu->addAction( QIcon( ":/logo/vlc16.png" ),
1146 qtr( "&Hide VLC media player in taskbar" ), mi,
1147 SLOT( hideUpdateSystrayMenu() ) );
1151 sysMenu->addAction( QIcon( ":/logo/vlc16.png" ),
1152 qtr( "Sho&w VLC media player" ), mi,
1153 SLOT( showUpdateSystrayMenu() ) );
1155 sysMenu->addSeparator();
1158 PopupMenuPlaylistEntries( sysMenu, p_intf, p_input );
1159 PopupMenuControlEntries( sysMenu, p_intf, false );
1161 VolumeEntries( p_intf, sysMenu );
1162 sysMenu->addSeparator();
1163 addDPStaticEntry( sysMenu, qtr( "&Open Media" ),
1164 ":/type/file-wide", SLOT( openFileDialog() ) );
1165 addDPStaticEntry( sysMenu, qtr( "&Quit" ) ,
1166 ":/menu/exit", SLOT( quit() ) );
1169 mi->getSysTray()->setContextMenu( sysMenu );
1175 /*************************************************************************
1176 * Builders for automenus
1177 *************************************************************************/
1178 QMenu * VLCMenuBar::Populate( intf_thread_t *p_intf,
1180 QVector< const char *> & varnames,
1181 QVector<vlc_object_t *> & objects )
1183 QMenu *menu = current;
1186 currentGroup = NULL;
1188 for( int i = 0; i < (int)objects.count() ; i++ )
1190 if( !varnames[i] || !*varnames[i] )
1192 menu->addSeparator();
1196 UpdateItem( p_intf, menu, varnames[i], objects[i], true );
1201 /*****************************************************************************
1203 *****************************************************************************/
1205 static bool IsMenuEmpty( const char *psz_var,
1206 vlc_object_t *p_object,
1207 bool b_root = true )
1209 vlc_value_t val, val_list;
1210 int i_type, i_result, i;
1212 /* Check the type of the object variable */
1213 i_type = var_Type( p_object, psz_var );
1215 /* Check if we want to display the variable */
1216 if( !( i_type & VLC_VAR_HASCHOICE ) ) return false;
1218 var_Change( p_object, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL );
1219 if( val.i_int == 0 ) return true;
1221 if( ( i_type & VLC_VAR_TYPE ) != VLC_VAR_VARIABLE )
1223 if( val.i_int == 1 && b_root ) return true;
1227 /* Check children variables in case of VLC_VAR_VARIABLE */
1228 if( var_Change( p_object, psz_var, VLC_VAR_GETLIST, &val_list, NULL ) < 0 )
1233 for( i = 0, i_result = true; i < val_list.p_list->i_count; i++ )
1235 if( !IsMenuEmpty( val_list.p_list->p_values[i].psz_string,
1243 /* clean up everything */
1244 var_FreeList( &val_list, NULL );
1249 #define TEXT_OR_VAR qfue ( text.psz_string ? text.psz_string : psz_var )
1251 void VLCMenuBar::UpdateItem( intf_thread_t *p_intf, QMenu *menu,
1252 const char *psz_var, vlc_object_t *p_object, bool b_submenu )
1254 vlc_value_t val, text;
1257 QAction *action = FindActionWithVar( menu, psz_var );
1259 DeleteNonStaticEntries( action->menu() );
1264 action->setEnabled( false );
1268 /* Check the type of the object variable */
1269 /* This HACK is needed so we have a radio button for audio and video tracks
1270 instread of a checkbox */
1271 if( !strcmp( psz_var, "audio-es" )
1272 || !strcmp( psz_var, "video-es" ) )
1273 i_type = VLC_VAR_INTEGER | VLC_VAR_HASCHOICE;
1275 i_type = var_Type( p_object, psz_var );
1277 switch( i_type & VLC_VAR_TYPE )
1281 case VLC_VAR_VARIABLE:
1282 case VLC_VAR_STRING:
1283 case VLC_VAR_INTEGER:
1287 /* Variable doesn't exist or isn't handled */
1289 action->setEnabled( false );
1293 /* Make sure we want to display the variable */
1294 if( menu->isEmpty() && IsMenuEmpty( psz_var, p_object ) )
1297 action->setEnabled( false );
1301 /* Get the descriptive name of the variable */
1302 int i_ret = var_Change( p_object, psz_var, VLC_VAR_GETTEXT, &text, NULL );
1303 if( i_ret != VLC_SUCCESS )
1305 text.psz_string = NULL;
1310 action = new QAction( TEXT_OR_VAR, menu );
1311 menu->addAction( action );
1312 action->setData( psz_var );
1315 /* Some specific stuff */
1316 bool forceDisabled = false;
1317 if( !strcmp( psz_var, "spu-es" ) )
1319 vout_thread_t *p_vout = THEMIM->getVout();
1320 forceDisabled = ( p_vout == NULL );
1322 vlc_object_release( p_vout );
1325 if( i_type & VLC_VAR_HASCHOICE )
1327 /* Append choices menu */
1331 submenu = action->menu();
1334 submenu = new QMenu( menu );
1335 action->setMenu( submenu );
1339 CreateChoicesMenu( submenu, psz_var, p_object, true ) == 0 );
1341 action->setEnabled( false );
1346 CreateChoicesMenu( menu, psz_var, p_object, true ) == 0 );
1348 FREENULL( text.psz_string );
1352 switch( i_type & VLC_VAR_TYPE )
1355 val.i_int = 0; // Prevent the copy of an uninitialized value
1356 CreateAndConnect( menu, psz_var, TEXT_OR_VAR, "", ITEM_NORMAL,
1357 p_object, val, i_type );
1361 var_Get( p_object, psz_var, &val );
1362 val.b_bool = !val.b_bool;
1363 CreateAndConnect( menu, psz_var, TEXT_OR_VAR, "", ITEM_CHECK,
1364 p_object, val, i_type, !val.b_bool );
1367 FREENULL( text.psz_string );
1372 /** HACK for the navigation submenu:
1373 * "title %2i" variables take the value 0 if not set
1375 static bool CheckTitle( vlc_object_t *p_object, const char *psz_var )
1378 if( sscanf( psz_var, "title %2i", &i_title ) <= 0 )
1381 int i_current_title = var_GetInteger( p_object, "title" );
1382 return ( i_title == i_current_title );
1386 int VLCMenuBar::CreateChoicesMenu( QMenu *submenu, const char *psz_var,
1387 vlc_object_t *p_object, bool b_root )
1389 vlc_value_t val, val_list, text_list;
1392 /* Check the type of the object variable */
1393 i_type = var_Type( p_object, psz_var );
1395 /* Make sure we want to display the variable */
1396 if( submenu->isEmpty() && IsMenuEmpty( psz_var, p_object, b_root ) )
1397 return VLC_EGENERIC;
1399 switch( i_type & VLC_VAR_TYPE )
1403 case VLC_VAR_VARIABLE:
1404 case VLC_VAR_STRING:
1405 case VLC_VAR_INTEGER:
1409 /* Variable doesn't exist or isn't handled */
1410 return VLC_EGENERIC;
1413 if( var_Change( p_object, psz_var, VLC_VAR_GETLIST,
1414 &val_list, &text_list ) < 0 )
1416 return VLC_EGENERIC;
1419 #define CURVAL val_list.p_list->p_values[i]
1420 #define CURTEXT text_list.p_list->p_values[i].psz_string
1421 #define RADIO_OR_COMMAND ( i_type & ( VLC_VAR_ISCOMMAND | VLC_VAR_HASCHOICE ) ) ? ITEM_RADIO : ITEM_NORMAL
1423 for( i = 0; i < val_list.p_list->i_count; i++ )
1425 vlc_value_t another_val;
1427 QMenu *subsubmenu = new QMenu( submenu );
1429 switch( i_type & VLC_VAR_TYPE )
1431 case VLC_VAR_VARIABLE:
1432 CreateChoicesMenu( subsubmenu, CURVAL.psz_string, p_object, false );
1433 subsubmenu->setTitle( qfue( CURTEXT ? CURTEXT :CURVAL.psz_string ) );
1434 submenu->addMenu( subsubmenu );
1437 case VLC_VAR_STRING:
1438 var_Get( p_object, psz_var, &val );
1439 another_val.psz_string = strdup( CURVAL.psz_string );
1440 menutext = qfue( CURTEXT ? CURTEXT : another_val.psz_string );
1441 CreateAndConnect( submenu, psz_var, menutext, "", RADIO_OR_COMMAND,
1442 p_object, another_val, i_type,
1443 val.psz_string && !strcmp( val.psz_string, CURVAL.psz_string ) );
1445 free( val.psz_string );
1448 case VLC_VAR_INTEGER:
1449 var_Get( p_object, psz_var, &val );
1450 if( CURTEXT ) menutext = qfue( CURTEXT );
1451 else menutext = QString::number( CURVAL.i_int );
1452 CreateAndConnect( submenu, psz_var, menutext, "", RADIO_OR_COMMAND,
1453 p_object, CURVAL, i_type,
1454 ( CURVAL.i_int == val.i_int )
1455 && CheckTitle( p_object, psz_var ) );
1459 var_Get( p_object, psz_var, &val );
1460 if( CURTEXT ) menutext = qfue( CURTEXT );
1461 else menutext.sprintf( "%.2f", CURVAL.f_float );
1462 CreateAndConnect( submenu, psz_var, menutext, "", RADIO_OR_COMMAND,
1463 p_object, CURVAL, i_type,
1464 CURVAL.f_float == val.f_float );
1471 currentGroup = NULL;
1473 /* clean up everything */
1474 var_FreeList( &val_list, &text_list );
1476 #undef RADIO_OR_COMMAND
1480 return submenu->isEmpty() ? VLC_EGENERIC : VLC_SUCCESS;
1483 void VLCMenuBar::CreateAndConnect( QMenu *menu, const char *psz_var,
1484 const QString& text, const QString& help,
1485 int i_item_type, vlc_object_t *p_obj,
1486 vlc_value_t val, int i_val_type,
1489 QAction *action = FindActionWithVar( menu, psz_var );
1494 action = new QAction( text, menu );
1495 menu->addAction( action );
1499 action->setToolTip( help );
1500 action->setEnabled( p_obj != NULL );
1502 if( i_item_type == ITEM_CHECK )
1504 action->setCheckable( true );
1506 else if( i_item_type == ITEM_RADIO )
1508 action->setCheckable( true );
1510 currentGroup = new QActionGroup( menu );
1511 currentGroup->addAction( action );
1514 action->setChecked( checked );
1516 MenuItemData *itemData = qFindChild<MenuItemData*>( action, QString() );
1518 itemData = new MenuItemData( action, p_obj, i_val_type, val, psz_var );
1520 /* remove previous signal-slot connection(s) if any */
1521 action->disconnect( );
1523 CONNECT( action, triggered(), THEDP->menusMapper, map() );
1524 THEDP->menusMapper->setMapping( action, itemData );
1527 menu->addAction( action );
1530 void VLCMenuBar::DoAction( QObject *data )
1532 MenuItemData *itemData = qobject_cast<MenuItemData *>( data );
1533 vlc_object_t *p_object = itemData->p_obj;
1534 if( p_object == NULL ) return;
1535 const char *var = itemData->psz_var;
1536 vlc_value_t val = itemData->val;
1538 /* Preserve settings across vouts via the playlist object: */
1539 if( !strcmp( var, "fullscreen" )
1540 || !strcmp( var, "video-on-top" ) )
1541 var_Set( pl_Get( p_object ), var, val );
1543 if ((var_Type( p_object, var) & VLC_VAR_CLASS) == VLC_VAR_VOID)
1544 var_TriggerCallback( p_object, var );
1546 var_Set( p_object, var, val );
1549 void VLCMenuBar::updateAudioDevice( intf_thread_t * p_intf, audio_output_t *p_aout, QMenu *current )
1551 char **ids, **names;
1558 int i_result = aout_DevicesList( p_aout, &ids, &names);
1559 selected = aout_DeviceGet( p_aout );
1561 QActionGroup *actionGroup = new QActionGroup(current);
1564 for( int i = 0; i < i_result; i++ )
1566 action = new QAction( qfue( names[i] ), NULL );
1567 action->setData( ids[i] );
1568 action->setCheckable( true );
1569 if( selected && !strcmp( ids[i], selected ) )
1570 action->setChecked( true );
1571 actionGroup->addAction( action );
1572 current->addAction( action );
1573 CONNECT(action, changed(), THEMIM->menusAudioMapper, map());
1574 THEMIM->menusAudioMapper->setMapping(action, ids[i]);
1583 void VLCMenuBar::updateRecents( intf_thread_t *p_intf )
1588 RecentsMRL* rmrl = RecentsMRL::getInstance( p_intf );
1589 QStringList l = rmrl->recents();
1591 recentsMenu->clear();
1595 recentsMenu->setEnabled( false );
1599 for( int i = 0; i < l.count(); ++i )
1601 QString mrl = l.at( i );
1602 char *psz = decode_URI_duplicate( qtu( mrl ) );
1603 QString text = qfu( psz );
1606 action = recentsMenu->addAction(
1607 QString( i < 9 ? "&%1: ": "%1: " ).arg( i + 1 ) +
1608 QApplication::fontMetrics().elidedText( text,
1609 Qt::ElideLeft, 400 ),
1610 rmrl->signalMapper, SLOT( map() ),
1611 i < 9 ? QString( "Ctrl+%1" ).arg( i + 1 ) : "" );
1612 rmrl->signalMapper->setMapping( action, l.at( i ) );
1615 recentsMenu->addSeparator();
1616 recentsMenu->addAction( qtr("&Clear"), rmrl, SLOT( clear() ) );
1617 recentsMenu->setEnabled( true );