menus.cpp 48.1 KB
Newer Older
1 2 3
/*****************************************************************************
 * menus.cpp : Qt menus
 *****************************************************************************
4
 * Copyright © 2006-2011 the VideoLAN team
5
 * $Id$
6
 *
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
7
 * Authors: Clément Stenac <zorglub@videolan.org>
8
 *          Jean-Baptiste Kempf <jb@videolan.org>
9
 *          Jean-Philippe André <jpeg@videolan.org>
10 11 12 13
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
14
 * ( at your option ) any later version.
15 16 17 18 19 20 21 22 23 24 25
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

26 27 28 29
/** \todo
 * - Remove static currentGroup
 */

Rémi Duraffort's avatar
Rémi Duraffort committed
30 31 32
#define __STDC_FORMAT_MACROS 1
#define __STDC_CONSTANT_MACROS 1

33 34 35 36
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

37
#include <vlc_common.h>
38
#include <vlc_intf_strings.h>
39 40
#include <vlc_vout.h>                             /* vout_thread_t */
#include <vlc_aout.h>                             /* audio_output_t */
41

Clément Stenac's avatar
Clément Stenac committed
42
#include "menus.hpp"
43

44 45 46 47 48 49 50 51
#include "main_interface.hpp"                     /* View modifications */
#include "dialogs_provider.hpp"                   /* Dialogs display */
#include "input_manager.hpp"                      /* Input Management */
#include "recents.hpp"                            /* Recent Items */
#include "actions_manager.hpp"                    /* Actions Management: play+volume */
#include "extensions_manager.hpp"                 /* Extensions menu */
#include "util/qmenuview.hpp"                     /* Simple Playlist menu */
#include "components/playlist/playlist_model.hpp" /* PLModel getter */
Clément Stenac's avatar
Clément Stenac committed
52

53 54 55 56 57
#include <QMenu>
#include <QMenuBar>
#include <QAction>
#include <QActionGroup>
#include <QSignalMapper>
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
58
#include <QStatusBar>
59

60 61 62 63
/*
  This file defines the main menus and the pop-up menu (right-click menu)
  and the systray menu (in that order in the file)

64 65 66
  There are 4 menus that have to be rebuilt everytime there are called:
  Audio, Video, Navigation, view
  4 functions are building those menus: AudioMenu, VideoMenu, NavigMenu, View
67 68 69 70 71 72 73
  and 3 functions associated are collecting the objects :
  InputAutoMenuBuilder, AudioAutoMenuBuilder, VideoAutoMenuBuilder.

  A QSignalMapper decides when to rebuild those menus cf MenuFunc in the .hpp
  Just before one of those menus are aboutToShow(), they are rebuild.
  */

74 75
enum
{
76 77 78
    ITEM_NORMAL, /* not a checkbox, nor a radio */
    ITEM_CHECK,  /* Checkbox */
    ITEM_RADIO   /* Radiobox */
79 80 81 82
};

static QActionGroup *currentGroup;

83
QMenu *VLCMenuBar::recentsMenu = NULL;
Ludovic Fauvet's avatar
Ludovic Fauvet committed
84

85 86 87
/**
 * @brief Add static entries to DP in menus
 **/
88
QAction *addDPStaticEntry( QMenu *menu,
89
                       const QString& text,
90
                       const char *icon,
91
                       const char *member,
92
                       const char *shortcut = NULL,
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
93
                       QAction::MenuRole role = QAction::NoRole
94
                       )
95
{
96
    QAction *action = NULL;
97
#ifndef __APPLE__ /* We don't set icons in menus in MacOS X */
Rémi Duraffort's avatar
Rémi Duraffort committed
98
    if( !EMPTY_STR( icon ) )
99
    {
Rémi Duraffort's avatar
Rémi Duraffort committed
100
        if( !EMPTY_STR( shortcut ) )
101 102
            action = menu->addAction( QIcon( icon ), text, THEDP,
                                      member, qtr( shortcut ) );
103
        else
104
            action = menu->addAction( QIcon( icon ), text, THEDP, member );
105 106
    }
    else
107
#endif
108
    {
Rémi Duraffort's avatar
Rémi Duraffort committed
109
        if( !EMPTY_STR( shortcut ) )
110
            action = menu->addAction( text, THEDP, member, qtr( shortcut ) );
111
        else
112
            action = menu->addAction( text, THEDP, member );
113
    }
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
114 115 116
#ifdef __APPLE__
    action->setMenuRole( role )
#endif
117
    action->setData( VLCMenuBar::ACTION_STATIC );
118
    return action;
119
}
120

