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