menus.cpp 48 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
    PUSH_VAR( "video-snapshot" );
237
    PUSH_VAR( "zoom" );
238
    PUSH_VAR( "autoscale" );
239 240
    PUSH_VAR( "aspect-ratio" );
    PUSH_VAR( "crop" );
241
    PUSH_VAR( "deinterlace" );
242
    PUSH_VAR( "deinterlace-mode" );
243
    PUSH_VAR( "postprocess" );
244

245 246 247
    return VLC_SUCCESS;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

328
}
329 330

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

474 475
    menu->addSeparator();

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

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

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

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

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

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

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

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

525 526 527
    return menu;
}

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

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

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

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

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

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

565 566 567 568 569 570
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() ) );
571
        action->setData( VLCMenuBar::ACTION_STATIC );
572 573
        action = current->addAction( qtr( "Decrease Volume" ),
                ActionsManager::getInstance( p_intf ), SLOT( AudioDown() ) );
574
        action->setData( VLCMenuBar::ACTION_STATIC );
575 576
        action = current->addAction( qtr( "Mute" ),
                ActionsManager::getInstance( p_intf ), SLOT( toggleMuteAudio() ) );
577
        action->setData( VLCMenuBar::ACTION_STATIC );
578 579
}

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

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

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

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

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

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

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

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

643
        current->addSeparator();
644
        /* Surface modifiers */
645 646 647 648
        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" ) );
649

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

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

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

667 668
    p_input = THEMIM->getInput();

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

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

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

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

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

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

702 703
    menu->addSeparator();
    PopupMenuPlaylistControlEntries( menu, p_intf );
704
    PopupMenuControlEntries( menu, p_intf );
705

706 707
    EnableStaticEntries( menu, ( THEMIM->getInput() != NULL ) );
    return RebuildNavigMenu( p_intf, menu );
708 709
}

710
QMenu *VLCMenuBar::RebuildNavigMenu( intf_thread_t *p_intf, QMenu *menu )
711
{
712
    /* */
713
    input_thread_t *p_object;
714 715
    QVector<vlc_object_t *> objects;
    QVector<const char *> varnames;
716

717
    /* Get the input and hold it */
718
    p_object = THEMIM->getInput();
719

720
    InputAutoMenuBuilder( p_object, objects, varnames );
721

722 723
    menu->addSeparator();

724
    /* Title and so on */
725 726 727 728
    PUSH_VAR( "prev-title" );
    PUSH_VAR( "next-title" );
    PUSH_VAR( "prev-chapter" );
    PUSH_VAR( "next-chapter" );
729

730
    EnableStaticEntries( menu, (p_object != NULL ) );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
731
    return Populate( p_intf, menu, varnames, objects );
732
}
733

734 735 736
/**
 * Help/About Menu
**/
737
QMenu *VLCMenuBar::HelpMenu( QWidget *parent )
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
738
{