121 122 123
/**
 * @brief Add static entries to MIM in menus
 **/
124 125
QAction* addMIMStaticEntry( intf_thread_t *p_intf,
                            QMenu *menu,
126
                            const QString& text,
127 128 129
                            const char *icon,
                            const char *member,
                            bool bStatic = false )
130
{
131
    QAction *action;
132
#ifndef __APPLE__ /* We don't set icons in menus in MacOS X */
Rémi Duraffort's avatar
Rémi Duraffort committed
133
    if( !EMPTY_STR( icon ) )
134
    {
135
        action = menu->addAction( text, THEMIM,  member );
136 137 138
        action->setIcon( QIcon( icon ) );
    }
    else
139
#endif
140
    {
Rémi Duraffort's avatar
Rémi Duraffort committed
141
        action = menu->addAction( text, THEMIM, member );
142
    }
143 144 145
    action->setData( VLCMenuBar::ACTION_STATIC |
                     ( bStatic ) ? VLCMenuBar::ACTION_ALWAYS_ENABLED
                                 : VLCMenuBar::ACTION_NONE
146
                   );
147
    return action;
148 149
}

150
/**
151 152
 * @brief Enable all static entries of a menu, disable the others
 * @param menu the menu in which the entries will be disabled
153
 * @param enable if false, disable all entries
154
 **/
155
void VLCMenuBar::EnableStaticEntries( QMenu *menu, bool enable = true )
156
{
157
    if( !menu ) return;
158

Jean-Philippe Andre's avatar
Jean-Philippe Andre committed
159
    QList< QAction* > actions = menu->actions();
160
    for( int i = 0; i < actions.count(); ++i )
161
    {
162 163 164 165 166 167 168
        int actionflags = actions[i]->data().toInt();
        if ( actionflags & ACTION_MANAGED )
            actions[i]->setEnabled(
                ( actionflags & ACTION_ALWAYS_ENABLED )
                ||
                enable
            );
169 170 171
    }
}

172 173
/**
 * \return Number of static entries
174
 **/
175
inline int DeleteNonStaticEntries( QMenu *menu )
176
{
177 178
    if( !menu ) return VLC_EGENERIC;

179
    int i_ret = 0;
180

Jean-Philippe Andre's avatar
Jean-Philippe Andre committed
181
    QList< QAction* > actions = menu->actions();
182
    for( int i = 0; i < actions.count(); ++i )
183
    {
184
        if( actions[i]->data().toInt() & VLCMenuBar::ACTION_NO_CLEANUP )
185
            i_ret++;
186 187
        else
            delete actions[i];
188
    }
189
    return i_ret;
190 191
}

192 193 194 195
/**
 * \return QAction associated to psz_var variable
 **/
static QAction * FindActionWithVar( QMenu *menu, const char *psz_var )
196
{
197
    QList< QAction* > actions = menu->actions();
198
    for( int i = 0; i < actions.count(); ++i )
199
    {
200 201
        if( actions[i]->data().toString() == psz_var )
            return actions[i];
202
    }
203
    return NULL;
204 205
}

206
/*****************************************************************************
207
 * Definitions of variables for the dynamic menus
208
 *****************************************************************************/
209 210
#define PUSH_VAR( var ) varnames.append( var ); \
    objects.append( VLC_OBJECT(p_object) )
211

212 213
#define PUSH_INPUTVAR( var ) varnames.append( var ); \
    objects.append( VLC_OBJECT(p_input) );
214

215
static int InputAutoMenuBuilder( input_thread_t *p_object,
216 217
        QVector<vlc_object_t *> &objects,
        QVector<const char *> &varnames )
218
{
219
    PUSH_VAR( "bookmark" );
220
    PUSH_VAR( "title" );
221
    PUSH_VAR( "chapter" );
222
    PUSH_VAR( "navigation" );
223
    PUSH_VAR( "program" );
224 225 226
    return VLC_SUCCESS;
}

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
227
static int VideoAutoMenuBuilder( vout_thread_t *p_object,
228
        input_thread_t *p_input,
229 230
        QVector<vlc_object_t *> &objects,
        QVector<const char *> &varnames )
