menus.cpp 48.2 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 58
#include <QMenu>
#include <QMenuBar>
#include <QAction>
#include <QActionGroup>
#include <QSignalMapper>
#include <QSystemTrayIcon>
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
59
#include <QStatusBar>
60
#include <QFontMetrics>
61

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

66 67 68
  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
69 70 71 72 73 74 75
  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.
  */

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

static QActionGroup *currentGroup;

85
QMenu *VLCMenuBar::recentsMenu = NULL;
Ludovic Fauvet's avatar
Ludovic Fauvet committed
86

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

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

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

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

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

178
    int i_ret = 0;
179

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

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

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

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

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

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

248 249 250
    return VLC_SUCCESS;
}

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

263 264
/*****************************************************************************
 * All normal menus
265
 * Simple Code
266 267
 *****************************************************************************/

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

274
// Dynamic menu
275
#define BAR_DADD( func, title, id ) { \
276 277 278 279 280
    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 ); }

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

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

298
// Add an action that is a checkbox
299 300 301 302 303 304
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 );
}
305

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

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

319
    /* Dynamic menus, rebuilt before being showed */
320
    BAR_DADD( NavigMenu( p_intf, bar ), qtr( "P&layback" ), 3 );
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
321 322
    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
323

324
    addMenuToMainbar( ToolsMenu( bar ), qtr( "&Tools" ), bar );
325 326

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

329
    addMenuToMainbar( HelpMenu( bar ), qtr( "&Help" ), bar );
330

331
}
332 333

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

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

353
    menu->addSeparator();
354 355 356 357 358

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

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

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

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

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

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

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

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

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

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

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

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

419 420 421
    addDPStaticEntry( menu, qtr( "Program Guide" ), "", SLOT( epgDialog() ),
        "" );

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

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

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

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

Clément Stenac's avatar
Clément Stenac committed
435 436 437
    return menu;
}

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

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

451 452
    if( !current )
    {
453
        menu = new QMenu( qtr( "&View" ), mi );
454
    }
455 456 457
    else
    {
        menu = current;
458 459 460 461 462 463 464 465
        //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 );
466
            if( m && m->parent() == menu ) delete m;
467
        }
468
    }
469

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

477 478
    menu->addSeparator();

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

485 486
    CONNECT( action, triggered( bool ), mi, toggleMinimalView( bool ) );
    CONNECT( mi, minimalViewToggled( bool ), action, setChecked( bool ) );
487 488 489

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

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

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

520
    menu->addSeparator();
521 522 523 524

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

525
    /* Extensions */
526
    ExtensionsMenu( p_intf, menu );
527

528 529 530
    return menu;
}

531 532 533
/**
 * Interface Sub-Menu, to list extras interface and skins
 **/
534
QMenu *VLCMenuBar::InterfacesMenu( intf_thread_t *p_intf, QMenu *current )
535
{
536 537 538 539
    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
540

541
    return Populate( p_intf, current, varnames, objects );
542 543
}

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

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

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

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

568 569 570 571 572 573
static inline void VolumeEntries( intf_thread_t *p_intf, QMenu *current )
{
        current->addSeparator();

        QAction *action = current->addAction( qtr( "Increase Volume" ),
                ActionsManager::getInstance( p_intf ), SLOT( AudioUp() ) );
574
        action->setData( VLCMenuBar::ACTION_STATIC );
575 576
        action = current->addAction( qtr( "Decrease Volume" ),
                ActionsManager::getInstance( p_intf ), SLOT( AudioDown() ) );
577
        action->setData( VLCMenuBar::ACTION_STATIC );
578 579
        action = current->addAction( qtr( "Mute" ),
                ActionsManager::getInstance( p_intf ), SLOT( toggleMuteAudio() ) );
580
        action->setData( VLCMenuBar::ACTION_STATIC );
581 582
}

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

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

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

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

613 614 615
    return Populate( p_intf, current, varnames, objects );
}

616
/* Subtitles */
617
QMenu *VLCMenuBar::SubtitleMenu( QMenu *current )
618 619 620 621 622 623 624 625
{
    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();
626
    return submenu;
627 628
}

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

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

