1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2006-2007 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>
34 #include <vlc_intf_strings.h>
36 #include "main_interface.hpp"
38 #include "dialogs_provider.hpp"
39 #include "input_manager.hpp"
48 static QActionGroup *currentGroup;
50 // Add static entries to menus
51 #define DP_SADD( text, help, icon, slot ) \
53 if( strlen(icon) > 0 ) \
55 QAction *action = menu->addAction( text, THEDP, SLOT( slot ) ); \
56 action->setIcon(QIcon(icon)); \
60 menu->addAction( text, THEDP, SLOT( slot ) ); \
63 #define MIM_SADD( text, help, icon, slot ) \
65 if( strlen(icon) > 0 ) \
67 QAction *action = menu->addAction( text, THEMIM, SLOT( slot ) ); \
68 action->setIcon(QIcon(icon)); \
72 menu->addAction( text, THEMIM, SLOT( slot ) ); \
77 /*****************************************************************************
78 * Definitions of variables for the dynamic menus
79 *****************************************************************************/
80 #define PUSH_VAR( var ) varnames.push_back( var ); \
81 objects.push_back( p_object->i_object_id )
83 #define PUSH_SEPARATOR if( objects.size() != i_last_separator ) { \
84 objects.push_back( 0 ); varnames.push_back( "" ); \
85 i_last_separator = objects.size(); }
87 static int InputAutoMenuBuilder( vlc_object_t *p_object,
89 vector<const char *> &varnames )
91 PUSH_VAR( "bookmark");
93 PUSH_VAR ("chapter" );
94 PUSH_VAR( "program" );
95 PUSH_VAR( "navigation" );
96 PUSH_VAR( "dvd_menus" );
100 static int VideoAutoMenuBuilder( vlc_object_t *p_object,
101 vector<int> &objects,
102 vector<const char *> &varnames )
104 PUSH_VAR( "fullscreen" );
106 PUSH_VAR( "deinterlace" );
107 PUSH_VAR( "aspect-ratio" );
109 PUSH_VAR( "video-on-top" );
110 PUSH_VAR( "directx-wallpaper" );
111 PUSH_VAR( "video-snapshot" );
113 vlc_object_t *p_dec_obj = (vlc_object_t *)vlc_object_find( p_object,
116 if( p_dec_obj != NULL )
118 vlc_object_t *p_object = p_dec_obj;
119 PUSH_VAR( "ffmpeg-pp-q" );
120 vlc_object_release( p_dec_obj );
125 static int AudioAutoMenuBuilder( vlc_object_t *p_object,
126 vector<int> &objects,
127 vector<const char *> &varnames )
129 PUSH_VAR( "audio-device" );
130 PUSH_VAR( "audio-channels" );
131 PUSH_VAR( "visual" );
132 PUSH_VAR( "equalizer" );
136 /*****************************************************************************
138 *****************************************************************************/
140 #define BAR_ADD( func, title ) { \
141 QMenu *menu = func; menu->setTitle( title ); bar->addMenu( menu ); }
143 #define BAR_DADD( func, title, id ) { \
144 QMenu *menu = func; menu->setTitle( title ); bar->addMenu( menu ); \
145 MenuFunc *f = new MenuFunc( menu, id ); \
146 CONNECT( menu, aboutToShow(), THEDP->menusUpdateMapper, map() ); \
147 THEDP->menusUpdateMapper->setMapping( menu, f ); }
149 void QVLCMenu::createMenuBar( MainInterface *mi, intf_thread_t *p_intf,
150 bool playlist, bool adv_controls_enabled,
151 bool visual_selector_enabled )
155 * Remove SIGCHLD from the ignored signal the time to initialise
156 * Qt because it call gconf to get the icon theme */
160 sigaddset( &set, SIGCHLD );
161 pthread_sigmask (SIG_UNBLOCK, &set, NULL);
163 QMenuBar *bar = mi->menuBar();
165 pthread_sigmask (SIG_BLOCK, &set, NULL);
167 BAR_ADD( FileMenu(), qtr("Media") );
170 BAR_ADD( PlaylistMenu( mi,p_intf ), qtr("Playlist" ) );
172 BAR_ADD( ToolsMenu( p_intf, mi, adv_controls_enabled,
173 visual_selector_enabled ), qtr("Tools") );
174 BAR_DADD( VideoMenu( p_intf, NULL ), qtr("Video"), 1 );
175 BAR_DADD( AudioMenu( p_intf, NULL ), qtr("Audio"), 2 );
176 BAR_DADD( NavigMenu( p_intf, NULL ), qtr("Navigation"), 3 );
178 BAR_ADD( HelpMenu(), qtr("Help" ) );
180 QMenu *QVLCMenu::FileMenu()
182 QMenu *menu = new QMenu();
183 /* DP_SADD( qtr("Quick &Open File...") , "", "", simpleOpenDialog() );*/
184 DP_SADD( qtr("Open &File..." ), "", "", openFileDialog() );
185 DP_SADD( qtr("Open &Disc..." ), "", "", openDiscDialog());
186 DP_SADD( qtr("Open &Network..." ), "", "", openNetDialog());
187 DP_SADD( qtr("Open &Capture Device..." ), "", "", openCaptureDialog());
188 menu->addSeparator();
189 DP_SADD( qtr("&Streaming..."), "", "", streamingDialog() );
190 menu->addSeparator();
191 DP_SADD( qtr("&Quit") , "", "", quit() );
195 QMenu *QVLCMenu::PlaylistMenu( MainInterface *mi, intf_thread_t *p_intf )
197 QMenu *menu = new QMenu();
198 menu->addMenu( SDMenu( p_intf ) );
199 menu->addSeparator();
201 DP_SADD( qtr(I_PL_LOAD), "", "", openPlaylist() );
202 DP_SADD( qtr(I_PL_SAVE), "", "", savePlaylist() );
203 menu->addSeparator();
204 menu->addAction( qtr("Undock from interface"), mi,
205 SLOT( undockPlaylist() ) );
209 QMenu *QVLCMenu::ToolsMenu( intf_thread_t *p_intf, MainInterface *mi,
210 bool adv_controls_enabled,
211 bool visual_selector_enabled, bool with_intf )
213 QMenu *menu = new QMenu();
216 QMenu *intfmenu = InterfacesMenu( p_intf, NULL );
217 intfmenu->setTitle( qtr("Interfaces" ) );
218 menu->addMenu( intfmenu );
219 menu->addSeparator();
221 DP_SADD( qtr(I_MENU_MSG), "", "", messagesDialog() );
222 DP_SADD( qtr(I_MENU_INFO) , "", "", mediaInfoDialog() );
223 DP_SADD( qtr(I_MENU_CODECINFO) , "", "", mediaCodecDialog() );
224 DP_SADD( qtr(I_MENU_EXT), "","",extendedDialog() );
227 menu->addSeparator();
228 QAction *adv = menu->addAction( qtr("Advanced controls" ),
229 mi, SLOT( advanced() ) );
230 adv->setCheckable( true );
231 if( adv_controls_enabled ) adv->setChecked( true );
233 adv = menu->addAction( qtr("Visualizations selector" ),
234 mi, SLOT( visual() ) );
235 adv->setCheckable( true );
236 if( visual_selector_enabled ) adv->setChecked( true );
239 menu->addSeparator();
240 DP_SADD( qtr("Preferences"), "", "", prefsDialog() );
244 QMenu *QVLCMenu::InterfacesMenu( intf_thread_t *p_intf, QMenu *current )
247 vector<const char *> varnames;
248 /** \todo add "switch to XXX" */
249 varnames.push_back( "intf-add" );
250 objects.push_back( p_intf->i_object_id );
252 QMenu *menu = Populate( p_intf, current, varnames, objects );
254 if( !p_intf->pf_show_dialog )
256 menu->addSeparator();
257 menu->addAction( qtr("Switch to skins"), THEDP, SLOT(switchToSkins()) );
260 CONNECT( menu, aboutToShow(), THEDP->menusUpdateMapper, map() );
261 THEDP->menusUpdateMapper->setMapping( menu, 4 );
265 QMenu *QVLCMenu::AudioMenu( intf_thread_t *p_intf, QMenu * current )
268 vector<const char *> varnames;
270 vlc_object_t *p_object = (vlc_object_t *)vlc_object_find( p_intf,
271 VLC_OBJECT_INPUT, FIND_ANYWHERE );
272 if( p_object != NULL )
274 PUSH_VAR( "audio-es" );
275 vlc_object_release( p_object );
278 p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
282 AudioAutoMenuBuilder( p_object, objects, varnames );
283 vlc_object_release( p_object );
285 return Populate( p_intf, current, varnames, objects );
289 QMenu *QVLCMenu::VideoMenu( intf_thread_t *p_intf, QMenu *current )
291 vlc_object_t *p_object;
293 vector<const char *> varnames;
295 p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
297 if( p_object != NULL )
299 PUSH_VAR( "video-es" );
300 PUSH_VAR( "spu-es" );
301 vlc_object_release( p_object );
304 p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
306 if( p_object != NULL )
308 VideoAutoMenuBuilder( p_object, objects, varnames );
309 vlc_object_release( p_object );
311 return Populate( p_intf, current, varnames, objects );
314 QMenu *QVLCMenu::NavigMenu( intf_thread_t *p_intf, QMenu *current )
316 vlc_object_t *p_object;
318 vector<const char *> varnames;
321 p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
323 if( p_object != NULL )
325 InputAutoMenuBuilder( p_object, objects, varnames );
326 PUSH_VAR( "prev-title"); PUSH_VAR ( "next-title" );
327 PUSH_VAR( "prev-chapter"); PUSH_VAR( "next-chapter" );
328 vlc_object_release( p_object );
330 return Populate( p_intf, current, varnames, objects );
333 QMenu *QVLCMenu::SDMenu( intf_thread_t *p_intf )
335 QMenu *menu = new QMenu();
336 menu->setTitle( qtr(I_PL_SD) );
337 vlc_list_t *p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE,
340 for( int i_index = 0 ; i_index < p_list->i_count; i_index++ )
342 module_t * p_parser = (module_t *)p_list->p_values[i_index].p_object ;
343 if( !strcmp( p_parser->psz_capability, "services_discovery" ) )
346 for( int i_index = 0 ; i_index < p_list->i_count; i_index++ )
348 module_t * p_parser = (module_t *)p_list->p_values[i_index].p_object;
349 if( !strcmp( p_parser->psz_capability, "services_discovery" ) )
351 QAction *a = new QAction( qfu( p_parser->psz_longname ), menu );
352 a->setCheckable( true );
353 /* hack to handle submodules properly */
355 while( p_parser->pp_shortcuts[++i] != NULL );
357 if( playlist_IsServicesDiscoveryLoaded( THEPL,
358 i>=0?p_parser->pp_shortcuts[i] : p_parser->psz_object_name ) )
360 a->setChecked( true );
362 CONNECT( a , triggered(), THEDP->SDMapper, map() );
363 THEDP->SDMapper->setMapping( a, i>=0? p_parser->pp_shortcuts[i] :
364 p_parser->psz_object_name );
365 menu->addAction( a );
368 vlc_list_release( p_list );
372 QMenu *QVLCMenu::HelpMenu()
374 QMenu *menu = new QMenu();
375 DP_SADD( qtr("Help") , "", "", helpDialog() );
376 menu->addSeparator();
377 DP_SADD( qtr(I_MENU_ABOUT), "", "", aboutDialog() );
382 /*****************************************************************************
384 *****************************************************************************/
385 #define POPUP_BOILERPLATE \
386 unsigned int i_last_separator = 0; \
387 vector<int> objects; \
388 vector<const char *> varnames; \
389 input_thread_t *p_input = THEMIM->getInput();
391 #define CREATE_POPUP \
392 QMenu *menu = new QMenu(); \
393 Populate( p_intf, menu, varnames, objects ); \
394 p_intf->p_sys->p_popup_menu = menu; \
395 menu->popup( QCursor::pos() ); \
396 p_intf->p_sys->p_popup_menu = NULL; \
397 i_last_separator = 0;
399 #define POPUP_STATIC_ENTRIES \
401 MIM_SADD( qtr("Stop"), "", "", stop() ); \
402 MIM_SADD( qtr("Previous"), "", "", prev() ); \
403 MIM_SADD( qtr("Next"), "", "", next() ); \
406 var_Get( p_input, "state", &val ); \
407 if( val.i_int == PAUSE_S ) \
408 MIM_SADD( qtr("Play"), "", "", togglePlayPause() ) \
410 MIM_SADD( qtr("Pause"), "", "", togglePlayPause() ) \
412 else if( THEPL->items.i_size && THEPL->i_enabled ) \
413 MIM_SADD( qtr("Play"), "", "", togglePlayPause() ) \
415 QMenu *intfmenu = InterfacesMenu( p_intf, NULL ); \
416 intfmenu->setTitle( qtr("Interfaces" ) ); \
417 menu->addMenu( intfmenu ); \
419 QMenu *toolsmenu = ToolsMenu( p_intf, NULL, false, false ); \
420 toolsmenu->setTitle( qtr("Tools" ) ); \
421 menu->addMenu( toolsmenu ); \
423 void QVLCMenu::VideoPopupMenu( intf_thread_t *p_intf )
428 vlc_object_yield( p_input );
429 varnames.push_back( "video-es" );
430 objects.push_back( p_input->i_object_id );
431 varnames.push_back( "spu-es" );
432 objects.push_back( p_input->i_object_id );
433 vlc_object_t *p_vout = (vlc_object_t *)vlc_object_find( p_input,
434 VLC_OBJECT_VOUT, FIND_CHILD );
437 VideoAutoMenuBuilder( p_vout, objects, varnames );
438 vlc_object_release( p_vout );
440 vlc_object_release( p_input );
445 void QVLCMenu::AudioPopupMenu( intf_thread_t *p_intf )
450 vlc_object_yield( p_input );
451 varnames.push_back( "audio-es" );
452 objects.push_back( p_input->i_object_id );
453 vlc_object_t *p_aout = (vlc_object_t *)vlc_object_find( p_input,
454 VLC_OBJECT_AOUT, FIND_ANYWHERE );
457 AudioAutoMenuBuilder( p_aout, objects, varnames );
458 vlc_object_release( p_aout );
460 vlc_object_release( p_input );
465 /* Navigation stuff, and general */
466 void QVLCMenu::MiscPopupMenu( intf_thread_t *p_intf )
471 vlc_object_yield( p_input );
472 varnames.push_back( "audio-es" );
473 InputAutoMenuBuilder( VLC_OBJECT(p_input), objects, varnames );
477 QMenu *menu = new QMenu();
478 Populate( p_intf, menu, varnames, objects );
479 menu->addSeparator();
480 POPUP_STATIC_ENTRIES;
482 p_intf->p_sys->p_popup_menu = menu;
483 menu->popup( QCursor::pos() );
484 p_intf->p_sys->p_popup_menu = NULL;
487 void QVLCMenu::PopupMenu( intf_thread_t *p_intf )
492 vlc_object_yield( p_input );
493 InputAutoMenuBuilder( VLC_OBJECT(p_input), objects, varnames );
497 varnames.push_back( "video-es" );
498 objects.push_back( p_input->i_object_id );
499 varnames.push_back( "spu-es" );
500 objects.push_back( p_input->i_object_id );
501 vlc_object_t *p_vout = (vlc_object_t *)vlc_object_find( p_input,
502 VLC_OBJECT_VOUT, FIND_CHILD );
505 VideoAutoMenuBuilder( p_vout, objects, varnames );
506 vlc_object_release( p_vout );
510 varnames.push_back( "audio-es" );
511 objects.push_back( p_input->i_object_id );
512 vlc_object_t *p_aout = (vlc_object_t *)vlc_object_find( p_input,
513 VLC_OBJECT_AOUT, FIND_ANYWHERE );
516 AudioAutoMenuBuilder( p_aout, objects, varnames );
517 vlc_object_release( p_aout );
521 QMenu *menu = new QMenu();
522 Populate( p_intf, menu, varnames, objects );
523 menu->addSeparator();
524 POPUP_STATIC_ENTRIES;
526 p_intf->p_sys->p_popup_menu = menu;
527 menu->popup( QCursor::pos() );
528 p_intf->p_sys->p_popup_menu = NULL;
532 #undef PUSH_SEPARATOR
534 /*************************************************************************
535 * Builders for automenus
536 *************************************************************************/
537 QMenu * QVLCMenu::Populate( intf_thread_t *p_intf, QMenu *current,
538 vector< const char *> & varnames,
539 vector<int> & objects, bool append )
541 QMenu *menu = current;
549 vlc_object_t *p_object;
550 vlc_bool_t b_section_empty = VLC_FALSE;
553 #define APPEND_EMPTY { QAction *action = menu->addAction( qtr("Empty" ) ); \
554 action->setEnabled( false ); }
556 for( i = 0; i < (int)objects.size() ; i++ )
558 if( !varnames[i] || !*varnames[i] )
560 if( b_section_empty )
562 menu->addSeparator();
563 b_section_empty = VLC_TRUE;
567 if( objects[i] == 0 )
569 /// \bug What is this ?
570 // Append( menu, varnames[i], NULL );
571 b_section_empty = VLC_FALSE;
575 p_object = (vlc_object_t *)vlc_object_get( p_intf,
577 if( p_object == NULL ) continue;
579 b_section_empty = VLC_FALSE;
580 /* Ugly specific stuff */
581 if( strstr(varnames[i], "intf-add" ) )
582 CreateItem( menu, varnames[i], p_object, false );
584 CreateItem( menu, varnames[i], p_object, true );
585 vlc_object_release( p_object );
588 /* Special case for empty menus */
589 if( menu->actions().size() == 0 || b_section_empty )
595 /*****************************************************************************
597 *****************************************************************************/
599 static bool IsMenuEmpty( const char *psz_var, vlc_object_t *p_object,
602 vlc_value_t val, val_list;
603 int i_type, i_result, i;
605 /* Check the type of the object variable */
606 i_type = var_Type( p_object, psz_var );
608 /* Check if we want to display the variable */
609 if( !(i_type & VLC_VAR_HASCHOICE) ) return FALSE;
611 var_Change( p_object, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL );
612 if( val.i_int == 0 ) return TRUE;
614 if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE )
616 /* Very evil hack ! intf-switch can have only one value */
617 if( !strcmp( psz_var, "intf-switch" ) ) return FALSE;
618 if( val.i_int == 1 && b_root ) return TRUE;
622 /* Check children variables in case of VLC_VAR_VARIABLE */
623 if( var_Change( p_object, psz_var, VLC_VAR_GETLIST, &val_list, NULL ) < 0 )
628 for( i = 0, i_result = TRUE; i < val_list.p_list->i_count; i++ )
630 if( !IsMenuEmpty( val_list.p_list->p_values[i].psz_string,
638 /* clean up everything */
639 var_Change( p_object, psz_var, VLC_VAR_FREELIST, &val_list, NULL );
644 void QVLCMenu::CreateItem( QMenu *menu, const char *psz_var,
645 vlc_object_t *p_object, bool b_submenu )
647 vlc_value_t val, text;
650 /* Check the type of the object variable */
651 i_type = var_Type( p_object, psz_var );
653 switch( i_type & VLC_VAR_TYPE )
657 case VLC_VAR_VARIABLE:
659 case VLC_VAR_INTEGER:
663 /* Variable doesn't exist or isn't handled */
667 /* Make sure we want to display the variable */
668 if( IsMenuEmpty( psz_var, p_object ) ) return;
670 /* Get the descriptive name of the variable */
671 var_Change( p_object, psz_var, VLC_VAR_GETTEXT, &text, NULL );
673 if( i_type & VLC_VAR_HASCHOICE )
675 /* Append choices menu */
678 QMenu *submenu = new QMenu();
679 submenu->setTitle( qfu( text.psz_string ?
680 text.psz_string : psz_var ) );
681 if( CreateChoicesMenu( submenu, psz_var, p_object, true ) == 0)
682 menu->addMenu( submenu );
685 CreateChoicesMenu( menu, psz_var, p_object, true );
686 FREENULL( text.psz_string );
690 #define TEXT_OR_VAR qfu ( text.psz_string ? text.psz_string : psz_var )
692 switch( i_type & VLC_VAR_TYPE )
695 var_Get( p_object, psz_var, &val );
696 CreateAndConnect( menu, psz_var, TEXT_OR_VAR, "", ITEM_NORMAL,
697 p_object->i_object_id, val, i_type );
701 var_Get( p_object, psz_var, &val );
702 CreateAndConnect( menu, psz_var, TEXT_OR_VAR, "", ITEM_CHECK,
703 p_object->i_object_id, val, i_type, val.b_bool );
706 FREENULL( text.psz_string );
710 int QVLCMenu::CreateChoicesMenu( QMenu *submenu, const char *psz_var,
711 vlc_object_t *p_object, bool b_root )
713 vlc_value_t val, val_list, text_list;
716 /* Check the type of the object variable */
717 i_type = var_Type( p_object, psz_var );
719 /* Make sure we want to display the variable */
720 if( IsMenuEmpty( psz_var, p_object, b_root ) ) return VLC_EGENERIC;
722 switch( i_type & VLC_VAR_TYPE )
726 case VLC_VAR_VARIABLE:
728 case VLC_VAR_INTEGER:
732 /* Variable doesn't exist or isn't handled */
736 if( var_Change( p_object, psz_var, VLC_VAR_GETLIST,
737 &val_list, &text_list ) < 0 )
741 #define NORMAL_OR_RADIO i_type & VLC_VAR_ISCOMMAND ? ITEM_NORMAL: ITEM_RADIO
742 #define NOTCOMMAND !(i_type & VLC_VAR_ISCOMMAND)
743 #define CURVAL val_list.p_list->p_values[i]
744 #define CURTEXT text_list.p_list->p_values[i].psz_string
746 for( i = 0; i < val_list.p_list->i_count; i++ )
748 vlc_value_t another_val;
750 QMenu *subsubmenu = new QMenu();
752 switch( i_type & VLC_VAR_TYPE )
754 case VLC_VAR_VARIABLE:
755 CreateChoicesMenu( subsubmenu, CURVAL.psz_string, p_object, false );
756 subsubmenu->setTitle( qfu( CURTEXT ? CURTEXT :CURVAL.psz_string ) );
757 submenu->addMenu( subsubmenu );
761 var_Get( p_object, psz_var, &val );
762 another_val.psz_string = strdup( CURVAL.psz_string );
763 menutext = qfu( CURTEXT ? CURTEXT : another_val.psz_string );
764 CreateAndConnect( submenu, psz_var, menutext, "", NORMAL_OR_RADIO,
765 p_object->i_object_id, another_val, i_type,
766 NOTCOMMAND && val.psz_string &&
767 !strcmp( val.psz_string, CURVAL.psz_string ) );
769 if( val.psz_string ) free( val.psz_string );
772 case VLC_VAR_INTEGER:
773 var_Get( p_object, psz_var, &val );
774 if( CURTEXT ) menutext = qfu( CURTEXT );
775 else menutext.sprintf( "%d", CURVAL.i_int);
776 CreateAndConnect( submenu, psz_var, menutext, "", NORMAL_OR_RADIO,
777 p_object->i_object_id, CURVAL, i_type,
778 NOTCOMMAND && CURVAL.i_int == val.i_int );
782 var_Get( p_object, psz_var, &val );
783 if( CURTEXT ) menutext = qfu( CURTEXT );
784 else menutext.sprintf( "%.2f", CURVAL.f_float );
785 CreateAndConnect( submenu, psz_var, menutext, "", NORMAL_OR_RADIO,
786 p_object->i_object_id, CURVAL, i_type,
787 NOTCOMMAND && CURVAL.f_float == val.f_float );
796 /* clean up everything */
797 var_Change( p_object, psz_var, VLC_VAR_FREELIST, &val_list, &text_list );
799 #undef NORMAL_OR_RADIO
806 void QVLCMenu::CreateAndConnect( QMenu *menu, const char *psz_var,
807 QString text, QString help,
808 int i_item_type, int i_object_id,
809 vlc_value_t val, int i_val_type,
812 QAction *action = new QAction( text, menu );
813 action->setText( text );
814 action->setToolTip( help );
816 if( i_item_type == ITEM_CHECK )
818 action->setCheckable( true );
820 else if( i_item_type == ITEM_RADIO )
822 action->setCheckable( true );
824 currentGroup = new QActionGroup(menu);
825 currentGroup->addAction( action );
830 action->setChecked( true );
832 MenuItemData *itemData = new MenuItemData( i_object_id, i_val_type,
834 CONNECT( action, triggered(), THEDP->menusMapper, map() );
835 THEDP->menusMapper->setMapping( action, itemData );
836 menu->addAction( action );
839 void QVLCMenu::DoAction( intf_thread_t *p_intf, QObject *data )
841 MenuItemData *itemData = qobject_cast<MenuItemData *>(data);
842 vlc_object_t *p_object = (vlc_object_t *)vlc_object_get( p_intf,
843 itemData->i_object_id );
844 if( p_object == NULL ) return;
846 var_Set( p_object, itemData->psz_var, itemData->val );
847 vlc_object_release( p_object );