231
{
232 233
    PUSH_INPUTVAR( "video-es" );
    PUSH_INPUTVAR( "spu-es" );
234 235
    PUSH_VAR( "fullscreen" );
    PUSH_VAR( "video-on-top" );
236
    PUSH_VAR( "video-wallpaper" );
237
    PUSH_VAR( "video-snapshot" );
238
    PUSH_VAR( "zoom" );
239
    PUSH_VAR( "autoscale" );
240 241
    PUSH_VAR( "aspect-ratio" );
    PUSH_VAR( "crop" );
242
    PUSH_VAR( "deinterlace" );
243
    PUSH_VAR( "deinterlace-mode" );
244
    PUSH_VAR( "postprocess" );
245

246 247 248
    return VLC_SUCCESS;
}

249
static int AudioAutoMenuBuilder( audio_output_t *p_object,
250
        input_thread_t *p_input,
251 252
        QVector<vlc_object_t *> &objects,
        QVector<const char *> &varnames )
253
{
254
    PUSH_INPUTVAR( "audio-es" );
255
    PUSH_VAR( "audio-channels" );
256 257
    PUSH_VAR( "audio-device" );
    PUSH_VAR( "visual" );
258 259 260
    return VLC_SUCCESS;
}

261 262
/*****************************************************************************
 * All normal menus
263
 * Simple Code
264 265
 *****************************************************************************/

266
// Static menu
267 268 269 270
static inline void addMenuToMainbar( QMenu *func, QString title, QMenuBar *bar ) {
    func->setTitle( title );
    bar->addMenu( func);
}
271

272
// Dynamic menu
273
#define BAR_DADD( func, title, id ) { \
274 275 276 277 278
    QMenu *_menu = func; _menu->setTitle( title ); bar->addMenu( _menu ); \
    MenuFunc *f = new MenuFunc( _menu, id ); \
    CONNECT( _menu, aboutToShow(), THEDP->menusUpdateMapper, map() ); \
    THEDP->menusUpdateMapper->setMapping( _menu, f ); }

279
// Add a simple action
280 281 282 283 284
static inline void addAction( QMenu *_menu, QVariant val, QString title ) {
    QAction *_action = new QAction( title, _menu );
    _action->setData( val );
    _menu->addAction( _action );
}
285

286
// Add an action with a submenu
287
static inline QMenu *addActionWithSubmenu( QMenu *_menu, QVariant val, QString title ) {
288
    QAction *_action = new QAction( title, _menu );
289
    QMenu *_submenu = new QMenu( _menu );
290
    _action->setData( val );
291
    _action->setMenu( _submenu );
292
    _menu->addAction( _action );
293
    return _submenu;
294
}
295

296
// Add an action that is a checkbox
297 298 299 300 301 302
static inline void addActionWithCheckbox( QMenu *_menu, QVariant val, QString title ) {
    QAction *_action = new QAction( title, _menu );
    _action->setData( val );
    _action->setCheckable( true );
    _menu->addAction( _action );
}
303

304 305 306
/**
 * Main Menu Bar Creation
 **/
307
void VLCMenuBar::createMenuBar( MainInterface *mi,
308
                              intf_thread_t *p_intf )
Clément Stenac's avatar
Qt4:  
Clément Stenac committed
309
{
310 311 312
    /* QMainWindows->menuBar()
       gives the QProcess::destroyed timeout issue on Cleanlooks style with
       setDesktopAware set to false */
313
    QMenuBar *bar = mi->menuBar();
314

315
    addMenuToMainbar( FileMenu( p_intf, bar, mi ), qtr( "&Media" ), bar );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
316

317
    /* Dynamic menus, rebuilt before being showed */
318
    BAR_DADD( NavigMenu( p_intf, bar ), qtr( "P&layback" ), 3 );
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
319 320
    BAR_DADD( AudioMenu( p_intf, bar ), qtr( "&Audio" ), 1 );
    BAR_DADD( VideoMenu( p_intf, bar ), qtr( "&Video" ), 2 );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
321

322
    addMenuToMainbar( ToolsMenu( bar ), qtr( "&Tools" ), bar );
323 324

    /* View menu, a bit different */
Rémi Duraffort's avatar
Rémi Duraffort committed
325
    BAR_DADD( ViewMenu( p_intf, NULL, mi ), qtr( "V&iew" ), 4 );
326

327
    addMenuToMainbar( HelpMenu( bar ), qtr( "&Help" ), bar );
328

329
}
330 331

