1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2006 the VideoLAN team
7 * Authors: ClÃment Stenac <zorglub@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
27 #include <QActionGroup>
28 #include <QSignalMapper>
30 #include <vlc_intf_strings.h>
32 #include "main_interface.hpp"
34 #include "dialogs_provider.hpp"
35 #include "input_manager.hpp"
44 static QActionGroup *currentGroup;
46 // Add static entries to menus
47 #define DP_SADD( text, help, icon, slot ) { if( strlen(icon) > 0 ) { QAction *action = menu->addAction( text, THEDP, SLOT( slot ) ); action->setIcon(QIcon(icon));} else { menu->addAction( text, THEDP, SLOT( slot ) ); } }
48 #define MIM_SADD( text, help, icon, slot ) { if( strlen(icon) > 0 ) { QAction *action = menu->addAction( text, THEMIM, SLOT( slot ) ); action->setIcon(QIcon(icon));} else { menu->addAction( text, THEMIM, SLOT( slot ) ); } }
51 /*****************************************************************************
52 * Definitions of variables for the dynamic menus
53 *****************************************************************************/
54 #define PUSH_VAR( var ) varnames.push_back( var ); \
55 objects.push_back( p_object->i_object_id )
57 #define PUSH_SEPARATOR if( objects.size() != i_last_separator ) { \
58 objects.push_back( 0 ); varnames.push_back( "" ); \
59 i_last_separator = objects.size(); }
61 static int InputAutoMenuBuilder( vlc_object_t *p_object,
63 vector<const char *> &varnames )
65 PUSH_VAR( "bookmark");
67 PUSH_VAR ("chapter" );
68 PUSH_VAR( "program" );
69 PUSH_VAR( "navigation" );
70 PUSH_VAR( "dvd_menus" );
74 static int VideoAutoMenuBuilder( vlc_object_t *p_object,
76 vector<const char *> &varnames )
78 PUSH_VAR( "fullscreen" );
80 PUSH_VAR( "deinterlace" );
81 PUSH_VAR( "aspect-ratio" );
83 PUSH_VAR( "video-on-top" );
84 PUSH_VAR( "directx-wallpaper" );
85 PUSH_VAR( "video-snapshot" );
87 vlc_object_t *p_dec_obj = (vlc_object_t *)vlc_object_find( p_object,
90 if( p_dec_obj != NULL )
92 vlc_object_t *p_object = p_dec_obj;
93 PUSH_VAR( "ffmpeg-pp-q" );
94 vlc_object_release( p_dec_obj );
99 static int AudioAutoMenuBuilder( vlc_object_t *p_object,
100 vector<int> &objects,
101 vector<const char *> &varnames )
103 PUSH_VAR( "audio-device" );
104 PUSH_VAR( "audio-channels" );
105 PUSH_VAR( "visual" );
106 PUSH_VAR( "equalizer" );
110 /*****************************************************************************
112 *****************************************************************************/
114 #define BAR_ADD( func, title ) { \
115 QMenu *menu = func; menu->setTitle( title ); bar->addMenu( menu ); }
117 #define BAR_DADD( func, title, id ) { \
118 QMenu *menu = func; menu->setTitle( title ); bar->addMenu( menu ); \
119 MenuFunc *f = new MenuFunc( menu, id ); \
120 CONNECT( menu, aboutToShow(), THEDP->menusUpdateMapper, map() ); \
121 THEDP->menusUpdateMapper->setMapping( menu, f ); }
123 void QVLCMenu::createMenuBar( MainInterface *mi, intf_thread_t *p_intf,
124 bool playlist, bool adv_controls_enabled,
125 bool visual_selector_enabled )
127 QMenuBar *bar = mi->menuBar();
128 BAR_ADD( FileMenu(), qtr("Media") );
131 BAR_ADD( PlaylistMenu( mi,p_intf ), qtr("Playlist" ) );
133 BAR_ADD( ToolsMenu( p_intf, mi, adv_controls_enabled,
134 visual_selector_enabled ), qtr("Tools") );
135 BAR_DADD( VideoMenu( p_intf, NULL ), qtr("Video"), 1 );
136 BAR_DADD( AudioMenu( p_intf, NULL ), qtr("Audio"), 2 );
137 BAR_DADD( NavigMenu( p_intf, NULL ), qtr("Navigation"), 3 );
139 BAR_ADD( HelpMenu(), qtr("Help" ) );
141 QMenu *QVLCMenu::FileMenu()
143 QMenu *menu = new QMenu();
144 /* DP_SADD( qtr("Quick &Open File...") , "", "", simpleOpenDialog() );*/
145 DP_SADD( qtr("Open &File..." ), "", "", openFileDialog() );
146 DP_SADD( qtr("Open &Disc..." ), "", "", openDiscDialog());
147 DP_SADD( qtr("Open &Network..." ), "", "", openNetDialog());
148 DP_SADD( qtr("Open &Capture Device..." ), "", "", openCaptureDialog());
149 menu->addSeparator();
150 DP_SADD( qtr("&Streaming..."), "", "", streamingDialog() );
151 menu->addSeparator();
152 DP_SADD( qtr("&Quit") , "", "", quit() );
156 QMenu *QVLCMenu::PlaylistMenu( MainInterface *mi, intf_thread_t *p_intf )
158 QMenu *menu = new QMenu();
159 menu->addMenu( SDMenu( p_intf ) );
160 menu->addSeparator();
162 DP_SADD( qtr(I_PL_LOAD), "", "", openPlaylist() );
163 DP_SADD( qtr(I_PL_SAVE), "", "", savePlaylist() );
164 menu->addSeparator();
165 menu->addAction( qtr("Undock from interface"), mi,
166 SLOT( undockPlaylist() ) );
170 QMenu *QVLCMenu::ToolsMenu( intf_thread_t *p_intf, MainInterface *mi,
171 bool adv_controls_enabled,
172 bool visual_selector_enabled, bool with_intf )
174 QMenu *menu = new QMenu();
177 QMenu *intfmenu = InterfacesMenu( p_intf, NULL );
178 intfmenu->setTitle( qtr("Interfaces" ) );
179 menu->addMenu( intfmenu );
180 menu->addSeparator();
182 DP_SADD( qtr(I_MENU_MSG), "", "", messagesDialog() );
183 DP_SADD( qtr(I_MENU_INFO) , "", "", mediaInfoDialog() );
184 DP_SADD( qtr(I_MENU_CODECINFO) , "", "", mediaCodecDialog() );
185 DP_SADD( qtr(I_MENU_EXT), "","",extendedDialog() );
188 menu->addSeparator();
189 QAction *adv = menu->addAction( qtr("Advanced controls" ),
190 mi, SLOT( advanced() ) );
191 adv->setCheckable( true );
192 if( adv_controls_enabled ) adv->setChecked( true );
194 adv = menu->addAction( qtr("Visualizations selector" ),
195 mi, SLOT( visual() ) );
196 adv->setCheckable( true );
197 if( visual_selector_enabled ) adv->setChecked( true );
200 menu->addSeparator();
201 DP_SADD( qtr("Preferences"), "", "", prefsDialog() );
205 QMenu *QVLCMenu::InterfacesMenu( intf_thread_t *p_intf, QMenu *current )
208 vector<const char *> varnames;
209 /** \todo add "switch to XXX" */
210 varnames.push_back( "intf-add" );
211 objects.push_back( p_intf->i_object_id );
213 QMenu *menu = Populate( p_intf, current, varnames, objects );
215 if( !p_intf->pf_show_dialog )
217 menu->addSeparator();
218 menu->addAction( qtr("Switch to skins"), THEDP, SLOT(switchToSkins()) );
221 CONNECT( menu, aboutToShow(), THEDP->menusUpdateMapper, map() );
222 THEDP->menusUpdateMapper->setMapping( menu, 4 );
226 QMenu *QVLCMenu::AudioMenu( intf_thread_t *p_intf, QMenu * current )
229 vector<const char *> varnames;
231 vlc_object_t *p_object = (vlc_object_t *)vlc_object_find( p_intf,
232 VLC_OBJECT_INPUT, FIND_ANYWHERE );
233 if( p_object != NULL )
235 PUSH_VAR( "audio-es" );
236 vlc_object_release( p_object );
239 p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
243 AudioAutoMenuBuilder( p_object, objects, varnames );
244 vlc_object_release( p_object );
246 return Populate( p_intf, current, varnames, objects );
250 QMenu *QVLCMenu::VideoMenu( intf_thread_t *p_intf, QMenu *current )
252 vlc_object_t *p_object;
254 vector<const char *> varnames;
256 p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
258 if( p_object != NULL )
260 PUSH_VAR( "video-es" );
261 PUSH_VAR( "spu-es" );
262 vlc_object_release( p_object );
265 p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
267 if( p_object != NULL )
269 VideoAutoMenuBuilder( p_object, objects, varnames );
270 vlc_object_release( p_object );
272 return Populate( p_intf, current, varnames, objects );
275 QMenu *QVLCMenu::NavigMenu( intf_thread_t *p_intf, QMenu *current )
277 vlc_object_t *p_object;
279 vector<const char *> varnames;
282 p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
284 if( p_object != NULL )
286 InputAutoMenuBuilder( p_object, objects, varnames );
287 PUSH_VAR( "prev-title"); PUSH_VAR ( "next-title" );
288 PUSH_VAR( "prev-chapter"); PUSH_VAR( "next-chapter" );
289 vlc_object_release( p_object );
291 return Populate( p_intf, current, varnames, objects );
294 QMenu *QVLCMenu::SDMenu( intf_thread_t *p_intf )
296 QMenu *menu = new QMenu();
297 menu->setTitle( qtr(I_PL_SD) );
298 vlc_list_t *p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE,
301 for( int i_index = 0 ; i_index < p_list->i_count; i_index++ )
303 module_t * p_parser = (module_t *)p_list->p_values[i_index].p_object ;
304 if( !strcmp( p_parser->psz_capability, "services_discovery" ) )
307 for( int i_index = 0 ; i_index < p_list->i_count; i_index++ )
309 module_t * p_parser = (module_t *)p_list->p_values[i_index].p_object;
310 if( !strcmp( p_parser->psz_capability, "services_discovery" ) )
312 QAction *a = new QAction( qfu( p_parser->psz_longname ), menu );
313 a->setCheckable( true );
314 /* hack to handle submodules properly */
316 while( p_parser->pp_shortcuts[++i] != NULL );
318 if( playlist_IsServicesDiscoveryLoaded( THEPL,
319 i>=0?p_parser->pp_shortcuts[i] : p_parser->psz_object_name ) )
321 a->setChecked( true );
323 CONNECT( a , triggered(), THEDP->SDMapper, map() );
324 THEDP->SDMapper->setMapping( a, i>=0? p_parser->pp_shortcuts[i] :
325 p_parser->psz_object_name );
326 menu->addAction( a );
329 vlc_list_release( p_list );
333 QMenu *QVLCMenu::HelpMenu()
335 QMenu *menu = new QMenu();
336 DP_SADD( qtr("Help") , "", "", helpDialog() );
337 menu->addSeparator();
338 DP_SADD( qtr(I_MENU_ABOUT), "", "", aboutDialog() );
343 /*****************************************************************************
345 *****************************************************************************/
346 #define POPUP_BOILERPLATE \
347 unsigned int i_last_separator = 0; \
348 vector<int> objects; \
349 vector<const char *> varnames; \
350 input_thread_t *p_input = THEMIM->getInput();
352 #define CREATE_POPUP \
353 QMenu *menu = new QMenu(); \
354 Populate( p_intf, menu, varnames, objects ); \
355 p_intf->p_sys->p_popup_menu = menu; \
356 menu->popup( QCursor::pos() ); \
357 p_intf->p_sys->p_popup_menu = NULL; \
358 i_last_separator = 0;
360 #define POPUP_STATIC_ENTRIES \
362 MIM_SADD( qtr("Stop"), "", "", stop() ); \
363 MIM_SADD( qtr("Previous"), "", "", prev() ); \
364 MIM_SADD( qtr("Next"), "", "", next() ); \
367 var_Get( p_input, "state", &val ); \
368 if( val.i_int == PAUSE_S ) \
369 MIM_SADD( qtr("Play"), "", "", togglePlayPause() ) \
371 MIM_SADD( qtr("Pause"), "", "", togglePlayPause() ) \
373 else if( THEPL->items.i_size && THEPL->i_enabled ) \
374 MIM_SADD( qtr("Play"), "", "", togglePlayPause() ) \
376 QMenu *intfmenu = InterfacesMenu( p_intf, NULL ); \
377 intfmenu->setTitle( qtr("Interfaces" ) ); \
378 menu->addMenu( intfmenu ); \
380 QMenu *toolsmenu = ToolsMenu( p_intf, NULL, false, false ); \
381 toolsmenu->setTitle( qtr("Tools" ) ); \
382 menu->addMenu( toolsmenu ); \
384 void QVLCMenu::VideoPopupMenu( intf_thread_t *p_intf )
389 vlc_object_yield( p_input );
390 varnames.push_back( "video-es" );
391 objects.push_back( p_input->i_object_id );
392 varnames.push_back( "spu-es" );
393 objects.push_back( p_input->i_object_id );
394 vlc_object_t *p_vout = (vlc_object_t *)vlc_object_find( p_input,
395 VLC_OBJECT_VOUT, FIND_CHILD );
398 VideoAutoMenuBuilder( p_vout, objects, varnames );
399 vlc_object_release( p_vout );
401 vlc_object_release( p_input );
406 void QVLCMenu::AudioPopupMenu( intf_thread_t *p_intf )
411 vlc_object_yield( p_input );
412 varnames.push_back( "audio-es" );
413 objects.push_back( p_input->i_object_id );
414 vlc_object_t *p_aout = (vlc_object_t *)vlc_object_find( p_input,
415 VLC_OBJECT_AOUT, FIND_ANYWHERE );
418 AudioAutoMenuBuilder( p_aout, objects, varnames );
419 vlc_object_release( p_aout );
421 vlc_object_release( p_input );
426 /* Navigation stuff, and general */
427 void QVLCMenu::MiscPopupMenu( intf_thread_t *p_intf )
432 vlc_object_yield( p_input );
433 varnames.push_back( "audio-es" );
434 InputAutoMenuBuilder( VLC_OBJECT(p_input), objects, varnames );
438 QMenu *menu = new QMenu();
439 Populate( p_intf, menu, varnames, objects );
440 menu->addSeparator();
441 POPUP_STATIC_ENTRIES;
443 p_intf->p_sys->p_popup_menu = menu;
444 menu->popup( QCursor::pos() );
445 p_intf->p_sys->p_popup_menu = NULL;
448 void QVLCMenu::PopupMenu( intf_thread_t *p_intf )
453 vlc_object_yield( p_input );
454 InputAutoMenuBuilder( VLC_OBJECT(p_input), objects, varnames );
458 varnames.push_back( "video-es" );
459 objects.push_back( p_input->i_object_id );
460 varnames.push_back( "spu-es" );
461 objects.push_back( p_input->i_object_id );
462 vlc_object_t *p_vout = (vlc_object_t *)vlc_object_find( p_input,
463 VLC_OBJECT_VOUT, FIND_CHILD );
466 VideoAutoMenuBuilder( p_vout, objects, varnames );
467 vlc_object_release( p_vout );
471 varnames.push_back( "audio-es" );
472 objects.push_back( p_input->i_object_id );
473 vlc_object_t *p_aout = (vlc_object_t *)vlc_object_find( p_input,
474 VLC_OBJECT_AOUT, FIND_ANYWHERE );
477 AudioAutoMenuBuilder( p_aout, objects, varnames );
478 vlc_object_release( p_aout );
482 QMenu *menu = new QMenu();
483 Populate( p_intf, menu, varnames, objects );
484 menu->addSeparator();
485 POPUP_STATIC_ENTRIES;
487 p_intf->p_sys->p_popup_menu = menu;
488 menu->popup( QCursor::pos() );
489 p_intf->p_sys->p_popup_menu = NULL;
493 #undef PUSH_SEPARATOR
495 /*************************************************************************
496 * Builders for automenus
497 *************************************************************************/
498 QMenu * QVLCMenu::Populate( intf_thread_t *p_intf, QMenu *current,
499 vector< const char *> & varnames,
500 vector<int> & objects, bool append )
502 QMenu *menu = current;
510 vlc_object_t *p_object;
511 vlc_bool_t b_section_empty = VLC_FALSE;
514 #define APPEND_EMPTY { QAction *action = menu->addAction( qtr("Empty" ) ); \
515 action->setEnabled( false ); }
517 for( i = 0; i < (int)objects.size() ; i++ )
519 if( !varnames[i] || !*varnames[i] )
521 if( b_section_empty )
523 menu->addSeparator();
524 b_section_empty = VLC_TRUE;
528 if( objects[i] == 0 )
530 /// \bug What is this ?
531 // Append( menu, varnames[i], NULL );
532 b_section_empty = VLC_FALSE;
536 p_object = (vlc_object_t *)vlc_object_get( p_intf,
538 if( p_object == NULL ) continue;
540 b_section_empty = VLC_FALSE;
541 /* Ugly specific stuff */
542 if( strstr(varnames[i], "intf-add" ) )
543 CreateItem( menu, varnames[i], p_object, false );
545 CreateItem( menu, varnames[i], p_object, true );
546 vlc_object_release( p_object );
549 /* Special case for empty menus */
550 if( menu->actions().size() == 0 || b_section_empty )
556 /*****************************************************************************
558 *****************************************************************************/
560 static bool IsMenuEmpty( const char *psz_var, vlc_object_t *p_object,
563 vlc_value_t val, val_list;
564 int i_type, i_result, i;
566 /* Check the type of the object variable */
567 i_type = var_Type( p_object, psz_var );
569 /* Check if we want to display the variable */
570 if( !(i_type & VLC_VAR_HASCHOICE) ) return FALSE;
572 var_Change( p_object, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL );
573 if( val.i_int == 0 ) return TRUE;
575 if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE )
577 /* Very evil hack ! intf-switch can have only one value */
578 if( !strcmp( psz_var, "intf-switch" ) ) return FALSE;
579 if( val.i_int == 1 && b_root ) return TRUE;
583 /* Check children variables in case of VLC_VAR_VARIABLE */
584 if( var_Change( p_object, psz_var, VLC_VAR_GETLIST, &val_list, NULL ) < 0 )
589 for( i = 0, i_result = TRUE; i < val_list.p_list->i_count; i++ )
591 if( !IsMenuEmpty( val_list.p_list->p_values[i].psz_string,
599 /* clean up everything */
600 var_Change( p_object, psz_var, VLC_VAR_FREELIST, &val_list, NULL );
605 void QVLCMenu::CreateItem( QMenu *menu, const char *psz_var,
606 vlc_object_t *p_object, bool b_submenu )
608 vlc_value_t val, text;
611 /* Check the type of the object variable */
612 i_type = var_Type( p_object, psz_var );
614 switch( i_type & VLC_VAR_TYPE )
618 case VLC_VAR_VARIABLE:
620 case VLC_VAR_INTEGER:
624 /* Variable doesn't exist or isn't handled */
628 /* Make sure we want to display the variable */
629 if( IsMenuEmpty( psz_var, p_object ) ) return;
631 /* Get the descriptive name of the variable */
632 var_Change( p_object, psz_var, VLC_VAR_GETTEXT, &text, NULL );
634 if( i_type & VLC_VAR_HASCHOICE )
636 /* Append choices menu */
639 QMenu *submenu = new QMenu();
640 submenu->setTitle( qfu( text.psz_string ?
641 text.psz_string : psz_var ) );
642 if( CreateChoicesMenu( submenu, psz_var, p_object, true ) == 0)
643 menu->addMenu( submenu );
646 CreateChoicesMenu( menu, psz_var, p_object, true );
647 FREENULL( text.psz_string );
651 #define TEXT_OR_VAR qfu ( text.psz_string ? text.psz_string : psz_var )
653 switch( i_type & VLC_VAR_TYPE )
656 var_Get( p_object, psz_var, &val );
657 CreateAndConnect( menu, psz_var, TEXT_OR_VAR, "", ITEM_NORMAL,
658 p_object->i_object_id, val, i_type );
662 var_Get( p_object, psz_var, &val );
663 CreateAndConnect( menu, psz_var, TEXT_OR_VAR, "", ITEM_CHECK,
664 p_object->i_object_id, val, i_type, val.b_bool );
667 FREENULL( text.psz_string );
671 int QVLCMenu::CreateChoicesMenu( QMenu *submenu, const char *psz_var,
672 vlc_object_t *p_object, bool b_root )
674 vlc_value_t val, val_list, text_list;
677 /* Check the type of the object variable */
678 i_type = var_Type( p_object, psz_var );
680 /* Make sure we want to display the variable */
681 if( IsMenuEmpty( psz_var, p_object, b_root ) ) return VLC_EGENERIC;
683 switch( i_type & VLC_VAR_TYPE )
687 case VLC_VAR_VARIABLE:
689 case VLC_VAR_INTEGER:
693 /* Variable doesn't exist or isn't handled */
697 if( var_Change( p_object, psz_var, VLC_VAR_GETLIST,
698 &val_list, &text_list ) < 0 )
702 #define NORMAL_OR_RADIO i_type & VLC_VAR_ISCOMMAND ? ITEM_NORMAL: ITEM_RADIO
703 #define NOTCOMMAND !(i_type & VLC_VAR_ISCOMMAND)
704 #define CURVAL val_list.p_list->p_values[i]
705 #define CURTEXT text_list.p_list->p_values[i].psz_string
707 for( i = 0; i < val_list.p_list->i_count; i++ )
709 vlc_value_t another_val;
711 QMenu *subsubmenu = new QMenu();
713 switch( i_type & VLC_VAR_TYPE )
715 case VLC_VAR_VARIABLE:
716 CreateChoicesMenu( subsubmenu, CURVAL.psz_string, p_object, false );
717 subsubmenu->setTitle( qfu( CURTEXT ? CURTEXT :CURVAL.psz_string ) );
718 submenu->addMenu( subsubmenu );
722 var_Get( p_object, psz_var, &val );
723 another_val.psz_string = strdup( CURVAL.psz_string );
724 menutext = qfu( CURTEXT ? CURTEXT : another_val.psz_string );
725 CreateAndConnect( submenu, psz_var, menutext, "", NORMAL_OR_RADIO,
726 p_object->i_object_id, another_val, i_type,
727 NOTCOMMAND && val.psz_string &&
728 !strcmp( val.psz_string, CURVAL.psz_string ) );
730 if( val.psz_string ) free( val.psz_string );
733 case VLC_VAR_INTEGER:
734 var_Get( p_object, psz_var, &val );
735 if( CURTEXT ) menutext = qfu( CURTEXT );
736 else menutext.sprintf( "%d", CURVAL.i_int);
737 CreateAndConnect( submenu, psz_var, menutext, "", NORMAL_OR_RADIO,
738 p_object->i_object_id, CURVAL, i_type,
739 NOTCOMMAND && CURVAL.i_int == val.i_int );
743 var_Get( p_object, psz_var, &val );
744 if( CURTEXT ) menutext = qfu( CURTEXT );
745 else menutext.sprintf( "%.2f", CURVAL.f_float );
746 CreateAndConnect( submenu, psz_var, menutext, "", NORMAL_OR_RADIO,
747 p_object->i_object_id, CURVAL, i_type,
748 NOTCOMMAND && CURVAL.f_float == val.f_float );
757 /* clean up everything */
758 var_Change( p_object, psz_var, VLC_VAR_FREELIST, &val_list, &text_list );
760 #undef NORMAL_OR_RADIO
767 void QVLCMenu::CreateAndConnect( QMenu *menu, const char *psz_var,
768 QString text, QString help,
769 int i_item_type, int i_object_id,
770 vlc_value_t val, int i_val_type,
773 QAction *action = new QAction( text, menu );
774 action->setText( text );
775 action->setToolTip( help );
777 if( i_item_type == ITEM_CHECK )
779 action->setCheckable( true );
781 else if( i_item_type == ITEM_RADIO )
783 action->setCheckable( true );
785 currentGroup = new QActionGroup(menu);
786 currentGroup->addAction( action );
791 action->setChecked( true );
793 MenuItemData *itemData = new MenuItemData( i_object_id, i_val_type,
795 CONNECT( action, triggered(), THEDP->menusMapper, map() );
796 THEDP->menusMapper->setMapping( action, itemData );
797 menu->addAction( action );
800 void QVLCMenu::DoAction( intf_thread_t *p_intf, QObject *data )
802 MenuItemData *itemData = qobject_cast<MenuItemData *>(data);
803 vlc_object_t *p_object = (vlc_object_t *)vlc_object_get( p_intf,
804 itemData->i_object_id );
805 if( p_object == NULL ) return;
807 var_Set( p_object, itemData->psz_var, itemData->val );
808 vlc_object_release( p_object );