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