/**
332
 * Media ( File ) Menu
333 334
 * Opening, streaming and quit
 **/
335
QMenu *VLCMenuBar::FileMenu( intf_thread_t *p_intf, QWidget *parent, MainInterface *mi )
336
{
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
337
    QMenu *menu = new QMenu( parent );
338
    QAction *action;
339

340 341
    addDPStaticEntry( menu, qtr( "Open &File..." ),
        ":/type/file-asym", SLOT( simpleOpenDialog() ), "Ctrl+O" );
342
    addDPStaticEntry( menu, qtr( I_OP_OPDIR ),
343
        ":/type/folder-grey", SLOT( PLOpenDir() ), "Ctrl+F" );
344
    addDPStaticEntry( menu, qtr( "Open &Disc..." ),
345
        ":/type/disc", SLOT( openDiscDialog() ), "Ctrl+D" );
346
    addDPStaticEntry( menu, qtr( "Open &Network Stream..." ),
347
        ":/type/network", SLOT( openNetDialog() ), "Ctrl+N" );
348
    addDPStaticEntry( menu, qtr( "Open &Capture Device..." ),
349
        ":/type/capture-card", SLOT( openCaptureDialog() ), "Ctrl+C" );
350

351
    menu->addSeparator();
352 353 354 355 356

    addDPStaticEntry( menu, qtr( "&Open (advanced)..." ),
        ":/type/file-asym", SLOT( openFileDialog() ), "Ctrl+Shift+O" );
    menu->addSeparator();

357
    addDPStaticEntry( menu, qtr( "Open &Location from clipboard" ),
358
                      NULL, SLOT( openUrlDialog() ), "Ctrl+V" );
359

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
360
    if( var_InheritBool( p_intf, "qt-recentplay" ) )
361
    {
362
        recentsMenu = new QMenu( qtr( "Open &Recent Media" ), menu );
363 364 365
        updateRecents( p_intf );
        menu->addMenu( recentsMenu );
    }
366
    menu->addSeparator();
367

368 369 370 371
    addDPStaticEntry( menu, qtr( I_PL_SAVE ), "", SLOT( saveAPlaylist() ),
        "Ctrl+Y" );
    menu->addSeparator();

372
#ifdef ENABLE_SOUT
373
    addDPStaticEntry( menu, qtr( "Conve&rt / Save..." ), "",
374
        SLOT( openAndTranscodingDialogs() ), "Ctrl+R" );
375
    addDPStaticEntry( menu, qtr( "&Stream..." ),
376
        ":/menu/stream", SLOT( openAndStreamingDialogs() ), "Ctrl+S" );
377
    menu->addSeparator();
378
#endif
379

380 381 382 383 384
    action = addMIMStaticEntry( p_intf, menu, qtr( "Quit at the end of playlist" ), "",
                               SLOT( activatePlayQuit( bool ) ) );
    action->setCheckable( true );
    action->setChecked( THEMIM->getPlayExitState() );

385 386 387 388 389 390
    if( mi->getSysTray() )
    {
        action = menu->addAction( qtr( "Close to systray"), mi,
                                 SLOT( toggleUpdateSystrayMenu() ) );
    }

391
    addDPStaticEntry( menu, qtr( "&Quit" ) ,
392
        ":/menu/quit", SLOT( quit() ), "Ctrl+Q" );
393 394 395
    return menu;
}

396
/**
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
397
 * Tools, like Media Information, Preferences or Messages
398
 **/
