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