]> git.sesse.net Git - vlc/blob - modules/gui/qt4/menus.cpp
Qt: Menus updates. Change position and removal of ...
[vlc] / modules / gui / qt4 / menus.cpp
1 /*****************************************************************************
2  * menus.cpp : Qt menus
3  *****************************************************************************
4  * Copyright © 2006-2008 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Clément Stenac <zorglub@videolan.org>
8  *          Jean-Baptiste Kempf <jb@videolan.org>
9  *          Jean-Philippe André <jpeg@videolan.org>
10  *
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.
15  *
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.
20  *
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  *****************************************************************************/
25
26 /** \todo
27  * - Remove static currentGroup
28  */
29
30 #ifdef HAVE_CONFIG_H
31 # include "config.h"
32 #endif
33
34 #include <vlc_intf_strings.h>
35 #include <vlc_services_discovery.h>
36
37 #include "menus.hpp"
38
39 #include "main_interface.hpp"    /* View modifications */
40 #include "dialogs_provider.hpp"  /* Dialogs display */
41 #include "input_manager.hpp"     /* Input Management */
42 #include "recents.hpp"           /* Recent Items */
43
44 #include <QMenu>
45 #include <QMenuBar>
46 #include <QAction>
47 #include <QActionGroup>
48 #include <QSignalMapper>
49 #include <QSystemTrayIcon>
50 #include <QList>
51
52 /*
53   This file defines the main menus and the pop-up menu (right-click menu)
54   and the systray menu (in that order in the file)
55
56   There are 3 menus that have to be rebuilt everytime there are called:
57   Audio, Video, Navigation
58   3 functions are building those menus: AudioMenu, VideoMenu, NavigMenu
59   and 3 functions associated are collecting the objects :
60   InputAutoMenuBuilder, AudioAutoMenuBuilder, VideoAutoMenuBuilder.
61
62   A QSignalMapper decides when to rebuild those menus cf MenuFunc in the .hpp
63   Just before one of those menus are aboutToShow(), they are rebuild.
64   */
65
66 enum
67 {
68     ITEM_NORMAL,
69     ITEM_CHECK,
70     ITEM_RADIO
71 };
72
73 static QActionGroup *currentGroup;
74
75 /* HACK for minimalView to go around a Qt bug/feature
76  * that doesn't update the QAction checked state when QMenu is hidden */
77 QAction *QVLCMenu::minimalViewAction = NULL;
78
79 QMenu *QVLCMenu::recentsMenu = NULL;
80
81 /****************************************************************************
82  * Menu code helpers:
83  ****************************************************************************
84  * Add static entries to DP in menus
85  ***************************************************************************/
86 void addDPStaticEntry( QMenu *menu,
87                        const QString text,
88                        const char *icon,
89                        const char *member,
90                        const char *shortcut = NULL )
91 {
92     QAction *action = NULL;
93     if( !EMPTY_STR( icon ) > 0 )
94     {
95         if( !EMPTY_STR( shortcut ) > 0 )
96             action = menu->addAction( QIcon( icon ), text, THEDP,
97                                       member, qtr( shortcut ) );
98         else
99             action = menu->addAction( QIcon( icon ), text, THEDP, member );
100     }
101     else
102     {
103         if( !EMPTY_STR( shortcut ) > 0 )
104             action = menu->addAction( text, THEDP, member, qtr( shortcut ) );
105         else
106             action = menu->addAction( text, THEDP, member );
107     }
108     action->setData( "_static_" );
109 }
110
111 void EnableDPStaticEntries( QMenu *menu, bool enable = true )
112 {
113     if( !menu ) return;
114
115     QAction *action;
116     foreach( action, menu->actions() )
117     {
118         if( action->data().toString() == "_static_" )
119             action->setEnabled( enable );
120     }
121 }
122
123 /**
124  * \return Number of static entries
125  */
126 int DeleteNonStaticEntries( QMenu *menu )
127 {
128     int i_ret = 0;
129     QAction *action;
130     if( !menu )
131         return VLC_EGENERIC;
132     foreach( action, menu->actions() )
133     {
134         if( action->data().toString() != "_static_" )
135             delete action;
136         else
137             i_ret++;
138     }
139     return i_ret;
140 }
141
142 /***
143  * Same for MIM
144  ***/
145 void addMIMStaticEntry( intf_thread_t *p_intf,
146                         QMenu *menu,
147                         const QString text,
148                         const char *icon,
149                         const char *member )
150 {
151     if( strlen( icon ) > 0 )
152     {
153         QAction *action = menu->addAction( text, THEMIM,  member );
154         action->setIcon( QIcon( icon ) );
155     }
156     else
157     {
158         menu->addAction( text, THEMIM, member );
159     }
160 }
161
162 /*****************************************************************************
163  * Definitions of variables for the dynamic menus
164  *****************************************************************************/
165 #define PUSH_VAR( var ) varnames.push_back( var ); \
166     objects.push_back( VLC_OBJECT(p_object) )
167
168 #define PUSH_INPUTVAR( var ) varnames.push_back( var ); \
169     objects.push_back( VLC_OBJECT(p_input) );
170
171 #define PUSH_SEPARATOR if( objects.size() != i_last_separator ) { \
172     objects.push_back( 0 ); varnames.push_back( "" ); \
173     i_last_separator = objects.size(); }
174
175 static int InputAutoMenuBuilder( input_thread_t *p_object,
176         vector<vlc_object_t *> &objects,
177         vector<const char *> &varnames )
178 {
179     PUSH_VAR( "bookmark" );
180     PUSH_VAR( "title" );
181     PUSH_VAR( "chapter" );
182     PUSH_VAR( "program" );
183     PUSH_VAR( "navigation" );
184     PUSH_VAR( "dvd_menus" );
185     return VLC_SUCCESS;
186 }
187
188 static int VideoAutoMenuBuilder( vout_thread_t *p_object,
189         input_thread_t *p_input,
190         vector<vlc_object_t *> &objects,
191         vector<const char *> &varnames )
192 {
193     PUSH_INPUTVAR( "video-es" );
194     PUSH_INPUTVAR( "spu-es" );
195     PUSH_VAR( "fullscreen" );
196     PUSH_VAR( "zoom" );
197     PUSH_VAR( "deinterlace" );
198     PUSH_VAR( "aspect-ratio" );
199     PUSH_VAR( "crop" );
200     PUSH_VAR( "video-on-top" );
201 #ifdef WIN32
202     PUSH_VAR( "directx-wallpaper" );
203 #endif
204     PUSH_VAR( "video-snapshot" );
205
206     /* Special case for postproc */
207     // FIXME
208     if( p_object )
209     {
210         /* p_object is the vout, so the decoder is our parent and the
211          * postproc filter one of the decoder's children */
212         vlc_object_t *p_dec = (vlc_object_t *)
213                               vlc_object_find( p_object, VLC_OBJECT_DECODER,
214                                                FIND_PARENT );
215         if( p_dec )
216         {
217             vlc_object_t *p_pp = (vlc_object_t *)
218                                  vlc_object_find_name( p_dec, "postproc",
219                                                        FIND_CHILD );
220             if( p_pp )
221             {
222                 vlc_object_t *p_object = p_pp;
223                 PUSH_VAR( "postproc-q" );
224                 vlc_object_release( p_pp );
225             }
226
227             vlc_object_release( p_dec );
228         }
229     }
230     return VLC_SUCCESS;
231 }
232
233 static int AudioAutoMenuBuilder( aout_instance_t *p_object,
234         input_thread_t *p_input,
235         vector<vlc_object_t *> &objects,
236         vector<const char *> &varnames )
237 {
238     PUSH_INPUTVAR( "audio-es" );
239     PUSH_VAR( "audio-device" );
240     PUSH_VAR( "audio-channels" );
241     PUSH_VAR( "visual" );
242     return VLC_SUCCESS;
243 }
244
245 static QAction * FindActionWithVar( QMenu *menu, const char *psz_var )
246 {
247     QAction *action;
248     foreach( action, menu->actions() )
249     {
250         if( action->data().toString() == psz_var )
251             return action;
252     }
253     return NULL;
254 }
255
256 /*****************************************************************************
257  * All normal menus
258  * Simple Code
259  *****************************************************************************/
260
261 #define BAR_ADD( func, title ) { \
262     QMenu *_menu = func; _menu->setTitle( title ); bar->addMenu( _menu ); }
263
264 #define BAR_DADD( func, title, id ) { \
265     QMenu *_menu = func; _menu->setTitle( title ); bar->addMenu( _menu ); \
266     MenuFunc *f = new MenuFunc( _menu, id ); \
267     CONNECT( _menu, aboutToShow(), THEDP->menusUpdateMapper, map() ); \
268     THEDP->menusUpdateMapper->setMapping( _menu, f ); }
269
270 #define ACT_ADD( _menu, val, title ) { \
271     QAction *_action = new QAction( title, _menu ); _action->setData( val ); \
272     _menu->addAction( _action ); }
273
274 /**
275  * Main Menu Bar Creation
276  **/
277 void QVLCMenu::createMenuBar( MainInterface *mi,
278                               intf_thread_t *p_intf,
279                               bool visual_selector_enabled )
280 /* FIXME remove this visual dependency */
281 {
282     /* QMainWindows->menuBar()
283        gives the QProcess::destroyed timeout issue on Cleanlooks style with
284        setDesktopAware set to false */
285     QMenuBar *bar = mi->menuBar();
286     BAR_ADD( FileMenu( p_intf ), qtr( "&Media" ) );
287
288     BAR_DADD( AudioMenu( p_intf, NULL ), qtr( "&Audio" ), 1 );
289     BAR_DADD( VideoMenu( p_intf, NULL ), qtr( "&Video" ), 2 );
290     BAR_DADD( NavigMenu( p_intf, NULL ), qtr( "P&layback" ), 3 );
291
292     BAR_ADD( ToolsMenu( p_intf ), qtr( "&Tools" ) );
293     BAR_ADD( ViewMenu( p_intf, NULL, mi, visual_selector_enabled, true ),
294              qtr( "V&iew" ) );
295
296     BAR_ADD( HelpMenu( NULL ), qtr( "&Help" ) );
297 }
298 #undef BAR_ADD
299 #undef BAR_DADD
300
301 /**
302  * Media ( File ) Menu
303  * Opening, streaming and quit
304  **/
305 QMenu *QVLCMenu::FileMenu( intf_thread_t *p_intf )
306 {
307     QMenu *menu = new QMenu();
308
309     addDPStaticEntry( menu, qtr( "&Open File..." ),
310 #ifdef WIN32
311         ":/file-asym", SLOT( simpleOpenDialog() ), "Ctrl+O" );
312     addDPStaticEntry( menu, qtr( "Advanced Open File..." ),
313         ":/file-asym", SLOT( openFileDialog() ) );
314 #else
315         ":/file-asym", SLOT( openFileDialog() ), "Ctrl+O" );
316 #endif
317     addDPStaticEntry( menu, qtr( "Open &URL" ),
318                       NULL, SLOT( openUrlDialog() ), "Ctrl+V" );
319     addDPStaticEntry( menu, qtr( I_OPEN_FOLDER ),
320         ":/folder-grey", SLOT( PLOpenDir() ), "Ctrl+F" );
321     addDPStaticEntry( menu, qtr( "Open &Disc..." ),
322         ":/disc", SLOT( openDiscDialog() ), "Ctrl+D" );
323     addDPStaticEntry( menu, qtr( "Open &Network..." ),
324         ":/network", SLOT( openNetDialog() ), "Ctrl+N" );
325     addDPStaticEntry( menu, qtr( "Open &Capture Device..." ),
326         ":/capture-card", SLOT( openCaptureDialog() ),
327         "Ctrl+C" );
328
329     menu->addSeparator();
330
331     addDPStaticEntry( menu, qtr( I_PL_LOAD ), "", SLOT( openAPlaylist() ),
332         "Ctrl+X" );
333     addDPStaticEntry( menu, qtr( I_PL_SAVE ), "", SLOT( saveAPlaylist() ),
334         "Ctrl+Y" );
335
336     menu->addSeparator();
337
338     recentsMenu = new QMenu( qtr( "Recently &Played" ), menu );
339     updateRecents( p_intf );
340     menu->addMenu( recentsMenu );
341     menu->addSeparator();
342
343     addDPStaticEntry( menu, qtr( "Conve&rt / Save..." ), "",
344         SLOT( openAndTranscodingDialogs() ), "Ctrl+R" );
345     addDPStaticEntry( menu, qtr( "&Streaming..." ),
346         ":/stream", SLOT( openAndStreamingDialogs() ),
347         "Ctrl+S" );
348     menu->addSeparator();
349
350     addDPStaticEntry( menu, qtr( "&Quit" ) ,
351         ":/quit", SLOT( quit() ), "Ctrl+Q" );
352     return menu;
353 }
354
355 /* Playlist/MediaLibrary Control */
356 QMenu *QVLCMenu::ToolsMenu( intf_thread_t *p_intf )
357 {
358     VLC_UNUSED( p_intf ); //TODO remove
359     QMenu *menu = new QMenu();
360
361     addDPStaticEntry( menu, qtr( I_MENU_EXT ), ":/settings",
362             SLOT( extendedDialog() ), "Ctrl+E" );
363
364     addDPStaticEntry( menu, qtr( I_MENU_INFO ) , ":/info",
365         SLOT( mediaInfoDialog() ), "Ctrl+I" );
366     addDPStaticEntry( menu, qtr( I_MENU_CODECINFO ) ,
367         ":/info", SLOT( mediaCodecDialog() ), "Ctrl+J" );
368
369     addDPStaticEntry( menu, qtr( I_MENU_BOOKMARK ),"",
370                       SLOT( bookmarksDialog() ), "Ctrl+B" );
371 #ifdef ENABLE_VLM
372     addDPStaticEntry( menu, qtr( I_MENU_VLM ), "", SLOT( vlmDialog() ),
373         "Ctrl+W" );
374 #endif
375
376     addDPStaticEntry( menu, qtr( I_MENU_MSG ),
377         ":/messages", SLOT( messagesDialog() ),
378         "Ctrl+M" );
379
380     addDPStaticEntry( menu, qtr( "Plu&gins and extensions" ),
381         "", SLOT( pluginDialog() ) );
382     menu->addSeparator();
383
384     addDPStaticEntry( menu, qtr( "Customi&ze Interface..." ),
385         ":/preferences", SLOT( toolbarDialog() ) );
386     addDPStaticEntry( menu, qtr( "&Preferences" ),
387         ":/preferences", SLOT( prefsDialog() ), "Ctrl+P" );
388
389     return menu;
390 }
391
392 /**
393  * Tools/View Menu
394  * This is kept in the same menu for now, but could change if it gets much
395  * longer.
396  * This menu can be an interface menu but also a right click menu.
397  **/
398 QMenu *QVLCMenu::ViewMenu( intf_thread_t *p_intf,
399                             QMenu *current,
400                             MainInterface *mi,
401                             bool visual_selector_enabled,
402                             bool with_intf )
403 {
404     QMenu *menu = new QMenu( current );
405     QAction *act;
406     if( mi )
407     {
408         act = menu->addAction( QIcon( ":/playlist_menu" ),
409                                qtr( "Play&list..." ), mi,
410                                SLOT( togglePlaylist() ), qtr( "Ctrl+L" ) );
411         act->setData( "_static_" );
412     }
413     act = menu->addMenu( SDMenu( p_intf ) );
414     act->setData( "_static_" );
415     /*menu->addSeparator();
416     menu->addAction( qtr( "Undock from Interface" ), mi,
417                      SLOT( undockPlaylist() ), qtr( "Ctrl+U" ) );*/
418
419
420     menu->addSeparator();
421
422     if( with_intf )
423     {
424         QMenu *intfmenu = InterfacesMenu( p_intf, menu );
425         MenuFunc *f = new MenuFunc( intfmenu, 4 );
426         CONNECT( intfmenu, aboutToShow(), THEDP->menusUpdateMapper, map() );
427         THEDP->menusUpdateMapper->setMapping( intfmenu, f );
428         menu->addSeparator();
429     }
430     if( mi )
431     {
432         /* Minimal View */
433         QAction *action = menu->addAction( qtr( "Mi&nimal View" ), mi,
434                                 SLOT( toggleMinimalView() ), qtr( "Ctrl+H" ) );
435         action->setCheckable( true );
436         action->setData( "_static_" );
437         if( mi->getControlsVisibilityStatus() & CONTROLS_VISIBLE )
438             action->setChecked( true );
439         minimalViewAction = action; /* HACK for minimalView */
440
441         /* FullScreen View */
442         action = menu->addAction( qtr( "&Fullscreen Interface" ), mi,
443                                   SLOT( toggleFullScreen() ), QString( "F11" ) );
444         action->setCheckable( true );
445         action->setData( "_static_" );
446
447         /* Advanced Controls */
448         action = menu->addAction( qtr( "&Advanced Controls" ), mi,
449                                   SLOT( toggleAdvanced() ) );
450         action->setCheckable( true );
451         action->setData( "_static_" );
452         if( mi->getControlsVisibilityStatus() & CONTROLS_ADVANCED )
453             action->setChecked( true );
454 #if 0 /* For Visualisations. Not yet working */
455         adv = menu->addAction( qtr( "Visualizations selector" ),
456                 mi, SLOT( visual() ) );
457         adv->setCheckable( true );
458         if( visual_selector_enabled ) adv->setChecked( true );
459 #endif
460     }
461
462     menu->addSeparator();
463
464     return menu;
465 }
466
467 /**
468  * Interface Sub-Menu, to list extras interface and skins
469  **/
470 QMenu *QVLCMenu::InterfacesMenu( intf_thread_t *p_intf, QMenu *current )
471 {
472     vector<vlc_object_t *> objects;
473     vector<const char *> varnames;
474     /** \todo add "switch to XXX" */
475     varnames.push_back( "intf-add" );
476     objects.push_back( VLC_OBJECT(p_intf) );
477
478     return Populate( p_intf, current, varnames, objects );
479 }
480
481 /**
482  * Main Audio Menu
483  */
484 QMenu *QVLCMenu::AudioMenu( intf_thread_t *p_intf, QMenu * current )
485 {
486     vector<vlc_object_t *> objects;
487     vector<const char *> varnames;
488     aout_instance_t *p_aout;
489     input_thread_t *p_input;
490
491     if( !current ) current = new QMenu();
492
493     if( current->isEmpty() )
494     {
495         ACT_ADD( current, "audio-es", qtr( "Audio &Track" ) );
496         ACT_ADD( current, "audio-device", qtr( "Audio &Device" ) );
497         ACT_ADD( current, "audio-channels", qtr( "Audio &Channels" ) );
498         current->addSeparator();
499         ACT_ADD( current, "visual", qtr( "&Visualizations" ) );
500     }
501
502     p_input = THEMIM->getInput();
503     if( p_input )
504         vlc_object_hold( p_input );
505     p_aout = THEMIM->getAout();
506     if( p_aout )
507     {
508         AudioAutoMenuBuilder( p_aout, p_input, objects, varnames );
509         vlc_object_release( p_aout );
510     }
511     if( p_input )
512         vlc_object_release( p_input );
513
514     return Populate( p_intf, current, varnames, objects );
515 }
516
517 /**
518  * Main Video Menu
519  * Subtitles are part of Video.
520  **/
521 QMenu *QVLCMenu::VideoMenu( intf_thread_t *p_intf, QMenu *current )
522 {
523     vout_thread_t *p_vout;
524     input_thread_t *p_input;
525     vector<vlc_object_t *> objects;
526     vector<const char *> varnames;
527
528     if( !current ) current = new QMenu();
529
530     if( current->isEmpty() )
531     {
532         ACT_ADD( current, "video-es", qtr( "Video &Track" ) );
533
534         QAction *action;
535         QMenu *submenu = new QMenu( qtr( "&Subtitles Track" ), current );
536         action = current->addMenu( submenu );
537         action->setData( "spu-es" );
538         addDPStaticEntry( submenu, qtr( "Open File..." ), "",
539                           SLOT( loadSubtitlesFile() ) );
540         submenu->addSeparator();
541
542         ACT_ADD( current, "fullscreen", qtr( "&Fullscreen" ) );
543         ACT_ADD( current, "zoom", qtr( "&Zoom" ) );
544         ACT_ADD( current, "deinterlace", qtr( "&Deinterlace" ) );
545         ACT_ADD( current, "aspect-ratio", qtr( "&Aspect Ratio" ) );
546         ACT_ADD( current, "crop", qtr( "&Crop" ) );
547         ACT_ADD( current, "video-on-top", qtr( "Always &On Top" ) );
548 #ifdef WIN32
549         ACT_ADD( current, "directx-wallpaper", qtr( "DirectX Wallpaper" ) );
550 #endif
551         ACT_ADD( current, "video-snapshot", qtr( "Sna&pshot" ) );
552         ACT_ADD( current, "postproc-q", qtr( "Post processing" ) );
553     }
554
555     p_input = THEMIM->getInput();
556     if( p_input )
557         vlc_object_hold( p_input );
558
559     p_vout = THEMIM->getVout();
560     if( p_vout )
561     {
562         VideoAutoMenuBuilder( p_vout, p_input, objects, varnames );
563         vlc_object_release( p_vout );
564     }
565     if( p_input )
566         vlc_object_release( p_input );
567
568     return Populate( p_intf, current, varnames, objects );
569 }
570
571 /**
572  * Navigation Menu
573  * For DVD, MP4, MOV and other chapter based format
574  **/
575 QMenu *QVLCMenu::NavigMenu( intf_thread_t *p_intf, QMenu *menu )
576 {
577     if( !menu ) menu = new QMenu();
578
579     if( menu->isEmpty() )
580     {
581         addDPStaticEntry( menu, qtr( I_MENU_GOTOTIME ),"",
582                           SLOT( gotoTimeDialog() ), "Ctrl+T" );
583         menu->addSeparator();
584
585         ACT_ADD( menu, "bookmark", qtr( "&Bookmarks" ) );
586         ACT_ADD( menu, "title", qtr( "T&itle" ) );
587         ACT_ADD( menu, "chapter", qtr( "&Chapter" ) );
588         ACT_ADD( menu, "program", qtr( "&Program" ) );
589         ACT_ADD( menu, "navigation", qtr( "&Navigation" ) );
590     }
591
592     input_thread_t *p_object;
593     vector<vlc_object_t *> objects;
594     vector<const char *> varnames;
595
596     p_object = THEMIM->getInput();
597     if( p_object )
598         vlc_object_hold( p_object );
599     InputAutoMenuBuilder( p_object, objects, varnames );
600     PUSH_VAR( "prev-title" );
601     PUSH_VAR( "next-title" );
602     PUSH_VAR( "prev-chapter" );
603     PUSH_VAR( "next-chapter" );
604     EnableDPStaticEntries( menu, ( p_object != NULL ) );
605     if( p_object )
606     {
607         vlc_object_release( p_object );
608     }
609     return Populate( p_intf, menu, varnames, objects );
610 }
611
612 /**
613  * Service Discovery SubMenu
614  **/
615 QMenu *QVLCMenu::SDMenu( intf_thread_t *p_intf )
616 {
617     QMenu *menu = new QMenu();
618     menu->setTitle( qtr( I_PL_SD ) );
619     char **ppsz_longnames;
620     char **ppsz_names = vlc_sd_GetNames( &ppsz_longnames );
621     if( !ppsz_names )
622         return menu;
623
624     char **ppsz_name = ppsz_names, **ppsz_longname = ppsz_longnames;
625     for( ; *ppsz_name; ppsz_name++, ppsz_longname++ )
626     {
627         QAction *a = new QAction( qfu( *ppsz_longname ), menu );
628         a->setCheckable( true );
629         if( playlist_IsServicesDiscoveryLoaded( THEPL, *ppsz_name ) )
630             a->setChecked( true );
631         CONNECT( a , triggered(), THEDP->SDMapper, map() );
632         THEDP->SDMapper->setMapping( a, QString( *ppsz_name ) );
633         menu->addAction( a );
634
635         if( !strcmp( *ppsz_name, "podcast" ) )
636         {
637             QAction *b = new QAction( qtr( "Configure podcasts..." ), menu );
638             //b->setEnabled( a->isChecked() );
639             menu->addAction( b );
640             CONNECT( b, triggered(), THEDP, podcastConfigureDialog() );
641         }
642         free( *ppsz_name );
643         free( *ppsz_longname );
644     }
645     free( ppsz_names );
646     free( ppsz_longnames );
647     return menu;
648 }
649 /**
650  * Help/About Menu
651 **/
652 QMenu *QVLCMenu::HelpMenu( QMenu *current )
653 {
654     QMenu *menu = new QMenu( current );
655     addDPStaticEntry( menu, qtr( "&Help..." ) ,
656         ":/help", SLOT( helpDialog() ), "F1" );
657 #ifdef UPDATE_CHECK
658     addDPStaticEntry( menu, qtr( "Check for &Updates..." ) , "",
659                       SLOT( updateDialog() ) );
660 #endif
661     menu->addSeparator();
662     addDPStaticEntry( menu, qtr( I_MENU_ABOUT ), ":/info",
663             SLOT( aboutDialog() ), "Shift+F1" );
664     return menu;
665 }
666
667 /*****************************************************************************
668  * Popup menus - Right Click menus                                           *
669  *****************************************************************************/
670 #define POPUP_BOILERPLATE \
671     unsigned int i_last_separator = 0; \
672     vector<vlc_object_t *> objects; \
673     vector<const char *> varnames; \
674     input_thread_t *p_input = THEMIM->getInput();
675
676 #define CREATE_POPUP \
677     Populate( p_intf, menu, varnames, objects ); \
678     p_intf->p_sys->p_popup_menu = menu; \
679     menu->popup( QCursor::pos() ); \
680     p_intf->p_sys->p_popup_menu = NULL; \
681     i_last_separator = 0;
682
683 void QVLCMenu::PopupMenuControlEntries( QMenu *menu,
684                                         intf_thread_t *p_intf,
685                                         input_thread_t *p_input )
686 {
687     if( p_input )
688     {
689         vlc_value_t val;
690         var_Get( p_input, "state", &val );
691         if( val.i_int == PLAYING_S )
692             addMIMStaticEntry( p_intf, menu, qtr( "Pause" ),
693                     ":/pause", SLOT( togglePlayPause() ) );
694         else
695             addMIMStaticEntry( p_intf, menu, qtr( "Play" ),
696                     ":/play", SLOT( togglePlayPause() ) );
697     }
698     else if( THEPL->items.i_size )
699         addMIMStaticEntry( p_intf, menu, qtr( "Play" ),
700                 ":/play", SLOT( togglePlayPause() ) );
701     else
702         addDPStaticEntry( menu, qtr( "Play" ),
703                 ":/play", SLOT( openDialog() ) );
704
705     addMIMStaticEntry( p_intf, menu, qtr( "Stop" ),
706             ":/stop", SLOT( stop() ) );
707     addMIMStaticEntry( p_intf, menu, qtr( "Previous" ),
708             ":/previous", SLOT( prev() ) );
709     addMIMStaticEntry( p_intf, menu, qtr( "Next" ),
710             ":/next", SLOT( next() ) );
711 }
712
713 void QVLCMenu::PopupMenuStaticEntries( QMenu *menu )
714 {
715 #if 0
716     QMenu *toolsmenu = ToolsMenu( p_intf, menu, false, true );
717     toolsmenu->setTitle( qtr( "Tools" ) );
718     menu->addMenu( toolsmenu );
719 #endif
720
721     QMenu *openmenu = new QMenu( qtr( "Open Media" ), menu );
722     addDPStaticEntry( openmenu, qtr( "&Open File..." ),
723         ":/file-asym", SLOT( openFileDialog() ) );
724     addDPStaticEntry( openmenu, qtr( I_OPEN_FOLDER ),
725         ":/folder-grey", SLOT( PLOpenDir() ) );
726     addDPStaticEntry( openmenu, qtr( "Open &Disc..." ),
727         ":/disc", SLOT( openDiscDialog() ) );
728     addDPStaticEntry( openmenu, qtr( "Open &Network..." ),
729         ":/network", SLOT( openNetDialog() ) );
730     addDPStaticEntry( openmenu, qtr( "Open &Capture Device..." ),
731         ":/capture-card", SLOT( openCaptureDialog() ) );
732     menu->addMenu( openmenu );
733
734     menu->addSeparator();
735 #if 0
736     QMenu *helpmenu = HelpMenu( menu );
737     helpmenu->setTitle( qtr( "Help" ) );
738     menu->addMenu( helpmenu );
739 #endif
740
741     addDPStaticEntry( menu, qtr( "Quit" ), ":/quit",
742                       SLOT( quit() ), "Ctrl+Q" );
743 }
744
745 /* Video Tracks and Subtitles tracks */
746 void QVLCMenu::VideoPopupMenu( intf_thread_t *p_intf )
747 {
748     POPUP_BOILERPLATE;
749     if( p_input )
750     {
751         vlc_object_hold( p_input );
752         vout_thread_t *p_vout = THEMIM->getVout();
753         if( p_vout )
754         {
755             VideoAutoMenuBuilder( p_vout, p_input, objects, varnames );
756             vlc_object_release( p_vout );
757         }
758         vlc_object_release( p_input );
759     }
760     QMenu *menu = new QMenu();
761     CREATE_POPUP;
762 }
763
764 /* Audio Tracks */
765 void QVLCMenu::AudioPopupMenu( intf_thread_t *p_intf )
766 {
767     POPUP_BOILERPLATE;
768     if( p_input )
769     {
770         vlc_object_hold( p_input );
771         aout_instance_t *p_aout = THEMIM->getAout();
772         AudioAutoMenuBuilder( p_aout, p_input, objects, varnames );
773         if( p_aout )
774             vlc_object_release( p_aout );
775         vlc_object_release( p_input );
776     }
777     QMenu *menu = new QMenu();
778     CREATE_POPUP;
779 }
780
781 /* Navigation stuff, and general menus ( open ) */
782 void QVLCMenu::MiscPopupMenu( intf_thread_t *p_intf )
783 {
784     POPUP_BOILERPLATE;
785
786     if( p_input )
787     {
788         vlc_object_hold( p_input );
789         varnames.push_back( "audio-es" );
790         InputAutoMenuBuilder( p_input, objects, varnames );
791         PUSH_SEPARATOR;
792     }
793
794     QMenu *menu = new QMenu();
795     Populate( p_intf, menu, varnames, objects );
796
797     menu->addSeparator();
798     PopupMenuControlEntries( menu, p_intf, p_input );
799
800     menu->addSeparator();
801     PopupMenuStaticEntries( menu );
802
803     p_intf->p_sys->p_popup_menu = menu;
804     menu->popup( QCursor::pos() );
805     p_intf->p_sys->p_popup_menu = NULL;
806 }
807
808 /* Main Menu that sticks everything together  */
809 void QVLCMenu::PopupMenu( intf_thread_t *p_intf, bool show )
810 {
811     MainInterface *mi = p_intf->p_sys->p_mi;
812     if( show )
813     {
814         /* Delete and recreate a popup if there is one */
815         if( p_intf->p_sys->p_popup_menu )
816             delete p_intf->p_sys->p_popup_menu;
817
818         QMenu *menu = new QMenu();
819         QMenu *submenu;
820         QAction *action;
821         bool b_isFullscreen = false;
822
823         POPUP_BOILERPLATE;
824
825         PopupMenuControlEntries( menu, p_intf, p_input );
826         menu->addSeparator();
827
828         if( p_input )
829         {
830             vout_thread_t *p_vout = THEMIM->getVout();
831
832             /* Add a fullscreen switch button */
833             if( p_vout )
834             {
835                 vlc_value_t val;
836                 var_Get( p_vout, "fullscreen", &val );
837                 b_isFullscreen = !( !val.b_bool );
838                 if( b_isFullscreen )
839                     CreateAndConnect( menu, "fullscreen",
840                             qtr( "Leave Fullscreen" ),"" , ITEM_NORMAL,
841                             VLC_OBJECT(p_vout), val, VLC_VAR_BOOL,
842                             b_isFullscreen );
843                 vlc_object_release( p_vout );
844             }
845
846             menu->addSeparator();
847
848             vlc_object_hold( p_input );
849             InputAutoMenuBuilder( p_input, objects, varnames );
850             vlc_object_release( p_input );
851
852             submenu = new QMenu( menu );
853             action = menu->addMenu( AudioMenu( p_intf, submenu ) );
854             action->setText( qtr( "&Audio" ) );
855             if( action->menu()->isEmpty() )
856                 action->setEnabled( false );
857
858             submenu = new QMenu( menu );
859             action = menu->addMenu( VideoMenu( p_intf, submenu ) );
860             action->setText( qtr( "&Video" ) );
861             if( action->menu()->isEmpty() )
862                 action->setEnabled( false );
863
864             submenu = new QMenu( menu );
865             action = menu->addMenu( NavigMenu( p_intf, submenu ) );
866             action->setText( qtr( "&Playback" ) );
867             if( action->menu()->isEmpty() )
868                 action->setEnabled( false );
869         }
870
871         menu->addSeparator();
872
873         /* Add some special entries for windowed mode: Interface Menu */
874         if( !b_isFullscreen )
875         {
876             submenu = new QMenu( qtr( "Interface" ), menu );
877             if( mi )
878             {
879                 submenu->addAction( QIcon( ":/playlist" ),
880                          qtr( "Show Playlist" ), mi, SLOT( togglePlaylist() ) );
881             }
882             addDPStaticEntry( submenu, qtr( I_MENU_EXT ),
883                 ":/settings", SLOT( extendedDialog() ) );
884             addDPStaticEntry( submenu, qtr( I_MENU_INFO ) , ":/info",
885                 SLOT( mediaInfoDialog() ), "Ctrl+I" );
886             if( mi )
887             {
888                 action = submenu->addAction( QIcon( "" ),
889                      qtr( "Minimal View" ), mi, SLOT( toggleMinimalView() ) );
890                 action->setCheckable( true );
891                 action->setChecked( !( mi->getControlsVisibilityStatus() &
892                             CONTROLS_VISIBLE ) );
893                 action = submenu->addAction( QIcon( "" ),
894                         qtr( "Toggle Fullscreen Interface" ),
895                         mi, SLOT( toggleFullScreen() ) );
896                 action->setCheckable( true );
897                 action->setChecked( mi->isFullScreen() );
898             }
899             else /* We are using the skins interface.
900                     If not, this entry will not show. */
901             {
902                 addDPStaticEntry( submenu, qtr( "&Preferences..." ),
903                     ":/preferences", SLOT( prefsDialog() ), "Ctrl+P" );
904                 submenu->addSeparator();
905                 objects.clear();
906                 varnames.clear();
907                 vlc_object_t *p_object = ( vlc_object_t* )
908                      vlc_object_find_name( p_intf, "skins2", FIND_PARENT );
909                 if( p_object )
910                 {
911                     objects.push_back( p_object );
912                     varnames.push_back( "intf-skins" );
913                     Populate( p_intf, submenu, varnames, objects );
914                     vlc_object_release( p_object );
915                 }
916                 else
917                 {
918                     msg_Dbg( p_intf, "could not find parent interface" );
919                 }
920             }
921             menu->addMenu( submenu );
922         }
923
924         PopupMenuStaticEntries( menu );
925
926         p_intf->p_sys->p_popup_menu = menu;
927         p_intf->p_sys->p_popup_menu->popup( QCursor::pos() );
928     }
929     else
930     {
931         // destroy popup if there is one
932         delete p_intf->p_sys->p_popup_menu;
933         p_intf->p_sys->p_popup_menu = NULL;
934     }
935 }
936
937 #undef ACT_ADD
938
939 /************************************************************************
940  * Systray Menu                                                         *
941  ************************************************************************/
942
943 void QVLCMenu::updateSystrayMenu( MainInterface *mi,
944                                   intf_thread_t *p_intf,
945                                   bool b_force_visible )
946 {
947     POPUP_BOILERPLATE;
948
949     /* Get the systray menu and clean it */
950     QMenu *sysMenu = mi->getSysTrayMenu();
951     sysMenu->clear();
952
953     /* Hide / Show VLC and cone */
954     if( mi->isVisible() || b_force_visible )
955     {
956         sysMenu->addAction( QIcon( ":/vlc16.png" ),
957                             qtr( "Hide VLC media player in taskbar" ), mi,
958                             SLOT( toggleUpdateSystrayMenu() ) );
959     }
960     else
961     {
962         sysMenu->addAction( QIcon( ":/vlc16.png" ),
963                             qtr( "Show VLC media player" ), mi,
964                             SLOT( toggleUpdateSystrayMenu() ) );
965     }
966
967     sysMenu->addSeparator();
968     PopupMenuControlEntries( sysMenu, p_intf, p_input );
969
970     sysMenu->addSeparator();
971     addDPStaticEntry( sysMenu, qtr( "&Open Media" ),
972             ":/file-wide", SLOT( openFileDialog() ) );
973     addDPStaticEntry( sysMenu, qtr( "&Quit" ) ,
974             ":/quit", SLOT( quit() ) );
975
976     /* Set the menu */
977     mi->getSysTray()->setContextMenu( sysMenu );
978 }
979
980 #undef PUSH_VAR
981 #undef PUSH_SEPARATOR
982
983 /*************************************************************************
984  * Builders for automenus
985  *************************************************************************/
986 QMenu * QVLCMenu::Populate( intf_thread_t *p_intf,
987                             QMenu *current,
988                             vector< const char *> & varnames,
989                             vector<vlc_object_t *> & objects )
990 {
991     QMenu *menu = current;
992     if( !menu ) menu = new QMenu();
993
994     /* Disable all non static entries */
995     QAction *p_action;
996     foreach( p_action, menu->actions() )
997     {
998         if( p_action->data().toString() != "_static_" )
999             p_action->setEnabled( false );
1000     }
1001
1002     currentGroup = NULL;
1003
1004     vlc_object_t *p_object;
1005     int i;
1006
1007     for( i = 0; i < ( int )objects.size() ; i++ )
1008     {
1009         if( !varnames[i] || !*varnames[i] )
1010         {
1011             menu->addSeparator();
1012             continue;
1013         }
1014         p_object = objects[i];
1015
1016         UpdateItem( p_intf, menu, varnames[i], p_object, true );
1017     }
1018     return menu;
1019 }
1020
1021 /*****************************************************************************
1022  * Private methods.
1023  *****************************************************************************/
1024
1025 static bool IsMenuEmpty( const char *psz_var,
1026                          vlc_object_t *p_object,
1027                          bool b_root = true )
1028 {
1029     vlc_value_t val, val_list;
1030     int i_type, i_result, i;
1031
1032     /* Check the type of the object variable */
1033     i_type = var_Type( p_object, psz_var );
1034
1035     /* Check if we want to display the variable */
1036     if( !( i_type & VLC_VAR_HASCHOICE ) ) return false;
1037
1038     var_Change( p_object, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL );
1039     if( val.i_int == 0 ) return true;
1040
1041     if( ( i_type & VLC_VAR_TYPE ) != VLC_VAR_VARIABLE )
1042     {
1043         if( val.i_int == 1 && b_root ) return true;
1044         else return false;
1045     }
1046
1047     /* Check children variables in case of VLC_VAR_VARIABLE */
1048     if( var_Change( p_object, psz_var, VLC_VAR_GETLIST, &val_list, NULL ) < 0 )
1049     {
1050         return true;
1051     }
1052
1053     for( i = 0, i_result = true; i < val_list.p_list->i_count; i++ )
1054     {
1055         if( !IsMenuEmpty( val_list.p_list->p_values[i].psz_string,
1056                     p_object, false ) )
1057         {
1058             i_result = false;
1059             break;
1060         }
1061     }
1062
1063     /* clean up everything */
1064     var_Change( p_object, psz_var, VLC_VAR_FREELIST, &val_list, NULL );
1065
1066     return i_result;
1067 }
1068
1069 #define TEXT_OR_VAR qfu ( text.psz_string ? text.psz_string : psz_var )
1070
1071 void QVLCMenu::UpdateItem( intf_thread_t *p_intf, QMenu *menu,
1072         const char *psz_var, vlc_object_t *p_object, bool b_submenu )
1073 {
1074     vlc_value_t val, text;
1075     int i_type;
1076
1077     QAction *action = FindActionWithVar( menu, psz_var );
1078     if( action )
1079         DeleteNonStaticEntries( action->menu() );
1080
1081     if( !p_object )
1082         return;
1083
1084     /* Check the type of the object variable */
1085     if( !strcmp( psz_var, "audio-es" )
1086      || !strcmp( psz_var, "video-es" )
1087      || !strcmp( psz_var, "postproc-q" ) )
1088         i_type = VLC_VAR_INTEGER | VLC_VAR_HASCHOICE;
1089     else
1090         i_type = var_Type( p_object, psz_var );
1091
1092     switch( i_type & VLC_VAR_TYPE )
1093     {
1094         case VLC_VAR_VOID:
1095         case VLC_VAR_BOOL:
1096         case VLC_VAR_VARIABLE:
1097         case VLC_VAR_STRING:
1098         case VLC_VAR_INTEGER:
1099         case VLC_VAR_FLOAT:
1100             break;
1101         default:
1102             /* Variable doesn't exist or isn't handled */
1103             return;
1104     }
1105
1106     /* Make sure we want to display the variable */
1107     if( menu->isEmpty() && IsMenuEmpty( psz_var, p_object ) )
1108         return;
1109
1110     /* Get the descriptive name of the variable */
1111     int i_ret = var_Change( p_object, psz_var, VLC_VAR_GETTEXT, &text, NULL );
1112     if( i_ret != VLC_SUCCESS )
1113     {
1114         text.psz_string = NULL;
1115     }
1116
1117     if( !action )
1118     {
1119         action = new QAction( TEXT_OR_VAR, menu );
1120         menu->addAction( action );
1121         action->setData( psz_var );
1122     }
1123
1124     /* Some specific stuff */
1125     bool forceDisabled = false;
1126     if( !strcmp( psz_var, "spu-es" ) )
1127     {
1128         vout_thread_t *p_vout = THEMIM->getVout();
1129         forceDisabled = ( p_vout == NULL );
1130         if( p_vout )
1131             vlc_object_release( p_vout );
1132     }
1133
1134     if( i_type & VLC_VAR_HASCHOICE )
1135     {
1136         /* Append choices menu */
1137         if( b_submenu )
1138         {
1139             QMenu *submenu;
1140             submenu = action->menu();
1141             if( !submenu )
1142             {
1143                 submenu = new QMenu( menu );
1144                 action->setMenu( submenu );
1145             }
1146
1147             action->setEnabled(
1148                CreateChoicesMenu( submenu, psz_var, p_object, true ) == 0 );
1149             if( forceDisabled )
1150                 action->setEnabled( false );
1151         }
1152         else
1153             CreateChoicesMenu( menu, psz_var, p_object, true );
1154         FREENULL( text.psz_string );
1155         return;
1156     }
1157
1158     switch( i_type & VLC_VAR_TYPE )
1159     {
1160         case VLC_VAR_VOID:
1161             var_Get( p_object, psz_var, &val );
1162             CreateAndConnect( menu, psz_var, TEXT_OR_VAR, "", ITEM_NORMAL,
1163                     p_object, val, i_type );
1164             break;
1165
1166         case VLC_VAR_BOOL:
1167             var_Get( p_object, psz_var, &val );
1168             val.b_bool = !val.b_bool;
1169             CreateAndConnect( menu, psz_var, TEXT_OR_VAR, "", ITEM_CHECK,
1170                     p_object, val, i_type, !val.b_bool );
1171             break;
1172     }
1173     FREENULL( text.psz_string );
1174 }
1175
1176
1177 int QVLCMenu::CreateChoicesMenu( QMenu *submenu, const char *psz_var,
1178         vlc_object_t *p_object, bool b_root )
1179 {
1180     vlc_value_t val, val_list, text_list;
1181     int i_type, i;
1182
1183     /* Check the type of the object variable */
1184     i_type = var_Type( p_object, psz_var );
1185
1186     /* Make sure we want to display the variable */
1187     if( submenu->isEmpty() && IsMenuEmpty( psz_var, p_object, b_root ) )
1188         return VLC_EGENERIC;
1189
1190     switch( i_type & VLC_VAR_TYPE )
1191     {
1192         case VLC_VAR_VOID:
1193         case VLC_VAR_BOOL:
1194         case VLC_VAR_VARIABLE:
1195         case VLC_VAR_STRING:
1196         case VLC_VAR_INTEGER:
1197         case VLC_VAR_FLOAT:
1198             break;
1199         default:
1200             /* Variable doesn't exist or isn't handled */
1201             return VLC_EGENERIC;
1202     }
1203
1204     if( var_Change( p_object, psz_var, VLC_VAR_GETLIST,
1205                     &val_list, &text_list ) < 0 )
1206     {
1207         return VLC_EGENERIC;
1208     }
1209
1210 #define CURVAL val_list.p_list->p_values[i]
1211 #define CURTEXT text_list.p_list->p_values[i].psz_string
1212
1213     for( i = 0; i < val_list.p_list->i_count; i++ )
1214     {
1215         vlc_value_t another_val;
1216         QString menutext;
1217         QMenu *subsubmenu = new QMenu( submenu );
1218
1219         switch( i_type & VLC_VAR_TYPE )
1220         {
1221             case VLC_VAR_VARIABLE:
1222                 CreateChoicesMenu( subsubmenu, CURVAL.psz_string, p_object, false );
1223                 subsubmenu->setTitle( qfu( CURTEXT ? CURTEXT :CURVAL.psz_string ) );
1224                 submenu->addMenu( subsubmenu );
1225                 break;
1226
1227             case VLC_VAR_STRING:
1228                 var_Get( p_object, psz_var, &val );
1229                 another_val.psz_string = strdup( CURVAL.psz_string );
1230                 menutext = qfu( CURTEXT ? CURTEXT : another_val.psz_string );
1231                 CreateAndConnect( submenu, psz_var, menutext, "", ITEM_RADIO,
1232                         p_object, another_val, i_type,
1233                         val.psz_string && !strcmp( val.psz_string, CURVAL.psz_string ) );
1234
1235                 free( val.psz_string );
1236                 break;
1237
1238             case VLC_VAR_INTEGER:
1239                 var_Get( p_object, psz_var, &val );
1240                 if( CURTEXT ) menutext = qfu( CURTEXT );
1241                 else menutext.sprintf( "%d", CURVAL.i_int );
1242                 CreateAndConnect( submenu, psz_var, menutext, "", ITEM_RADIO,
1243                         p_object, CURVAL, i_type,
1244                         CURVAL.i_int == val.i_int );
1245                 break;
1246
1247             case VLC_VAR_FLOAT:
1248                 var_Get( p_object, psz_var, &val );
1249                 if( CURTEXT ) menutext = qfu( CURTEXT );
1250                 else menutext.sprintf( "%.2f", CURVAL.f_float );
1251                 CreateAndConnect( submenu, psz_var, menutext, "", ITEM_RADIO,
1252                         p_object, CURVAL, i_type,
1253                         CURVAL.f_float == val.f_float );
1254                 break;
1255
1256             default:
1257                 break;
1258         }
1259     }
1260     currentGroup = NULL;
1261
1262     /* clean up everything */
1263     var_Change( p_object, psz_var, VLC_VAR_FREELIST, &val_list, &text_list );
1264
1265 #undef CURVAL
1266 #undef CURTEXT
1267     return VLC_SUCCESS;
1268 }
1269
1270 void QVLCMenu::CreateAndConnect( QMenu *menu, const char *psz_var,
1271         QString text, QString help,
1272         int i_item_type, vlc_object_t *p_obj,
1273         vlc_value_t val, int i_val_type,
1274         bool checked )
1275 {
1276     QAction *action = FindActionWithVar( menu, psz_var );
1277     if( !action )
1278     {
1279         action = new QAction( text, menu );
1280         menu->addAction( action );
1281     }
1282
1283     action->setToolTip( help );
1284     action->setEnabled( p_obj != NULL );
1285
1286     if( i_item_type == ITEM_CHECK )
1287     {
1288         action->setCheckable( true );
1289     }
1290     else if( i_item_type == ITEM_RADIO )
1291     {
1292         action->setCheckable( true );
1293         if( !currentGroup )
1294             currentGroup = new QActionGroup( menu );
1295         currentGroup->addAction( action );
1296     }
1297
1298     action->setChecked( checked );
1299
1300     MenuItemData *itemData = new MenuItemData( THEDP->menusMapper, p_obj, i_val_type,
1301             val, psz_var );
1302     CONNECT( action, triggered(), THEDP->menusMapper, map() );
1303     THEDP->menusMapper->setMapping( action, itemData );
1304     menu->addAction( action );
1305 }
1306
1307 void QVLCMenu::DoAction( QObject *data )
1308 {
1309     MenuItemData *itemData = qobject_cast<MenuItemData *>( data );
1310     vlc_object_t *p_object = itemData->p_obj;
1311     if( p_object == NULL ) return;
1312
1313     var_Set( p_object, itemData->psz_var, itemData->val );
1314 }
1315
1316 void QVLCMenu::updateRecents( intf_thread_t *p_intf )
1317 {
1318     if (recentsMenu)
1319     {
1320         QAction* action;
1321         RecentsMRL* rmrl = RecentsMRL::getInstance( p_intf );
1322         QList<QString> l = rmrl->recents();
1323
1324         recentsMenu->clear();
1325         if( !l.size() )
1326         {
1327             action = recentsMenu->addAction( " - Empty - " );
1328             action->setEnabled( false );
1329         }
1330         else
1331         {
1332             for( int i = 0; i < l.size(); ++i )
1333             {
1334                 action = recentsMenu->addAction(
1335                         QString( "&%1: " ).arg( i + 1 ) + l.at( i ),
1336                         rmrl->signalMapper,
1337                         SLOT( map() ) );
1338                 rmrl->signalMapper->setMapping( action, l.at( i ) );
1339             }
1340
1341             recentsMenu->addSeparator();
1342             recentsMenu->addAction( "&Clear", rmrl, SLOT( clear() ) );
1343         }
1344     }
1345 }