399
QMenu *VLCMenuBar::ToolsMenu( QMenu *menu )
Clément Stenac's avatar
Clément Stenac committed
400
{
401
    addDPStaticEntry( menu, qtr( "&Effects and Filters"), ":/menu/settings",
402
            SLOT( extendedDialog() ), "Ctrl+E" );
403

404
    addDPStaticEntry( menu, qtr( "&Track Synchronization"), ":/menu/settings",
405 406
            SLOT( synchroDialog() ), "" );

407
    addDPStaticEntry( menu, qtr( I_MENU_INFO ) , ":/menu/info",
408
        SLOT( mediaInfoDialog() ), "Ctrl+I" );
409
    addDPStaticEntry( menu, qtr( I_MENU_CODECINFO ) ,
410
        ":/menu/info", SLOT( mediaCodecDialog() ), "Ctrl+J" );
411

412
#ifdef ENABLE_VLM
413
    addDPStaticEntry( menu, qtr( I_MENU_VLM ), "", SLOT( vlmDialog() ),
414 415
        "Ctrl+W" );
#endif
416

417 418 419
    addDPStaticEntry( menu, qtr( "Program Guide" ), "", SLOT( epgDialog() ),
        "" );

420
    addDPStaticEntry( menu, qtr( I_MENU_MSG ),
421
        ":/menu/messages", SLOT( messagesDialog() ), "Ctrl+M" );
422

423 424
    addDPStaticEntry( menu, qtr( "Plu&gins and extensions" ),
        "", SLOT( pluginDialog() ) );
Clément Stenac's avatar
Clément Stenac committed
425 426
    menu->addSeparator();

427 428 429
    addDPStaticEntry( menu, qtr( "Customi&ze Interface..." ),
        ":/menu/preferences", SLOT( toolbarDialog() ) );

430
    addDPStaticEntry( menu, qtr( "&Preferences" ),
431
        ":/menu/preferences", SLOT( prefsDialog() ), "Ctrl+P", QAction::PreferencesRole );
432

Clément Stenac's avatar
Clément Stenac committed
433 434 435
    return menu;
}

436
/**
437
 * View Menu
438
 * Interface modification, load other interfaces, activate Extensions
439
 * \param current, set to NULL for menu creation, else for menu update
440
 **/
441
QMenu *VLCMenuBar::ViewMenu( intf_thread_t *p_intf, QMenu *current, MainInterface *_mi )
442
{
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
443
    QAction *action;
444
    QMenu *menu;
445

446 447 448
    MainInterface *mi = _mi ? _mi : p_intf->p_sys->p_mi;
    assert( mi );

449 450
    if( !current )
    {
451
        menu = new QMenu( qtr( "&View" ), mi );
452
    }
453 454 455
    else
    {
        menu = current;
456 457 458 459 460 461 462 463
        //menu->clear();
        //HACK menu->clear() does not delete submenus
        QList<QAction*> actions = menu->actions();
        foreach( QAction *a, actions )
        {
            QMenu *m = a->menu();
            if( a->parent() == menu ) delete a;
            else menu->removeAction( a );
464
            if( m && m->parent() == menu ) delete m;
465
        }
466
    }
467

468 469 470 471
    menu->addAction(
#ifndef __APPLE__
            QIcon( ":/menu/playlist_menu" ),
#endif
472 473 474
            qtr( "Play&list" ), mi,
            SLOT( togglePlaylist() ), qtr( "Ctrl+L" ) );

475 476
    menu->addSeparator();

477
    /* Minimal View */
478
    action = menu->addAction( qtr( "Mi&nimal Interface" ) );
479
    action->setShortcut( qtr( "Ctrl+H" ) );
480
    action->setCheckable( true );
481
    action->setChecked( (mi->getControlsVisibilityStatus() & CONTROLS_HIDDEN ) );
482

483 484
    CONNECT( action, triggered( bool ), mi, toggleMinimalView( bool ) );
    CONNECT( mi, minimalViewToggled( bool ), action, setChecked( bool ) );
485 486 487

    /* FullScreen View */
    action = menu->addAction( qtr( "&Fullscreen Interface" ), mi,
488
            SLOT( toggleInterfaceFullScreen() ), QString( "F11" ) );
489
    action->setCheckable( true );
490
    action->setChecked( mi->isInterfaceFullScreen() );
491 492
    CONNECT( mi, fullscreenInterfaceToggled( bool ),
             action, setChecked( bool ) );
493 494 495

    /* Advanced Controls */
    action = menu->addAction( qtr( "&Advanced Controls" ), mi,
496
            SLOT( toggleAdvancedButtons() ) );
497 498 499 500
    action->setCheckable( true );
    if( mi->getControlsVisibilityStatus() & CONTROLS_ADVANCED )
        action->setChecked( true );

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
501 502 503 504 505 506
    /* Docked Playlist */
    action = menu->addAction( qtr( "Docked Playlist" ) );
    action->setCheckable( true );
    action->setChecked( mi->isPlDocked() );
    CONNECT( action, triggered( bool ), mi, dockPlaylist( bool ) );

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
507 508 509 510
    action = menu->addAction( qtr( "Status Bar" ) );
    action->setCheckable( true );
    action->setChecked( mi->statusBar()->isVisible() );
    CONNECT( action, triggered( bool ), mi, setStatusBarVisibility( bool) );
511
#if 0 /* For Visualisations. Not yet working */
512 513
    adv = menu->addAction( qtr( "Visualizations selector" ), mi,
                           SLOT( visual() ) );
514 515
    adv->setCheckable( true );
    if( visual_selector_enabled ) adv->setChecked( true );
516
#endif
517

518
    menu->addSeparator();
519 520 521 522

    InterfacesMenu( p_intf, menu );
    menu->addSeparator();

523
    /* Extensions */
524
    ExtensionsMenu( p_intf, menu );
525

526 527 528
    return menu;
}

