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_EXT), "","",extendedDialog() );
187 menu->addSeparator();
188 QAction *adv = menu->addAction( qtr("Advanced controls" ),
189 mi, SLOT( advanced() ) );
190 adv->setCheckable( true );
191 if( adv_controls_enabled ) adv->setChecked( true );
193 adv = menu->addAction( qtr("Visualizations selector" ),
194 mi, SLOT( visual() ) );
195 adv->setCheckable( true );
196 if( visual_selector_enabled ) adv->setChecked( true );
199 menu->addSeparator();
200 DP_SADD( qtr("Preferences"), "", "", prefsDialog() );
204 QMenu *QVLCMenu::InterfacesMenu( intf_thread_t *p_intf, QMenu *current )
207 vector<const char *> varnames;
208 /** \todo add "switch to XXX" */
209 varnames.push_back( "intf-add" );
210 objects.push_back( p_intf->i_object_id );
212 QMenu *menu = Populate( p_intf, current, varnames, objects );
214 if( !p_intf->pf_show_dialog )
216 menu->addSeparator();
217 menu->addAction( qtr("Switch to skins"), THEDP, SLOT(switchToSkins()) );
220 CONNECT( menu, aboutToShow(), THEDP->menusUpdateMapper, map() );
221 THEDP->menusUpdateMapper->setMapping( menu, 4 );
225 QMenu *QVLCMenu::AudioMenu( intf_thread_t *p_intf, QMenu * current )
228 vector<const char *> varnames;
230 vlc_object_t *p_object = (vlc_object_t *)vlc_object_find( p_intf,
231 VLC_OBJECT_INPUT, FIND_ANYWHERE );
232 if( p_object != NULL )
234 PUSH_VAR( "audio-es" );
235 vlc_object_release( p_object );
238 p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
242 AudioAutoMenuBuilder( p_object, objects, varnames );
243 vlc_object_release( p_object );
245 return Populate( p_intf, current, varnames, objects );
249 QMenu *QVLCMenu::VideoMenu( intf_thread_t *p_intf, QMenu *current )
251 vlc_object_t *p_object;
253 vector<const char *> varnames;
255 p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
257 if( p_object != NULL )
259 PUSH_VAR( "video-es" );
260 PUSH_VAR( "spu-es" );
261 vlc_object_release( p_object );
264 p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
266 if( p_object != NULL )
268 VideoAutoMenuBuilder( p_object, objects, varnames );
269 vlc_object_release( p_object );
271 return Populate( p_intf, current, varnames, objects );
274 QMenu *QVLCMenu::NavigMenu( intf_thread_t *p_intf, QMenu *current )
276 vlc_object_t *p_object;
278 vector<const char *> varnames;
281 p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
283 if( p_object != NULL )
285 InputAutoMenuBuilder( p_object, objects, varnames );
286 PUSH_VAR( "prev-title"); PUSH_VAR ( "next-title" );
287 PUSH_VAR( "prev-chapter"); PUSH_VAR( "next-chapter" );
288 vlc_object_release( p_object );
290 return Populate( p_intf, current, varnames, objects );
293 QMenu *QVLCMenu::SDMenu( intf_thread_t *p_intf )
295 QMenu *menu = new QMenu();
296 menu->setTitle( qtr(I_PL_SD) );
297 vlc_list_t *p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE,
300 for( int i_index = 0 ; i_index < p_list->i_count; i_index++ )
302 module_t * p_parser = (module_t *)p_list->p_values[i_index].p_object ;
303 if( !strcmp( p_parser->psz_capability, "services_discovery" ) )
306 for( int i_index = 0 ; i_index < p_list->i_count; i_index++ )
308 module_t * p_parser = (module_t *)p_list->p_values[i_index].p_object;
309 if( !strcmp( p_parser->psz_capability, "services_discovery" ) )
311 QAction *a = new QAction( qfu( p_parser->psz_longname ), menu );
312 a->setCheckable( true );
313 /* hack to handle submodules properly */
315 while( p_parser->pp_shortcuts[++i] != NULL );
317 if( playlist_IsServicesDiscoveryLoaded( THEPL,
318 i>=0?p_parser->pp_shortcuts[i] : p_parser->psz_object_name ) )
320 a->setChecked( true );
322 CONNECT( a , triggered(), THEDP->SDMapper, map() );
323 THEDP->SDMapper->setMapping( a, i>=0? p_parser->pp_shortcuts[i] :
324 p_parser->psz_object_name );
325 menu->addAction( a );
328 vlc_list_release( p_list );
332 QMenu *QVLCMenu::HelpMenu()
334 QMenu *menu = new QMenu();
335 DP_SADD( qtr("Help") , "", "", helpDialog() );
336 menu->addSeparator();
337 DP_SADD( qtr(I_MENU_ABOUT), "", "", aboutDialog() );
342 /*****************************************************************************
344 *****************************************************************************/
345 #define POPUP_BOILERPLATE \
346 unsigned int i_last_separator = 0; \
347 vector<int> objects; \
348 vector<const char *> varnames; \
349 input_thread_t *p_input = THEMIM->getInput();
351 #define CREATE_POPUP \
352 QMenu *menu = new QMenu(); \
353 Populate( p_intf, menu, varnames, objects ); \
354 p_intf->p_sys->p_popup_menu = menu; \
355 menu->popup( QCursor::pos() ); \
356 p_intf->p_sys->p_popup_menu = NULL; \
357 i_last_separator = 0;
359 #define POPUP_STATIC_ENTRIES \
361 MIM_SADD( qtr("Stop"), "", "", stop() ); \
362 MIM_SADD( qtr("Previous"), "", "", prev() ); \
363 MIM_SADD( qtr("Next"), "", "", next() ); \
366 var_Get( p_input, "state", &val ); \
367 if( val.i_int == PAUSE_S ) \
368 MIM_SADD( qtr("Play"), "", "", togglePlayPause() ) \
370 MIM_SADD( qtr("Pause"), "", "", togglePlayPause() ) \
372 else if( THEPL->items.i_size && THEPL->i_enabled ) \
373 MIM_SADD( qtr("Play"), "", "", togglePlayPause() ) \
375 QMenu *intfmenu = InterfacesMenu( p_intf, NULL ); \
376 intfmenu->setTitle( qtr("Interfaces" ) ); \
377 menu->addMenu( intfmenu ); \
379 QMenu *toolsmenu = ToolsMenu( p_intf, NULL, false, false ); \
380 toolsmenu->setTitle( qtr("Tools" ) ); \
381 menu->addMenu( toolsmenu ); \
383 void QVLCMenu::VideoPopupMenu( intf_thread_t *p_intf )
388 vlc_object_yield( p_input );
389 varnames.push_back( "video-es" );
390 objects.push_back( p_input->i_object_id );
391 varnames.push_back( "spu-es" );
392 objects.push_back( p_input->i_object_id );
393 vlc_object_t *p_vout = (vlc_object_t *)vlc_object_find( p_input,
394 VLC_OBJECT_VOUT, FIND_CHILD );
397 VideoAutoMenuBuilder( p_vout, objects, varnames );
398 vlc_object_release( p_vout );
400 vlc_object_release( p_input );
405 void QVLCMenu::AudioPopupMenu( intf_thread_t *p_intf )
410 vlc_object_yield( p_input );
411 varnames.push_back( "audio-es" );
412 objects.push_back( p_input->i_object_id );
413 vlc_object_t *p_aout = (vlc_object_t *)vlc_object_find( p_input,
414 VLC_OBJECT_AOUT, FIND_ANYWHERE );
417 AudioAutoMenuBuilder( p_aout, objects, varnames );
418 vlc_object_release( p_aout );
420 vlc_object_release( p_input );
425 /* Navigation stuff, and general */
426 void QVLCMenu::MiscPopupMenu( intf_thread_t *p_intf )
431 vlc_object_yield( p_input );
432 varnames.push_back( "audio-es" );
433 InputAutoMenuBuilder( VLC_OBJECT(p_input), objects, varnames );
437 QMenu *menu = new QMenu();
438 Populate( p_intf, menu, varnames, objects );
439 menu->addSeparator();
440 POPUP_STATIC_ENTRIES;
442 p_intf->p_sys->p_popup_menu = menu;
443 menu->popup( QCursor::pos() );
444 p_intf->p_sys->p_popup_menu = NULL;
447 void QVLCMenu::PopupMenu( intf_thread_t *p_intf )
452 vlc_object_yield( p_input );
453 InputAutoMenuBuilder( VLC_OBJECT(p_input), objects, varnames );
457 varnames.push_back( "video-es" );
458 objects.push_back( p_input->i_object_id );
459 varnames.push_back( "spu-es" );
460 objects.push_back( p_input->i_object_id );
461 vlc_object_t *p_vout = (vlc_object_t *)vlc_object_find( p_input,
462 VLC_OBJECT_VOUT, FIND_CHILD );
465 VideoAutoMenuBuilder( p_vout, objects, varnames );
466 vlc_object_release( p_vout );
470 varnames.push_back( "audio-es" );
471 objects.push_back( p_input->i_object_id );
472 vlc_object_t *p_aout = (vlc_object_t *)vlc_object_find( p_input,
473 VLC_OBJECT_AOUT, FIND_ANYWHERE );
476 AudioAutoMenuBuilder( p_aout, objects, varnames );
477 vlc_object_release( p_aout );
481 QMenu *menu = new QMenu();
482 Populate( p_intf, menu, varnames, objects );
483 menu->addSeparator();
484 POPUP_STATIC_ENTRIES;
486 p_intf->p_sys->p_popup_menu = menu;
487 menu->popup( QCursor::pos() );
488 p_intf->p_sys->p_popup_menu = NULL;
492 #undef PUSH_SEPARATOR
494 /*************************************************************************
495 * Builders for automenus
496 *************************************************************************/
497 QMenu * QVLCMenu::Populate( intf_thread_t *p_intf, QMenu *current,
498 vector< const char *> & varnames,
499 vector<int> & objects, bool append )
501 QMenu *menu = current;
509 vlc_object_t *p_object;
510 vlc_bool_t b_section_empty = VLC_FALSE;
513 #define APPEND_EMPTY { QAction *action = menu->addAction( qtr("Empty" ) ); \
514 action->setEnabled( false ); }
516 for( i = 0; i < (int)objects.size() ; i++ )
518 if( !varnames[i] || !*varnames[i] )
520 if( b_section_empty )
522 menu->addSeparator();
523 b_section_empty = VLC_TRUE;
527 if( objects[i] == 0 )
529 /// \bug What is this ?
530 // Append( menu, varnames[i], NULL );
531 b_section_empty = VLC_FALSE;
535 p_object = (vlc_object_t *)vlc_object_get( p_intf,
537 if( p_object == NULL ) continue;
539 b_section_empty = VLC_FALSE;
540 /* Ugly specific stuff */
541 if( strstr(varnames[i], "intf-add" ) )
542 CreateItem( menu, varnames[i], p_object, false );
544 CreateItem( menu, varnames[i], p_object, true );
545 vlc_object_release( p_object );
548 /* Special case for empty menus */
549 if( menu->actions().size() == 0 || b_section_empty )
555 /*****************************************************************************
557 *****************************************************************************/
559 static bool IsMenuEmpty( const char *psz_var, vlc_object_t *p_object,
562 vlc_value_t val, val_list;
563 int i_type, i_result, i;
565 /* Check the type of the object variable */
566 i_type = var_Type( p_object, psz_var );
568 /* Check if we want to display the variable */
569 if( !(i_type & VLC_VAR_HASCHOICE) ) return FALSE;
571 var_Change( p_object, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL );
572 if( val.i_int == 0 ) return TRUE;
574 if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE )
576 /* Very evil hack ! intf-switch can have only one value */
577 if( !strcmp( psz_var, "intf-switch" ) ) return FALSE;
578 if( val.i_int == 1 && b_root ) return TRUE;
582 /* Check children variables in case of VLC_VAR_VARIABLE */
583 if( var_Change( p_object, psz_var, VLC_VAR_GETLIST, &val_list, NULL ) < 0 )
588 for( i = 0, i_result = TRUE; i < val_list.p_list->i_count; i++ )
590 if( !IsMenuEmpty( val_list.p_list->p_values[i].psz_string,
598 /* clean up everything */
599 var_Change( p_object, psz_var, VLC_VAR_FREELIST, &val_list, NULL );
604 void QVLCMenu::CreateItem( QMenu *menu, const char *psz_var,
605 vlc_object_t *p_object, bool b_submenu )
607 vlc_value_t val, text;
610 /* Check the type of the object variable */
611 i_type = var_Type( p_object, psz_var );
613 switch( i_type & VLC_VAR_TYPE )
617 case VLC_VAR_VARIABLE:
619 case VLC_VAR_INTEGER:
623 /* Variable doesn't exist or isn't handled */
627 /* Make sure we want to display the variable */
628 if( IsMenuEmpty( psz_var, p_object ) ) return;
630 /* Get the descriptive name of the variable */
631 var_Change( p_object, psz_var, VLC_VAR_GETTEXT, &text, NULL );
633 if( i_type & VLC_VAR_HASCHOICE )
635 /* Append choices menu */
638 QMenu *submenu = new QMenu();
639 submenu->setTitle( qfu( text.psz_string ?
640 text.psz_string : psz_var ) );
641 if( CreateChoicesMenu( submenu, psz_var, p_object, true ) == 0)
642 menu->addMenu( submenu );
645 CreateChoicesMenu( menu, psz_var, p_object, true );
646 FREENULL( text.psz_string );
650 #define TEXT_OR_VAR qfu ( text.psz_string ? text.psz_string : psz_var )
652 switch( i_type & VLC_VAR_TYPE )
655 var_Get( p_object, psz_var, &val );
656 CreateAndConnect( menu, psz_var, TEXT_OR_VAR, "", ITEM_NORMAL,
657 p_object->i_object_id, val, i_type );
661 var_Get( p_object, psz_var, &val );
662 CreateAndConnect( menu, psz_var, TEXT_OR_VAR, "", ITEM_CHECK,
663 p_object->i_object_id, val, i_type, val.b_bool );
666 FREENULL( text.psz_string );
670 int QVLCMenu::CreateChoicesMenu( QMenu *submenu, const char *psz_var,
671 vlc_object_t *p_object, bool b_root )
673 vlc_value_t val, val_list, text_list;
676 /* Check the type of the object variable */
677 i_type = var_Type( p_object, psz_var );
679 /* Make sure we want to display the variable */
680 if( IsMenuEmpty( psz_var, p_object, b_root ) ) return VLC_EGENERIC;
682 switch( i_type & VLC_VAR_TYPE )
686 case VLC_VAR_VARIABLE:
688 case VLC_VAR_INTEGER:
692 /* Variable doesn't exist or isn't handled */
696 if( var_Change( p_object, psz_var, VLC_VAR_GETLIST,
697 &val_list, &text_list ) < 0 )
701 #define NORMAL_OR_RADIO i_type & VLC_VAR_ISCOMMAND ? ITEM_NORMAL: ITEM_RADIO
702 #define NOTCOMMAND !(i_type & VLC_VAR_ISCOMMAND)
703 #define CURVAL val_list.p_list->p_values[i]
704 #define CURTEXT text_list.p_list->p_values[i].psz_string
706 for( i = 0; i < val_list.p_list->i_count; i++ )
708 vlc_value_t another_val;
710 QMenu *subsubmenu = new QMenu();
712 switch( i_type & VLC_VAR_TYPE )
714 case VLC_VAR_VARIABLE:
715 CreateChoicesMenu( subsubmenu, CURVAL.psz_string, p_object, false );
716 subsubmenu->setTitle( qfu( CURTEXT ? CURTEXT :CURVAL.psz_string ) );
717 submenu->addMenu( subsubmenu );
721 var_Get( p_object, psz_var, &val );
722 another_val.psz_string = strdup( CURVAL.psz_string );
723 menutext = qfu( CURTEXT ? CURTEXT : another_val.psz_string );
724 CreateAndConnect( submenu, psz_var, menutext, "", NORMAL_OR_RADIO,
725 p_object->i_object_id, another_val, i_type,
726 NOTCOMMAND && val.psz_string &&
727 !strcmp( val.psz_string, CURVAL.psz_string ) );
729 if( val.psz_string ) free( val.psz_string );
732 case VLC_VAR_INTEGER:
733 var_Get( p_object, psz_var, &val );
734 if( CURTEXT ) menutext = qfu( CURTEXT );
735 else menutext.sprintf( "%d", CURVAL.i_int);
736 CreateAndConnect( submenu, psz_var, menutext, "", NORMAL_OR_RADIO,
737 p_object->i_object_id, CURVAL, i_type,
738 NOTCOMMAND && CURVAL.i_int == val.i_int );
742 var_Get( p_object, psz_var, &val );
743 if( CURTEXT ) menutext = qfu( CURTEXT );
744 else menutext.sprintf( "%.2f", CURVAL.f_float );
745 CreateAndConnect( submenu, psz_var, menutext, "", NORMAL_OR_RADIO,
746 p_object->i_object_id, CURVAL, i_type,
747 NOTCOMMAND && CURVAL.f_float == val.f_float );
756 /* clean up everything */
757 var_Change( p_object, psz_var, VLC_VAR_FREELIST, &val_list, &text_list );
759 #undef NORMAL_OR_RADIO
766 void QVLCMenu::CreateAndConnect( QMenu *menu, const char *psz_var,
767 QString text, QString help,
768 int i_item_type, int i_object_id,
769 vlc_value_t val, int i_val_type,
772 QAction *action = new QAction( text, menu );
773 action->setText( text );
774 action->setToolTip( help );
776 if( i_item_type == ITEM_CHECK )
778 action->setCheckable( true );
780 else if( i_item_type == ITEM_RADIO )
782 action->setCheckable( true );
784 currentGroup = new QActionGroup(menu);
785 currentGroup->addAction( action );
790 action->setChecked( true );
792 MenuItemData *itemData = new MenuItemData( i_object_id, i_val_type,
794 CONNECT( action, triggered(), THEDP->menusMapper, map() );
795 THEDP->menusMapper->setMapping( action, itemData );
796 menu->addAction( action );
799 void QVLCMenu::DoAction( intf_thread_t *p_intf, QObject *data )
801 MenuItemData *itemData = qobject_cast<MenuItemData *>(data);
802 vlc_object_t *p_object = (vlc_object_t *)vlc_object_get( p_intf,
803 itemData->i_object_id );
804 if( p_object == NULL ) return;
806 var_Set( p_object, itemData->psz_var, itemData->val );
807 vlc_object_release( p_object );