646
        current->addSeparator();
647
        /* Surface modifiers */
648 649 650
        addActionWithCheckbox( current, "fullscreen", qtr( "&Fullscreen" ) );
        addActionWithCheckbox( current, "autoscale", qtr( "Always Fit &Window" ) );
        addActionWithCheckbox( current, "video-on-top", qtr( "Always &on Top" ) );
651
#ifdef WIN32
652
        addActionWithCheckbox( current, "direct3d-desktop", qtr( "Display on &Desktop" ) );
François Cartegnie's avatar
François Cartegnie committed
653
#endif
654

François Cartegnie's avatar
François Cartegnie committed
655
#ifdef WIN32
656
        addActionWithCheckbox( current, "video-wallpaper", qtr( "Set as Wall&paper" ) );
657
#endif
658
        current->addSeparator();
659
        /* Size modifiers */
660 661 662
        addActionWithSubmenu( current, "zoom", qtr( "&Zoom" ) );
        addActionWithSubmenu( current, "aspect-ratio", qtr( "&Aspect Ratio" ) );
        addActionWithSubmenu( current, "crop", qtr( "&Crop" ) );
663 664 665

        current->addSeparator();
        /* Rendering modifiers */
666 667 668
        addActionWithSubmenu( current, "deinterlace", qtr( "&Deinterlace" ) );
        addActionWithSubmenu( current, "deinterlace-mode", qtr( "&Deinterlace mode" ) );
        addActionWithSubmenu( current, "postprocess", qtr( "&Post processing" ) );
669 670 671 672

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

675 676
    p_input = THEMIM->getInput();

677
    p_vout = THEMIM->getVout();
678
    VideoAutoMenuBuilder( p_vout, p_input, objects, varnames );
679

680 681
    if( p_vout )
        vlc_object_release( p_vout );
682

683
    return Populate( p_intf, current, varnames, objects );
684 685
}

686 687 688 689
/**
 * Navigation Menu
 * For DVD, MP4, MOV and other chapter based format
 **/
690
QMenu *VLCMenuBar::NavigMenu( intf_thread_t *p_intf, QMenu *menu )
691
{
692
    QAction *action;
693
    QMenu *submenu;
694

695 696
    addActionWithSubmenu( menu, "title", qtr( "T&itle" ) );
    addActionWithSubmenu( menu, "chapter", qtr( "&Chapter" ) );
697 698
    submenu = addActionWithSubmenu( menu, "navigation", qtr( "&Navigation" ) );
    submenu->setTearOffEnabled( true );
699
    addActionWithSubmenu( menu, "program", qtr( "&Program" ) );
700

701
    /* FixMe: sync I_MENU_BOOKMARK string */
702 703
    submenu = new QMenu( qtr( "Custom &Bookmarks" ), menu );
    submenu->setTearOffEnabled( true );
704 705 706 707 708 709
    addDPStaticEntry( submenu, qtr( "&Manage" ), "",
                      SLOT( bookmarksDialog() ), "Ctrl+B" );
    submenu->addSeparator();
    action = menu->addMenu( submenu );
    action->setData( "bookmark" );

710 711
    menu->addSeparator();
    PopupMenuPlaylistControlEntries( menu, p_intf );
712
    PopupMenuControlEntries( menu, p_intf );
713

714 715
    EnableStaticEntries( menu, ( THEMIM->getInput() != NULL ) );
    return RebuildNavigMenu( p_intf, menu );
716 717
}

718
QMenu *VLCMenuBar::RebuildNavigMenu( intf_thread_t *p_intf, QMenu *menu )
719
{
720
    /* */
721
    input_thread_t *p_object;
722 723
    QVector<vlc_object_t *> objects;
    QVector<const char *> varnames;
724

725
    /* Get the input and hold it */
726
    p_object = THEMIM->getInput();
727

728
    InputAutoMenuBuilder( p_object, objects, varnames );
729

730 731
    menu->addSeparator();

732
    /* Title and so on */
733 734 735 736
    PUSH_VAR( "prev-title" );
    PUSH_VAR( "next-title" );
    PUSH_VAR( "prev-chapter" );
    PUSH_VAR( "next-chapter" );