529 530 531
/**
 * Interface Sub-Menu, to list extras interface and skins
 **/
532
QMenu *VLCMenuBar::InterfacesMenu( intf_thread_t *p_intf, QMenu *current )
533
{
534 535 536 537
    QVector<vlc_object_t *> objects;
    QVector<const char *> varnames;
    varnames.append( "intf-add" );
    objects.append( VLC_OBJECT(p_intf) );
Clément Stenac's avatar
Qt4:  
Clément Stenac committed
538

539
    return Populate( p_intf, current, varnames, objects );
540 541
}

542
/**
543
 * Extensions menu: populate the current menu with extensions
544
 **/
545
void VLCMenuBar::ExtensionsMenu( intf_thread_t *p_intf, QMenu *extMenu )
546
{
547
    /* Get ExtensionsManager and load extensions if needed */
548
    ExtensionsManager *extMgr = ExtensionsManager::getInstance( p_intf );
549 550 551 552 553 554 555

    if( !var_InheritBool( p_intf, "qt-autoload-extensions")
        && !extMgr->isLoaded() )
    {
        return;
    }

556
    if( !extMgr->isLoaded() && !extMgr->cannotLoad() )
557
    {
558
        extMgr->loadExtensions();
559
    }
560

561
    /* Let the ExtensionsManager build itself the menu */
562
    extMenu->addSeparator();
563
    extMgr->menu( extMenu );
564 565
}

566 567
static inline void VolumeEntries( intf_thread_t *p_intf, QMenu *current )
{
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
568
    current->addSeparator();
569

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
570
    QAction *action = current->addAction( qtr( "&Increase Volume" ),
571
                ActionsManager::getInstance( p_intf ), SLOT( AudioUp() ) );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
572
    action->setData( VLCMenuBar::ACTION_STATIC );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
573
    action = current->addAction( qtr( "&Decrease Volume" ),
574
                ActionsManager::getInstance( p_intf ), SLOT( AudioDown() ) );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
575
    action->setData( VLCMenuBar::ACTION_STATIC );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
576
    action = current->addAction( qtr( "&Mute" ),
577
                ActionsManager::getInstance( p_intf ), SLOT( toggleMuteAudio() ) );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
578
    action->setData( VLCMenuBar::ACTION_STATIC );
579 580
}

581 582
/**
 * Main Audio Menu
583
 **/
584
QMenu *VLCMenuBar::AudioMenu( intf_thread_t *p_intf, QMenu * current )
585
{
586 587
    QVector<vlc_object_t *> objects;
    QVector<const char *> varnames;
588
    audio_output_t *p_aout;
589 590 591
    input_thread_t *p_input;

    if( current->isEmpty() )
592
    {
593 594 595
        addActionWithSubmenu( current, "audio-es", qtr( "Audio &Track" ) );
        addActionWithSubmenu( current, "audio-channels", qtr( "Audio &Channels" ) );
        addActionWithSubmenu( current, "audio-device", qtr( "Audio &Device" ) );
596
        current->addSeparator();
597

598
        addActionWithSubmenu( current, "visual", qtr( "&Visualizations" ) );
599
        VolumeEntries( p_intf, current );
600 601
    }

602
    p_input = THEMIM->getInput();
603
    p_aout = THEMIM->getAout();
604
    EnableStaticEntries( current, ( p_aout != NULL ) );
605
    AudioAutoMenuBuilder( p_aout, p_input, objects, varnames );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
606
    if( p_aout )
607
    {
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
608
        vlc_object_release( p_aout );
609
    }
610

611 612 613
    return Populate( p_intf, current, varnames, objects );
}

