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 menu->addSeparator();
149 DP_SADD( qtr("Streaming..."), "", "", streamingDialog() );
150 menu->addSeparator();
151 DP_SADD( qtr("&Quit") , "", "", quit() );
155 QMenu *QVLCMenu::PlaylistMenu( MainInterface *mi, intf_thread_t *p_intf )
157 QMenu *menu = new QMenu();
158 menu->addMenu( SDMenu( p_intf ) );
159 menu->addSeparator();
161 DP_SADD( qtr(I_PL_LOAD), "", "", openPlaylist() );
162 DP_SADD( qtr(I_PL_SAVE), "", "", savePlaylist() );
163 menu->addSeparator();
164 menu->addAction( qtr("Undock from interface"), mi,
165 SLOT( undockPlaylist() ) );
169 QMenu *QVLCMenu::ToolsMenu( intf_thread_t *p_intf, MainInterface *mi,
170 bool adv_controls_enabled,
171 bool visual_selector_enabled, bool with_intf )
173 QMenu *menu = new QMenu();
176 QMenu *intfmenu = InterfacesMenu( p_intf, NULL );
177 intfmenu->setTitle( qtr("Interfaces" ) );
178 menu->addMenu( intfmenu );
179 menu->addSeparator();
181 DP_SADD( qtr(I_MENU_MSG), "", "", messagesDialog() );
182 DP_SADD( qtr(I_MENU_INFO) , "", "", mediaInfoDialog() );
183 DP_SADD( qtr(I_MENU_EXT), "","",extendedDialog() );
186 menu->addSeparator();
187 QAction *adv = menu->addAction( qtr("Advanced controls" ),
188 mi, SLOT( advanced() ) );
189 adv->setCheckable( true );
190 if( adv_controls_enabled ) adv->setChecked( true );
192 adv = menu->addAction( qtr("Visualizations selector" ),
193 mi, SLOT( visual() ) );
194 adv->setCheckable( true );
195 if( visual_selector_enabled ) adv->setChecked( true );
198 menu->addSeparator();
199 DP_SADD( qtr("Preferences"), "", "", prefsDialog() );
203 QMenu *QVLCMenu::InterfacesMenu( intf_thread_t *p_intf, QMenu *current )
206 vector<const char *> varnames;
207 /** \todo add "switch to XXX" */
208 varnames.push_back( "intf-add" );
209 objects.push_back( p_intf->i_object_id );
211 QMenu *menu = Populate( p_intf, current, varnames, objects );
213 if( !p_intf->pf_show_dialog )
215 menu->addSeparator();
216 menu->addAction( qtr("Switch to skins"), THEDP, SLOT(switchToSkins()) );
219 CONNECT( menu, aboutToShow(), THEDP->menusUpdateMapper, map() );
220 THEDP->menusUpdateMapper->setMapping( menu, 4 );
224 QMenu *QVLCMenu::AudioMenu( intf_thread_t *p_intf, QMenu * current )
227 vector<const char *> varnames;
229 vlc_object_t *p_object = (vlc_object_t *)vlc_object_find( p_intf,
230 VLC_OBJECT_INPUT, FIND_ANYWHERE );
231 if( p_object != NULL )
233 PUSH_VAR( "audio-es" );
234 vlc_object_release( p_object );
237 p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
241 AudioAutoMenuBuilder( p_object, objects, varnames );
242 vlc_object_release( p_object );
244 return Populate( p_intf, current, varnames, objects );
248 QMenu *QVLCMenu::VideoMenu( intf_thread_t *p_intf, QMenu *current )
250 vlc_object_t *p_object;
252 vector<const char *> varnames;
254 p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
256 if( p_object != NULL )
258 PUSH_VAR( "video-es" );
259 PUSH_VAR( "spu-es" );
260 vlc_object_release( p_object );
263 p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
265 if( p_object != NULL )
267 VideoAutoMenuBuilder( p_object, objects, varnames );
268 vlc_object_release( p_object );
270 return Populate( p_intf, current, varnames, objects );
273 QMenu *QVLCMenu::NavigMenu( intf_thread_t *p_intf, QMenu *current )
275 vlc_object_t *p_object;
277 vector<const char *> varnames;
280 p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
282 if( p_object != NULL )
284 InputAutoMenuBuilder( p_object, objects, varnames );
285 PUSH_VAR( "prev-title"); PUSH_VAR ( "next-title" );
286 PUSH_VAR( "prev-chapter"); PUSH_VAR( "next-chapter" );
287 vlc_object_release( p_object );
289 return Populate( p_intf, current, varnames, objects );
292 QMenu *QVLCMenu::SDMenu( intf_thread_t *p_intf )
294 QMenu *menu = new QMenu();
295 menu->setTitle( qtr(I_PL_SD) );
296 vlc_list_t *p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE,
299 for( int i_index = 0 ; i_index < p_list->i_count; i_index++ )
301 module_t * p_parser = (module_t *)p_list->p_values[i_index].p_object ;
302 if( !strcmp( p_parser->psz_capability, "services_discovery" ) )
305 for( int i_index = 0 ; i_index < p_list->i_count; i_index++ )
307 module_t * p_parser = (module_t *)p_list->p_values[i_index].p_object;
308 if( !strcmp( p_parser->psz_capability, "services_discovery" ) )
310 QAction *a = new QAction( qfu( p_parser->psz_longname ), menu );
311 a->setCheckable( true );
312 /* hack to handle submodules properly */
314 while( p_parser->pp_shortcuts[++i] != NULL );
316 if( playlist_IsServicesDiscoveryLoaded( THEPL,
317 i>=0?p_parser->pp_shortcuts[i] : p_parser->psz_object_name ) )
319 a->setChecked( true );
321 CONNECT( a , triggered(), THEDP->SDMapper, map() );
322 THEDP->SDMapper->setMapping( a, i>=0? p_parser->pp_shortcuts[i] :
323 p_parser->psz_object_name );
324 menu->addAction( a );
327 vlc_list_release( p_list );
331 QMenu *QVLCMenu::HelpMenu()
333 QMenu *menu = new QMenu();
334 DP_SADD( qtr("Help") , "", "", helpDialog() );
335 menu->addSeparator();
336 DP_SADD( qtr(I_MENU_ABOUT), "", "", aboutDialog() );
341 /*****************************************************************************
343 *****************************************************************************/
344 #define POPUP_BOILERPLATE \
345 unsigned int i_last_separator = 0; \
346 vector<int> objects; \
347 vector<const char *> varnames; \
348 input_thread_t *p_input = THEMIM->getInput();
350 #define CREATE_POPUP \
351 QMenu *menu = new QMenu(); \
352 Populate( p_intf, menu, varnames, objects ); \
353 p_intf->p_sys->p_popup_menu = menu; \
354 menu->popup( QCursor::pos() ); \
355 p_intf->p_sys->p_popup_menu = NULL; \
356 i_last_separator = 0;
358 #define POPUP_STATIC_ENTRIES \
360 MIM_SADD( qtr("Stop"), "", "", stop() ); \
361 MIM_SADD( qtr("Previous"), "", "", prev() ); \
362 MIM_SADD( qtr("Next"), "", "", next() ); \
365 var_Get( p_input, "state", &val ); \
366 if( val.i_int == PAUSE_S ) \
367 MIM_SADD( qtr("Play"), "", "", togglePlayPause() ) \
369 MIM_SADD( qtr("Pause"), "", "", togglePlayPause() ) \
371 else if( THEPL->items.i_size && THEPL->i_enabled ) \
372 MIM_SADD( qtr("Play"), "", "", togglePlayPause() ) \
374 QMenu *intfmenu = InterfacesMenu( p_intf, NULL ); \
375 intfmenu->setTitle( qtr("Interfaces" ) ); \
376 menu->addMenu( intfmenu ); \
378 QMenu *toolsmenu = ToolsMenu( p_intf, NULL, false, false ); \
379 toolsmenu->setTitle( qtr("Tools" ) ); \
380 menu->addMenu( toolsmenu ); \
382 void QVLCMenu::VideoPopupMenu( intf_thread_t *p_intf )
387 vlc_object_yield( p_input );
388 varnames.push_back( "video-es" );
389 objects.push_back( p_input->i_object_id );
390 varnames.push_back( "spu-es" );
391 objects.push_back( p_input->i_object_id );
392 vlc_object_t *p_vout = (vlc_object_t *)vlc_object_find( p_input,
393 VLC_OBJECT_VOUT, FIND_CHILD );
396 VideoAutoMenuBuilder( p_vout, objects, varnames );
397 vlc_object_release( p_vout );
399 vlc_object_release( p_input );
404 void QVLCMenu::AudioPopupMenu( intf_thread_t *p_intf )
409 vlc_object_yield( p_input );
410 varnames.push_back( "audio-es" );
411 objects.push_back( p_input->i_object_id );
412 vlc_object_t *p_aout = (vlc_object_t *)vlc_object_find( p_input,
413 VLC_OBJECT_AOUT, FIND_ANYWHERE );
416 AudioAutoMenuBuilder( p_aout, objects, varnames );
417 vlc_object_release( p_aout );
419 vlc_object_release( p_input );
424 /* Navigation stuff, and general */
425 void QVLCMenu::MiscPopupMenu( intf_thread_t *p_intf )
430 vlc_object_yield( p_input );
431 varnames.push_back( "audio-es" );
432 InputAutoMenuBuilder( VLC_OBJECT(p_input), objects, varnames );
436 QMenu *menu = new QMenu();
437 Populate( p_intf, menu, varnames, objects );
438 menu->addSeparator();
439 POPUP_STATIC_ENTRIES;
441 p_intf->p_sys->p_popup_menu = menu;
442 menu->popup( QCursor::pos() );
443 p_intf->p_sys->p_popup_menu = NULL;
446 void QVLCMenu::PopupMenu( intf_thread_t *p_intf )
451 vlc_object_yield( p_input );
452 InputAutoMenuBuilder( VLC_OBJECT(p_input), objects, varnames );
456 varnames.push_back( "video-es" );
457 objects.push_back( p_input->i_object_id );
458 varnames.push_back( "spu-es" );
459 objects.push_back( p_input->i_object_id );
460 vlc_object_t *p_vout = (vlc_object_t *)vlc_object_find( p_input,
461 VLC_OBJECT_VOUT, FIND_CHILD );
464 VideoAutoMenuBuilder( p_vout, objects, varnames );
465 vlc_object_release( p_vout );
469 varnames.push_back( "audio-es" );
470 objects.push_back( p_input->i_object_id );
471 vlc_object_t *p_aout = (vlc_object_t *)vlc_object_find( p_input,
472 VLC_OBJECT_AOUT, FIND_ANYWHERE );
475 AudioAutoMenuBuilder( p_aout, objects, varnames );
476 vlc_object_release( p_aout );
480 QMenu *menu = new QMenu();
481 Populate( p_intf, menu, varnames, objects );
482 menu->addSeparator();
483 POPUP_STATIC_ENTRIES;
485 p_intf->p_sys->p_popup_menu = menu;
486 menu->popup( QCursor::pos() );
487 p_intf->p_sys->p_popup_menu = NULL;
491 #undef PUSH_SEPARATOR
493 /*************************************************************************
494 * Builders for automenus
495 *************************************************************************/
496 QMenu * QVLCMenu::Populate( intf_thread_t *p_intf, QMenu *current,
497 vector< const char *> & varnames,
498 vector<int> & objects, bool append )
500 QMenu *menu = current;
508 vlc_object_t *p_object;
509 vlc_bool_t b_section_empty = VLC_FALSE;
512 #define APPEND_EMPTY { QAction *action = menu->addAction( qtr("Empty" ) ); \
513 action->setEnabled( false ); }
515 for( i = 0; i < (int)objects.size() ; i++ )
517 if( !varnames[i] || !*varnames[i] )
519 if( b_section_empty )
521 menu->addSeparator();
522 b_section_empty = VLC_TRUE;
526 if( objects[i] == 0 )
528 /// \bug What is this ?
529 // Append( menu, varnames[i], NULL );
530 b_section_empty = VLC_FALSE;
534 p_object = (vlc_object_t *)vlc_object_get( p_intf,
536 if( p_object == NULL ) continue;
538 b_section_empty = VLC_FALSE;
539 /* Ugly specific stuff */
540 if( strstr(varnames[i], "intf-add" ) )
541 CreateItem( menu, varnames[i], p_object, false );
543 CreateItem( menu, varnames[i], p_object, true );
544 vlc_object_release( p_object );
547 /* Special case for empty menus */
548 if( menu->actions().size() == 0 || b_section_empty )
554 /*****************************************************************************
556 *****************************************************************************/
558 static bool IsMenuEmpty( const char *psz_var, vlc_object_t *p_object,
561 vlc_value_t val, val_list;
562 int i_type, i_result, i;
564 /* Check the type of the object variable */
565 i_type = var_Type( p_object, psz_var );
567 /* Check if we want to display the variable */
568 if( !(i_type & VLC_VAR_HASCHOICE) ) return FALSE;
570 var_Change( p_object, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL );
571 if( val.i_int == 0 ) return TRUE;
573 if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE )
575 /* Very evil hack ! intf-switch can have only one value */
576 if( !strcmp( psz_var, "intf-switch" ) ) return FALSE;
577 if( val.i_int == 1 && b_root ) return TRUE;
581 /* Check children variables in case of VLC_VAR_VARIABLE */
582 if( var_Change( p_object, psz_var, VLC_VAR_GETLIST, &val_list, NULL ) < 0 )
587 for( i = 0, i_result = TRUE; i < val_list.p_list->i_count; i++ )
589 if( !IsMenuEmpty( val_list.p_list->p_values[i].psz_string,
597 /* clean up everything */
598 var_Change( p_object, psz_var, VLC_VAR_FREELIST, &val_list, NULL );
603 void QVLCMenu::CreateItem( QMenu *menu, const char *psz_var,
604 vlc_object_t *p_object, bool b_submenu )
606 vlc_value_t val, text;
609 /* Check the type of the object variable */
610 i_type = var_Type( p_object, psz_var );
612 switch( i_type & VLC_VAR_TYPE )
616 case VLC_VAR_VARIABLE:
618 case VLC_VAR_INTEGER:
622 /* Variable doesn't exist or isn't handled */
626 /* Make sure we want to display the variable */
627 if( IsMenuEmpty( psz_var, p_object ) ) return;
629 /* Get the descriptive name of the variable */
630 var_Change( p_object, psz_var, VLC_VAR_GETTEXT, &text, NULL );
632 if( i_type & VLC_VAR_HASCHOICE )
634 /* Append choices menu */
637 QMenu *submenu = new QMenu();
638 submenu->setTitle( qfu( text.psz_string ?
639 text.psz_string : psz_var ) );
640 if( CreateChoicesMenu( submenu, psz_var, p_object, true ) == 0)
641 menu->addMenu( submenu );
644 CreateChoicesMenu( menu, psz_var, p_object, true );
645 FREENULL( text.psz_string );
649 #define TEXT_OR_VAR qfu ( text.psz_string ? text.psz_string : psz_var )
651 switch( i_type & VLC_VAR_TYPE )
654 var_Get( p_object, psz_var, &val );
655 CreateAndConnect( menu, psz_var, TEXT_OR_VAR, "", ITEM_NORMAL,
656 p_object->i_object_id, val, i_type );
660 var_Get( p_object, psz_var, &val );
661 CreateAndConnect( menu, psz_var, TEXT_OR_VAR, "", ITEM_CHECK,
662 p_object->i_object_id, val, i_type, val.b_bool );
665 FREENULL( text.psz_string );
669 int QVLCMenu::CreateChoicesMenu( QMenu *submenu, const char *psz_var,
670 vlc_object_t *p_object, bool b_root )
672 vlc_value_t val, val_list, text_list;
675 /* Check the type of the object variable */
676 i_type = var_Type( p_object, psz_var );
678 /* Make sure we want to display the variable */
679 if( IsMenuEmpty( psz_var, p_object, b_root ) ) return VLC_EGENERIC;
681 switch( i_type & VLC_VAR_TYPE )
685 case VLC_VAR_VARIABLE:
687 case VLC_VAR_INTEGER:
691 /* Variable doesn't exist or isn't handled */
695 if( var_Change( p_object, psz_var, VLC_VAR_GETLIST,
696 &val_list, &text_list ) < 0 )
700 #define NORMAL_OR_RADIO i_type & VLC_VAR_ISCOMMAND ? ITEM_NORMAL: ITEM_RADIO
701 #define NOTCOMMAND !(i_type & VLC_VAR_ISCOMMAND)
702 #define CURVAL val_list.p_list->p_values[i]
703 #define CURTEXT text_list.p_list->p_values[i].psz_string
705 for( i = 0; i < val_list.p_list->i_count; i++ )
707 vlc_value_t another_val;
709 QMenu *subsubmenu = new QMenu();
711 switch( i_type & VLC_VAR_TYPE )
713 case VLC_VAR_VARIABLE:
714 CreateChoicesMenu( subsubmenu, CURVAL.psz_string, p_object, false );
715 subsubmenu->setTitle( qfu( CURTEXT ? CURTEXT :CURVAL.psz_string ) );
716 submenu->addMenu( subsubmenu );
720 var_Get( p_object, psz_var, &val );
721 another_val.psz_string = strdup( CURVAL.psz_string );
722 menutext = qfu( CURTEXT ? CURTEXT : another_val.psz_string );
723 CreateAndConnect( submenu, psz_var, menutext, "", NORMAL_OR_RADIO,
724 p_object->i_object_id, another_val, i_type,
725 NOTCOMMAND && val.psz_string &&
726 !strcmp( val.psz_string, CURVAL.psz_string ) );
728 if( val.psz_string ) free( val.psz_string );
731 case VLC_VAR_INTEGER:
732 var_Get( p_object, psz_var, &val );
733 if( CURTEXT ) menutext = qfu( CURTEXT );
734 else menutext.sprintf( "%d", CURVAL.i_int);
735 CreateAndConnect( submenu, psz_var, menutext, "", NORMAL_OR_RADIO,
736 p_object->i_object_id, CURVAL, i_type,
737 NOTCOMMAND && CURVAL.i_int == val.i_int );
741 var_Get( p_object, psz_var, &val );
742 if( CURTEXT ) menutext = qfu( CURTEXT );
743 else menutext.sprintf( "%.2f", CURVAL.f_float );
744 CreateAndConnect( submenu, psz_var, menutext, "", NORMAL_OR_RADIO,
745 p_object->i_object_id, CURVAL, i_type,
746 NOTCOMMAND && CURVAL.f_float == val.f_float );
755 /* clean up everything */
756 var_Change( p_object, psz_var, VLC_VAR_FREELIST, &val_list, &text_list );
758 #undef NORMAL_OR_RADIO
765 void QVLCMenu::CreateAndConnect( QMenu *menu, const char *psz_var,
766 QString text, QString help,
767 int i_item_type, int i_object_id,
768 vlc_value_t val, int i_val_type,
771 QAction *action = new QAction( text, menu );
772 action->setText( text );
773 action->setToolTip( help );
775 if( i_item_type == ITEM_CHECK )
777 action->setCheckable( true );
779 else if( i_item_type == ITEM_RADIO )
781 action->setCheckable( true );
783 currentGroup = new QActionGroup(menu);
784 currentGroup->addAction( action );
789 action->setChecked( true );
791 MenuItemData *itemData = new MenuItemData( i_object_id, i_val_type,
793 CONNECT( action, triggered(), THEDP->menusMapper, map() );
794 THEDP->menusMapper->setMapping( action, itemData );
795 menu->addAction( action );
798 void QVLCMenu::DoAction( intf_thread_t *p_intf, QObject *data )
800 MenuItemData *itemData = qobject_cast<MenuItemData *>(data);
801 vlc_object_t *p_object = (vlc_object_t *)vlc_object_get( p_intf,
802 itemData->i_object_id );
803 if( p_object == NULL ) return;
805 var_Set( p_object, itemData->psz_var, itemData->val );
806 vlc_object_release( p_object );