Changeset 5ec2ab65b9da97c218818273f7a8e62cd7eaee09
- Timestamp:
- 17/06/08 04:58:33
(6 months ago)
- Author:
- Jean-Baptiste Kempf <jb@videolan.org>
- git-committer:
- Jean-Baptiste Kempf <jb@videolan.org> 1213671513 -0700
- git-parent:
[514a804f231641c2ca86d96281939df2a3843721]
- git-author:
- Jean-Philippe Andre <jpeg@via.ecp.fr> 1213623610 +0200
- Message:
Qt4 menus: start fixing ticket 1602
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| re00ed66 |
r5ec2ab6 |
|
| 23 | 23 | *****************************************************************************/ |
|---|
| 24 | 24 | |
|---|
| | 25 | /** \todo |
|---|
| | 26 | * - Remove static currentGroup |
|---|
| | 27 | */ |
|---|
| | 28 | |
|---|
| 25 | 29 | #ifdef HAVE_CONFIG_H |
|---|
| 26 | 30 | # include "config.h" |
|---|
| … | … | |
| 98 | 102 | *****************************************************************************/ |
|---|
| 99 | 103 | #define PUSH_VAR( var ) varnames.push_back( var ); \ |
|---|
| 100 | | objects.push_back( p_object->i_object_id ) |
|---|
| | 104 | objects.push_back( p_object ? p_object->i_object_id : 0 ) |
|---|
| | 105 | |
|---|
| | 106 | #define PUSH_INPUTVAR( var ) varnames.push_back( var ); \ |
|---|
| | 107 | objects.push_back( p_input ? p_input->i_object_id : 0 ); |
|---|
| 101 | 108 | |
|---|
| 102 | 109 | #define PUSH_SEPARATOR if( objects.size() != i_last_separator ) { \ |
|---|
| … | … | |
| 118 | 125 | |
|---|
| 119 | 126 | static int VideoAutoMenuBuilder( vlc_object_t *p_object, |
|---|
| | 127 | input_thread_t *p_input, |
|---|
| 120 | 128 | vector<int> &objects, |
|---|
| 121 | 129 | vector<const char *> &varnames ) |
|---|
| 122 | 130 | { |
|---|
| | 131 | PUSH_INPUTVAR( "video-es" ); |
|---|
| | 132 | PUSH_INPUTVAR( "spu-es" ); |
|---|
| 123 | 133 | PUSH_VAR( "fullscreen" ); |
|---|
| 124 | 134 | PUSH_VAR( "zoom" ); |
|---|
| … | … | |
| 130 | 140 | PUSH_VAR( "video-snapshot" ); |
|---|
| 131 | 141 | |
|---|
| 132 | | vlc_object_t *p_dec_obj = ( vlc_object_t * )vlc_object_find( p_object, |
|---|
| 133 | | VLC_OBJECT_DECODER, |
|---|
| 134 | | FIND_PARENT ); |
|---|
| 135 | | if( p_dec_obj != NULL ) |
|---|
| 136 | | { |
|---|
| 137 | | vlc_object_t *p_object = p_dec_obj; |
|---|
| 138 | | PUSH_VAR( "ffmpeg-pp-q" ); |
|---|
| 139 | | vlc_object_release( p_dec_obj ); |
|---|
| | 142 | if( p_object ) |
|---|
| | 143 | { |
|---|
| | 144 | vlc_object_t *p_dec_obj = ( vlc_object_t * )vlc_object_find( p_object, |
|---|
| | 145 | VLC_OBJECT_DECODER, |
|---|
| | 146 | FIND_PARENT ); |
|---|
| | 147 | if( p_dec_obj ) |
|---|
| | 148 | { |
|---|
| | 149 | vlc_object_t *p_object = p_dec_obj; |
|---|
| | 150 | PUSH_VAR( "ffmpeg-pp-q" ); |
|---|
| | 151 | vlc_object_release( p_dec_obj ); |
|---|
| | 152 | } |
|---|
| 140 | 153 | } |
|---|
| 141 | 154 | return VLC_SUCCESS; |
|---|
| … | … | |
| 143 | 156 | |
|---|
| 144 | 157 | static int AudioAutoMenuBuilder( vlc_object_t *p_object, |
|---|
| | 158 | input_thread_t *p_input, |
|---|
| 145 | 159 | vector<int> &objects, |
|---|
| 146 | 160 | vector<const char *> &varnames ) |
|---|
| 147 | 161 | { |
|---|
| | 162 | PUSH_INPUTVAR( "audio-es" ); |
|---|
| 148 | 163 | PUSH_VAR( "audio-device" ); |
|---|
| 149 | 164 | PUSH_VAR( "audio-channels" ); |
|---|
| … | … | |
| 153 | 168 | } |
|---|
| 154 | 169 | |
|---|
| | 170 | static QAction * FindActionWithVar( QMenu *menu, const char *psz_var ) |
|---|
| | 171 | { |
|---|
| | 172 | QAction *action; |
|---|
| | 173 | Q_FOREACH( action, menu->actions() ) |
|---|
| | 174 | { |
|---|
| | 175 | if( action->data().toString() == psz_var ) |
|---|
| | 176 | return action; |
|---|
| | 177 | } |
|---|
| | 178 | return NULL; |
|---|
| | 179 | } |
|---|
| | 180 | |
|---|
| | 181 | static QAction * FindActionWithText( QMenu *menu, QString &text ) |
|---|
| | 182 | { |
|---|
| | 183 | QAction *action; |
|---|
| | 184 | Q_FOREACH( action, menu->actions() ) |
|---|
| | 185 | { |
|---|
| | 186 | if( action->text() == text ) |
|---|
| | 187 | return action; |
|---|
| | 188 | } |
|---|
| | 189 | return NULL; |
|---|
| | 190 | } |
|---|
| | 191 | |
|---|
| 155 | 192 | /***************************************************************************** |
|---|
| 156 | 193 | * All normal menus |
|---|
| … | … | |
| 159 | 196 | |
|---|
| 160 | 197 | #define BAR_ADD( func, title ) { \ |
|---|
| 161 | | QMenu *menu = func; menu->setTitle( title ); bar->addMenu( menu ); } |
|---|
| | 198 | QMenu *_menu = func; _menu->setTitle( title ); bar->addMenu( _menu ); } |
|---|
| 162 | 199 | |
|---|
| 163 | 200 | #define BAR_DADD( func, title, id ) { \ |
|---|
| 164 | | QMenu *menu = func; menu->setTitle( title ); bar->addMenu( menu ); \ |
|---|
| 165 | | MenuFunc *f = new MenuFunc( menu, id ); \ |
|---|
| 166 | | CONNECT( menu, aboutToShow(), THEDP->menusUpdateMapper, map() ); \ |
|---|
| 167 | | THEDP->menusUpdateMapper->setMapping( menu, f ); } |
|---|
| | 201 | QMenu *_menu = func; _menu->setTitle( title ); bar->addMenu( _menu ); \ |
|---|
| | 202 | MenuFunc *f = new MenuFunc( _menu, id ); \ |
|---|
| | 203 | CONNECT( _menu, aboutToShow(), THEDP->menusUpdateMapper, map() ); \ |
|---|
| | 204 | THEDP->menusUpdateMapper->setMapping( _menu, f ); } |
|---|
| | 205 | |
|---|
| | 206 | #define ACT_ADD( _menu, val, title ) { \ |
|---|
| | 207 | QAction *_action = new QAction( title, _menu ); _action->setData( val ); \ |
|---|
| | 208 | _menu->addAction( _action ); } |
|---|
| 168 | 209 | |
|---|
| 169 | 210 | /** |
|---|
| … | … | |
| 182 | 223 | BAR_ADD( ToolsMenu( p_intf, NULL, mi, visual_selector_enabled, true ), |
|---|
| 183 | 224 | qtr( "&Tools" ) ); |
|---|
| 184 | | BAR_DADD( AudioMenu( p_intf, NULL ), qtr( "&Audio" ), 2 ); |
|---|
| 185 | | BAR_DADD( VideoMenu( p_intf, NULL ), qtr( "&Video" ), 1 ); |
|---|
| | 225 | BAR_DADD( AudioMenu( p_intf, NULL ), qtr( "&Audio" ), 1 ); |
|---|
| | 226 | BAR_DADD( VideoMenu( p_intf, NULL ), qtr( "&Video" ), 2 ); |
|---|
| 186 | 227 | BAR_DADD( NavigMenu( p_intf, NULL ), qtr( "&Playback" ), 3 ); |
|---|
| 187 | | |
|---|
| 188 | 228 | BAR_ADD( HelpMenu( NULL ), qtr( "&Help" ) ); |
|---|
| 189 | 229 | } |
|---|
| … | … | |
| 350 | 390 | vector<int> objects; |
|---|
| 351 | 391 | vector<const char *> varnames; |
|---|
| 352 | | |
|---|
| 353 | | vlc_object_t *p_object = ( vlc_object_t * )vlc_object_find( p_intf, |
|---|
| 354 | | VLC_OBJECT_INPUT, FIND_ANYWHERE ); |
|---|
| 355 | | if( p_object != NULL ) |
|---|
| 356 | | { |
|---|
| 357 | | PUSH_VAR( "audio-es" ); |
|---|
| | 392 | vlc_object_t *p_object; |
|---|
| | 393 | input_thread_t *p_input; |
|---|
| | 394 | |
|---|
| | 395 | if( !current ) |
|---|
| | 396 | current = new QMenu(); |
|---|
| | 397 | |
|---|
| | 398 | if( current->isEmpty() ) |
|---|
| | 399 | { |
|---|
| | 400 | ACT_ADD( current, "audio-es", qtr( "Audio &Track" ) ); |
|---|
| | 401 | ACT_ADD( current, "audio-device", qtr( "Audio &Device" ) ); |
|---|
| | 402 | ACT_ADD( current, "audio-channels", qtr( "Audio &Channels" ) ); |
|---|
| | 403 | ACT_ADD( current, "visual", qtr( "&Visualizations" ) ); |
|---|
| | 404 | ACT_ADD( current, "equalizer", qtr( "&Equalizer" ) ); |
|---|
| | 405 | } |
|---|
| | 406 | |
|---|
| | 407 | p_input = THEMIM->getInput(); |
|---|
| | 408 | if( p_input ) |
|---|
| | 409 | vlc_object_yield( p_input ); |
|---|
| | 410 | p_object = ( vlc_object_t * ) vlc_object_find( p_intf, |
|---|
| | 411 | VLC_OBJECT_AOUT, |
|---|
| | 412 | FIND_ANYWHERE ); |
|---|
| | 413 | |
|---|
| | 414 | AudioAutoMenuBuilder( p_object, p_input, objects, varnames ); |
|---|
| | 415 | |
|---|
| | 416 | if( p_object ) |
|---|
| 358 | 417 | vlc_object_release( p_object ); |
|---|
| 359 | | } |
|---|
| 360 | | |
|---|
| 361 | | p_object = ( vlc_object_t * )vlc_object_find( p_intf, VLC_OBJECT_AOUT, |
|---|
| 362 | | FIND_ANYWHERE ); |
|---|
| 363 | | if( p_object ) |
|---|
| 364 | | { |
|---|
| 365 | | AudioAutoMenuBuilder( p_object, objects, varnames ); |
|---|
| 366 | | vlc_object_release( p_object ); |
|---|
| 367 | | } |
|---|
| | 418 | if( p_input ) |
|---|
| | 419 | vlc_object_release( p_input ); |
|---|
| | 420 | |
|---|
| 368 | 421 | return Populate( p_intf, current, varnames, objects ); |
|---|
| 369 | 422 | } |
|---|
| … | … | |
| 376 | 429 | { |
|---|
| 377 | 430 | vlc_object_t *p_object; |
|---|
| | 431 | input_thread_t *p_input; |
|---|
| 378 | 432 | vector<int> objects; |
|---|
| 379 | 433 | vector<const char *> varnames; |
|---|
| 380 | 434 | |
|---|
| 381 | | p_object = ( vlc_object_t * )vlc_object_find( p_intf, VLC_OBJECT_INPUT, |
|---|
| 382 | | FIND_ANYWHERE ); |
|---|
| 383 | | if( p_object != NULL ) |
|---|
| 384 | | { |
|---|
| 385 | | PUSH_VAR( "video-es" ); |
|---|
| 386 | | PUSH_VAR( "spu-es" ); |
|---|
| 387 | | vlc_object_release( p_object ); |
|---|
| 388 | | } |
|---|
| 389 | | |
|---|
| | 435 | if( !current ) |
|---|
| | 436 | current = new QMenu(); |
|---|
| | 437 | |
|---|
| | 438 | if( current->isEmpty() ) |
|---|
| | 439 | { |
|---|
| | 440 | ACT_ADD( current, "video-es", qtr( "Video &Track" ) ); |
|---|
| | 441 | ACT_ADD( current, "fullscreen", qtr( "&Fullscreen" ) ); |
|---|
| | 442 | ACT_ADD( current, "zoom", qtr( "&Zoom" ) ); |
|---|
| | 443 | ACT_ADD( current, "deinterlace", qtr( "&Deinterlace" ) ); |
|---|
| | 444 | ACT_ADD( current, "aspect-ratio", qtr( "&Aspect Ratio" ) ); |
|---|
| | 445 | ACT_ADD( current, "crop", qtr( "&Crop" ) ); |
|---|
| | 446 | ACT_ADD( current, "video-on-top", qtr( "Always &On Top" ) ); |
|---|
| | 447 | ACT_ADD( current, "directx-wallpaper", qtr( "&DirectX Wallpaper" ) ); /* FIXME */ |
|---|
| | 448 | ACT_ADD( current, "video-snapshot", qtr( "&Snapshot" ) ); |
|---|
| | 449 | ACT_ADD( current, "ffmpeg-pp-q", qtr( "D&ecoder" ) ); /* FIXME */ |
|---|
| | 450 | } |
|---|
| | 451 | |
|---|
| | 452 | p_input = THEMIM->getInput(); |
|---|
| | 453 | if( p_input ) |
|---|
| | 454 | vlc_object_yield( p_input ); |
|---|
| 390 | 455 | p_object = ( vlc_object_t * )vlc_object_find( p_intf, VLC_OBJECT_VOUT, |
|---|
| 391 | 456 | FIND_ANYWHERE ); |
|---|
| 392 | | if( p_object != NULL ) |
|---|
| 393 | | { |
|---|
| 394 | | VideoAutoMenuBuilder( p_object, objects, varnames ); |
|---|
| | 457 | |
|---|
| | 458 | VideoAutoMenuBuilder( p_object, p_input, objects, varnames ); |
|---|
| | 459 | |
|---|
| | 460 | if( p_object ) |
|---|
| 395 | 461 | vlc_object_release( p_object ); |
|---|
| 396 | | } |
|---|
| | 462 | if( p_input ) |
|---|
| | 463 | vlc_object_release( p_input ); |
|---|
| | 464 | |
|---|
| 397 | 465 | return Populate( p_intf, current, varnames, objects ); |
|---|
| 398 | 466 | } |
|---|
| … | … | |
| 410 | 478 | p_object = ( vlc_object_t * )vlc_object_find( p_intf, VLC_OBJECT_INPUT, |
|---|
| 411 | 479 | FIND_ANYWHERE ); |
|---|
| 412 | | if( p_object != NULL ) |
|---|
| 413 | | { |
|---|
| 414 | | InputAutoMenuBuilder( p_object, objects, varnames ); |
|---|
| 415 | | PUSH_VAR( "prev-title" ); PUSH_VAR ( "next-title" ); |
|---|
| 416 | | PUSH_VAR( "prev-chapter" ); PUSH_VAR( "next-chapter" ); |
|---|
| | 480 | InputAutoMenuBuilder( p_object, objects, varnames ); |
|---|
| | 481 | PUSH_VAR( "prev-title" ); |
|---|
| | 482 | PUSH_VAR( "next-title" ); |
|---|
| | 483 | PUSH_VAR( "prev-chapter" ); |
|---|
| | 484 | PUSH_VAR( "next-chapter" ); |
|---|
| | 485 | if( p_object ) |
|---|
| 417 | 486 | vlc_object_release( p_object ); |
|---|
| 418 | | } |
|---|
| 419 | 487 | QMenu *navMenu = new QMenu( menu ); |
|---|
| 420 | 488 | addDPStaticEntry( navMenu, qtr( I_MENU_GOTOTIME ), "","", |
|---|
| … | … | |
| 479 | 547 | } |
|---|
| 480 | 548 | |
|---|
| | 549 | #undef ACT_ADD |
|---|
| 481 | 550 | |
|---|
| 482 | 551 | /***************************************************************************** |
|---|
| … | … | |
| 555 | 624 | { |
|---|
| 556 | 625 | vlc_object_yield( p_input ); |
|---|
| 557 | | varnames.push_back( "video-es" ); |
|---|
| 558 | | objects.push_back( p_input->i_object_id ); |
|---|
| 559 | | varnames.push_back( "spu-es" ); |
|---|
| 560 | | objects.push_back( p_input->i_object_id ); |
|---|
| 561 | 626 | vlc_object_t *p_vout = ( vlc_object_t * )vlc_object_find( p_input, |
|---|
| 562 | 627 | VLC_OBJECT_VOUT, FIND_CHILD ); |
|---|
| 563 | 628 | if( p_vout ) |
|---|
| 564 | 629 | { |
|---|
| 565 | | VideoAutoMenuBuilder( p_vout, objects, varnames ); |
|---|
| | 630 | VideoAutoMenuBuilder( p_vout, p_input, objects, varnames ); |
|---|
| 566 | 631 | vlc_object_release( p_vout ); |
|---|
| 567 | 632 | } |
|---|
| … | … | |
| 579 | 644 | { |
|---|
| 580 | 645 | vlc_object_yield( p_input ); |
|---|
| 581 | | varnames.push_back( "audio-es" ); |
|---|
| 582 | | objects.push_back( p_input->i_object_id ); |
|---|
| 583 | 646 | vlc_object_t *p_aout = ( vlc_object_t * )vlc_object_find( p_input, |
|---|
| 584 | 647 | VLC_OBJECT_AOUT, FIND_ANYWHERE ); |
|---|
| | 648 | AudioAutoMenuBuilder( p_aout, p_input, objects, varnames ); |
|---|
| 585 | 649 | if( p_aout ) |
|---|
| 586 | | { |
|---|
| 587 | | AudioAutoMenuBuilder( p_aout, objects, varnames ); |
|---|
| 588 | 650 | vlc_object_release( p_aout ); |
|---|
| 589 | | } |
|---|
| 590 | 651 | vlc_object_release( p_input ); |
|---|
| 591 | 652 | } |
|---|
| … | … | |
| 638 | 699 | /* Audio menu */ |
|---|
| 639 | 700 | PUSH_SEPARATOR; |
|---|
| 640 | | varnames.push_back( "audio-es" ); |
|---|
| 641 | | objects.push_back( p_input->i_object_id ); |
|---|
| 642 | 701 | vlc_object_t *p_aout = ( vlc_object_t * ) |
|---|
| 643 | 702 | vlc_object_find( p_input, VLC_OBJECT_AOUT, FIND_ANYWHERE ); |
|---|
| | 703 | AudioAutoMenuBuilder( p_aout, p_input, objects, varnames ); |
|---|
| 644 | 704 | if( p_aout ) |
|---|
| 645 | | { |
|---|
| 646 | | AudioAutoMenuBuilder( p_aout, objects, varnames ); |
|---|
| 647 | 705 | vlc_object_release( p_aout ); |
|---|
| 648 | | } |
|---|
| 649 | 706 | |
|---|
| 650 | 707 | /* Video menu */ |
|---|
| 651 | 708 | PUSH_SEPARATOR; |
|---|
| 652 | | varnames.push_back( "video-es" ); |
|---|
| 653 | | objects.push_back( p_input->i_object_id ); |
|---|
| 654 | | varnames.push_back( "spu-es" ); |
|---|
| 655 | | objects.push_back( p_input->i_object_id ); |
|---|
| 656 | 709 | vlc_object_t *p_vout = ( vlc_object_t * ) |
|---|
| 657 | 710 | vlc_object_find( p_input, VLC_OBJECT_VOUT, FIND_CHILD ); |
|---|
| | 711 | VideoAutoMenuBuilder( p_vout, p_input, objects, varnames ); |
|---|
| 658 | 712 | if( p_vout ) |
|---|
| 659 | | { |
|---|
| 660 | | VideoAutoMenuBuilder( p_vout, objects, varnames ); |
|---|
| 661 | 713 | vlc_object_release( p_vout ); |
|---|
| 662 | | } |
|---|
| 663 | 714 | |
|---|
| 664 | 715 | vlc_object_release( p_input ); |
|---|
| … | … | |
| 727 | 778 | #undef PUSH_VAR |
|---|
| 728 | 779 | #undef PUSH_SEPARATOR |
|---|
| 729 | | |
|---|
| 730 | 780 | |
|---|
| 731 | 781 | /************************************************************************* |
|---|
| … | … | |
| 741 | 791 | if( !menu ) |
|---|
| 742 | 792 | menu = new QMenu(); |
|---|
| 743 | | else if( !append ) |
|---|
| 744 | | menu->clear(); |
|---|
| | 793 | |
|---|
| | 794 | QAction *p_action; |
|---|
| | 795 | Q_FOREACH( p_action, menu->actions() ) |
|---|
| | 796 | { |
|---|
| | 797 | p_action->setEnabled( false ); |
|---|
| | 798 | } |
|---|
| 745 | 799 | |
|---|
| 746 | 800 | currentGroup = NULL; |
|---|
| 747 | 801 | |
|---|
| 748 | 802 | vlc_object_t *p_object; |
|---|
| 749 | | bool b_section_empty = false; |
|---|
| 750 | 803 | int i; |
|---|
| 751 | | |
|---|
| 752 | | #define APPEND_EMPTY { QAction *action = menu->addAction( qtr( "Empty" ) ); \ |
|---|
| 753 | | action->setEnabled( false ); } |
|---|
| 754 | 804 | |
|---|
| 755 | 805 | for( i = 0; i < ( int )objects.size() ; i++ ) |
|---|
| … | … | |
| 757 | 807 | if( !varnames[i] || !*varnames[i] ) |
|---|
| 758 | 808 | { |
|---|
| 759 | | if( b_section_empty ) |
|---|
| 760 | | APPEND_EMPTY; |
|---|
| 761 | 809 | menu->addSeparator(); |
|---|
| 762 | | b_section_empty = true; |
|---|
| 763 | 810 | continue; |
|---|
| 764 | 811 | } |
|---|
| … | … | |
| 766 | 813 | if( objects[i] == 0 ) |
|---|
| 767 | 814 | { |
|---|
| 768 | | /// \bug What is this ? |
|---|
| 769 | | // Append( menu, varnames[i], NULL ); |
|---|
| 770 | | b_section_empty = false; |
|---|
| 771 | 815 | continue; |
|---|
| 772 | 816 | } |
|---|
| 773 | | |
|---|
| 774 | | p_object = ( vlc_object_t * )vlc_object_get( objects[i] ); |
|---|
| 775 | | if( p_object == NULL ) continue; |
|---|
| 776 | | |
|---|
| 777 | | b_section_empty = false; |
|---|
| | 817 | else |
|---|
| | 818 | { |
|---|
| | 819 | p_object = ( vlc_object_t * )vlc_object_get( objects[i] ); |
|---|
| | 820 | if( !p_object ) |
|---|
| | 821 | { |
|---|
| | 822 | msg_Dbg( p_intf, "object %d not found !", objects[i] ); |
|---|
| | 823 | continue; |
|---|
| | 824 | } |
|---|
| | 825 | } |
|---|
| | 826 | |
|---|
| 778 | 827 | /* Ugly specific stuff */ |
|---|
| 779 | 828 | if( strstr( varnames[i], "intf-add" ) ) |
|---|
| 780 | | CreateItem( menu, varnames[i], p_object, false ); |
|---|
| | 829 | UpdateItem( p_intf, menu, varnames[i], p_object, false ); |
|---|
| 781 | 830 | else |
|---|
| 782 | | CreateItem( menu, varnames[i], p_object, true ); |
|---|
| 783 | | vlc_object_release( p_object ); |
|---|
| 784 | | } |
|---|
| 785 | | |
|---|
| 786 | | /* Special case for empty menus */ |
|---|
| 787 | | if( menu->actions().size() == 0 || b_section_empty ) |
|---|
| 788 | | APPEND_EMPTY |
|---|
| 789 | | |
|---|
| | 831 | UpdateItem( p_intf, menu, varnames[i], p_object, true ); |
|---|
| | 832 | if( p_object ) |
|---|
| | 833 | vlc_object_release( p_object ); |
|---|
| | 834 | } |
|---|
| 790 | 835 | return menu; |
|---|
| 791 | 836 | } |
|---|
| 792 | | #undef APPEND_EMPTY |
|---|
| 793 | 837 | |
|---|
| 794 | 838 | /***************************************************************************** |
|---|
| … | … | |
| 840 | 884 | } |
|---|
| 841 | 885 | |
|---|
| 842 | | void QVLCMenu::CreateItem( QMenu *menu, const char *psz_var, |
|---|
| 843 | | vlc_object_t *p_object, bool b_submenu ) |
|---|
| | 886 | #define TEXT_OR_VAR qfu ( text.psz_string ? text.psz_string : psz_var ) |
|---|
| | 887 | |
|---|
| | 888 | void QVLCMenu::UpdateItem( intf_thread_t *p_intf, QMenu *menu, |
|---|
| | 889 | const char *psz_var, vlc_object_t *p_object, bool b_submenu ) |
|---|
| 844 | 890 | { |
|---|
| 845 | 891 | vlc_value_t val, text; |
|---|
| 846 | 892 | int i_type; |
|---|
| 847 | 893 | |
|---|
| | 894 | if( !p_object ) |
|---|
| | 895 | { |
|---|
| | 896 | /* Nothing to do */ |
|---|
| | 897 | return; |
|---|
| | 898 | } |
|---|
| | 899 | |
|---|
| | 900 | if( !strcmp( psz_var, "spu-es" ) ) |
|---|
| | 901 | { |
|---|
| | 902 | /* TODO: add a static entry "Load File..." */ |
|---|
| | 903 | return; |
|---|
| | 904 | } |
|---|
| | 905 | |
|---|
| 848 | 906 | /* Check the type of the object variable */ |
|---|
| 849 | | i_type = var_Type( p_object, psz_var ); |
|---|
| | 907 | if( !strcmp( psz_var, "audio-es" ) |
|---|
| | 908 | || !strcmp( psz_var, "video-es" ) ) |
|---|
| | 909 | i_type = VLC_VAR_INTEGER | VLC_VAR_HASCHOICE; |
|---|
| | 910 | else |
|---|
| | 911 | i_type = var_Type( p_object, psz_var ); |
|---|
| 850 | 912 | |
|---|
| 851 | 913 | switch( i_type & VLC_VAR_TYPE ) |
|---|
| … | … | |
| 867 | 929 | |
|---|
| 868 | 930 | /* Get the descriptive name of the variable */ |
|---|
| 869 | | var_Change( p_object, psz_var, VLC_VAR_GETTEXT, &text, NULL ); |
|---|
| | 931 | int i_ret = var_Change( p_object, psz_var, VLC_VAR_GETTEXT, &text, NULL ); |
|---|
| | 932 | if( i_ret != VLC_SUCCESS ) |
|---|
| | 933 | { |
|---|
| | 934 | text.psz_string = NULL; |
|---|
| | 935 | } |
|---|
| | 936 | |
|---|
| | 937 | QAction *action = FindActionWithVar( menu, psz_var ); |
|---|
| | 938 | if( !action ) |
|---|
| | 939 | { |
|---|
| | 940 | action = new QAction( TEXT_OR_VAR, menu ); |
|---|
| | 941 | menu->addAction( action ); |
|---|
| | 942 | } |
|---|
| 870 | 943 | |
|---|
| 871 | 944 | if( i_type & VLC_VAR_HASCHOICE ) |
|---|
| … | … | |
| 874 | 947 | if( b_submenu ) |
|---|
| 875 | 948 | { |
|---|
| 876 | | QMenu *submenu = new QMenu( menu ); |
|---|
| 877 | | submenu->setTitle( qfu( text.psz_string ? |
|---|
| 878 | | text.psz_string : psz_var ) ); |
|---|
| | 949 | QMenu *submenu; |
|---|
| | 950 | action->setEnabled( true ); |
|---|
| | 951 | submenu = action->menu(); |
|---|
| | 952 | if( !submenu ) |
|---|
| | 953 | { |
|---|
| | 954 | submenu = new QMenu( menu ); |
|---|
| | 955 | action->setMenu( submenu ); |
|---|
| | 956 | } |
|---|
| | 957 | submenu->setEnabled( true ); |
|---|
| | 958 | |
|---|
| 879 | 959 | if( CreateChoicesMenu( submenu, psz_var, p_object, true ) == 0 ) |
|---|
| 880 | 960 | menu->addMenu( submenu ); |
|---|
| … | … | |
| 885 | 965 | return; |
|---|
| 886 | 966 | } |
|---|
| 887 | | |
|---|
| 888 | | #define TEXT_OR_VAR qfu ( text.psz_string ? text.psz_string : psz_var ) |
|---|
| 889 | 967 | |
|---|
| 890 | 968 | switch( i_type & VLC_VAR_TYPE ) |
|---|
| … | … | |
| 1010 | 1088 | bool checked ) |
|---|
| 1011 | 1089 | { |
|---|
| 1012 | | QAction *action = new QAction( text, menu ); |
|---|
| | 1090 | QAction *action = FindActionWithVar( menu, psz_var ); |
|---|
| | 1091 | if( !action ) |
|---|
| | 1092 | { |
|---|
| | 1093 | /* This is a value */ |
|---|
| | 1094 | action = FindActionWithText( menu, text ); |
|---|
| | 1095 | if( !action ) |
|---|
| | 1096 | { |
|---|
| | 1097 | action = new QAction( text, menu ); |
|---|
| | 1098 | menu->addAction( action ); |
|---|
| | 1099 | } |
|---|
| | 1100 | } |
|---|
| | 1101 | |
|---|
| 1013 | 1102 | action->setText( text ); |
|---|
| 1014 | 1103 | action->setToolTip( help ); |
|---|
| | 1104 | |
|---|
| | 1105 | action->setEnabled( i_object_id != 0 ); |
|---|
| 1015 | 1106 | |
|---|
| 1016 | 1107 | if( i_item_type == ITEM_CHECK ) |
|---|
| … | … | |
| 1026 | 1117 | } |
|---|
| 1027 | 1118 | |
|---|
| 1028 | | if( checked ) |
|---|
| 1029 | | { |
|---|
| 1030 | | action->setChecked( true ); |
|---|
| 1031 | | } |
|---|
| | 1119 | action->setChecked( checked ); |
|---|
| | 1120 | |
|---|
| 1032 | 1121 | MenuItemData *itemData = new MenuItemData( i_object_id, i_val_type, |
|---|
| 1033 | 1122 | val, psz_var ); |
|---|
| re00ed66 |
r5ec2ab6 |
|
| 108 | 108 | static void CreateAndConnect( QMenu *, const char *, QString, QString, |
|---|
| 109 | 109 | int, int, vlc_value_t, int, bool c = false ); |
|---|
| 110 | | static void CreateItem( QMenu *, const char *, vlc_object_t *, bool ); |
|---|
| | 110 | static void UpdateItem( intf_thread_t *, QMenu *, const char *, |
|---|
| | 111 | vlc_object_t *, bool ); |
|---|
| 111 | 112 | static int CreateChoicesMenu( QMenu *,const char *, vlc_object_t *, bool ); |
|---|
| 112 | 113 | }; |
|---|
| … | … | |
| 122 | 123 | switch( id ) |
|---|
| 123 | 124 | { |
|---|
| 124 | | case 1: QVLCMenu::VideoMenu( p_intf, menu ); break; |
|---|
| 125 | | case 2: QVLCMenu::AudioMenu( p_intf, menu ); break; |
|---|
| | 125 | case 1: QVLCMenu::AudioMenu( p_intf, menu ); break; |
|---|
| | 126 | case 2: QVLCMenu::VideoMenu( p_intf, menu ); break; |
|---|
| 126 | 127 | case 3: QVLCMenu::NavigMenu( p_intf, menu ); break; |
|---|
| 127 | 128 | case 4: QVLCMenu::InterfacesMenu( p_intf, menu ); break; |
|---|