614
/* Subtitles */
615
QMenu *VLCMenuBar::SubtitleMenu( QMenu *current )
616 617 618 619 620 621 622 623
{
    QAction *action;
    QMenu *submenu = new QMenu( qtr( "&Subtitles Track" ), current );
    action = current->addMenu( submenu );
    action->setData( "spu-es" );
    addDPStaticEntry( submenu, qtr( "Open File..." ), "",
                      SLOT( loadSubtitlesFile() ) );
    submenu->addSeparator();
624
    return submenu;
625 626
}

627 628 629 630
/**
 * Main Video Menu
 * Subtitles are part of Video.
 **/
631
QMenu *VLCMenuBar::VideoMenu( intf_thread_t *p_intf, QMenu *current, bool b_subtitle )
632
{
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
633
    vout_thread_t *p_vout;
634
    input_thread_t *p_input;
635 636
    QVector<vlc_object_t *> objects;
    QVector<const char *> varnames;
637

638
    if( current->isEmpty() )
639
    {
640
        addActionWithSubmenu( current, "video-es", qtr( "Video &Track" ) );
641
        if( b_subtitle)
642
            SubtitleMenu( current );
643

644
        current->addSeparator();
645
        /* Surface modifiers */
646 647 648 649
        addActionWithCheckbox( current, "fullscreen", qtr( "&Fullscreen" ) );
        addActionWithCheckbox( current, "autoscale", qtr( "Always Fit &Window" ) );
        addActionWithCheckbox( current, "video-on-top", qtr( "Always &on Top" ) );
        addActionWithCheckbox( current, "video-wallpaper", qtr( "Set as Wall&paper" ) );
650

651
        current->addSeparator();
652
        /* Size modifiers */
653 654 655
        addActionWithSubmenu( current, "zoom", qtr( "&Zoom" ) );
        addActionWithSubmenu( current, "aspect-ratio", qtr( "&Aspect Ratio" ) );
        addActionWithSubmenu( current, "crop", qtr( "&Crop" ) );
656 657 658

        current->addSeparator();
        /* Rendering modifiers */
659 660 661
        addActionWithSubmenu( current, "deinterlace", qtr( "&Deinterlace" ) );
        addActionWithSubmenu( current, "deinterlace-mode", qtr( "&Deinterlace mode" ) );
        addActionWithSubmenu( current, "postprocess", qtr( "&Post processing" ) );
662 663 664 665

        current->addSeparator();
        /* Other actions */
        addAction( current, "video-snapshot", qtr( "Take &Snapshot" ) );
666
    }
667

668 669
    p_input = THEMIM->getInput();

670
    p_vout = THEMIM->getVout();
671
    VideoAutoMenuBuilder( p_vout, p_input, objects, varnames );
672

673 674
    if( p_vout )
        vlc_object_release( p_vout );
675

676
    return Populate( p_intf, current, varnames, objects );
677 678
}

679 680 681 682
/**
 * Navigation Menu
 * For DVD, MP4, MOV and other chapter based format
 **/
683
QMenu *VLCMenuBar::NavigMenu( intf_thread_t *p_intf, QMenu *menu )
684
{
685
    QAction *action;
686
    QMenu *submenu;
687

688 689
    addActionWithSubmenu( menu, "title", qtr( "T&itle" ) );
    addActionWithSubmenu( menu, "chapter", qtr( "&Chapter" ) );
690 691
    submenu = addActionWithSubmenu( menu, "navigation", qtr( "&Navigation" ) );
    submenu->setTearOffEnabled( true );
692
    addActionWithSubmenu( menu, "program", qtr( "&Program" ) );
693

694
    /* FixMe: sync I_MENU_BOOKMARK string */
695 696
    submenu = new QMenu( qtr( "Custom &Bookmarks" ), menu );
    submenu->setTearOffEnabled( true );
697 698 699 700 701 702
    addDPStaticEntry( submenu, qtr( "&Manage" ), "",
                      SLOT( bookmarksDialog() ), "Ctrl+B" );
    submenu->addSeparator();
    action = menu->addMenu( submenu );
    action->setData( "bookmark" );

703
    menu->addSeparator();
704

705
    PopupMenuControlEntries( menu, p_intf );
706

707
    EnableStaticEntries( menu, ( THEMIM->getInput() != NULL ) );
Jean-Baptiste Kempf's avatar