menus.cpp 46 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
#include <vlc_vout.h>              /* vout_thread_t */
40
#include <vlc_aout.h>
41

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

44 45 46 47 48 49
#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*/
Clément Stenac's avatar
Clément Stenac committed
50

51 52 53 54 55 56
#include <QMenu>
#include <QMenuBar>
#include <QAction>
#include <QActionGroup>
#include <QSignalMapper>
#include <QSystemTrayIcon>
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
57
#include <QStatusBar>
58
#include <QFontMetrics>
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 76
#define STATIC_ENTRY "__static__"
#define ENTRY_ALWAYS_ENABLED "__ignore__"

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

static QActionGroup *currentGroup;

Ludovic Fauvet's avatar
Ludovic Fauvet committed
86 87
QMenu *QVLCMenu::recentsMenu = NULL;

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

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

Jean-Philippe Andre's avatar
Jean-Philippe Andre committed
156 157
    QList< QAction* > actions = menu->actions();
    for( int i = 0; i < actions.size(); ++i )
158
    {
159 160 161 162
        actions[i]->setEnabled( actions[i]->data().toString()
                                == ENTRY_ALWAYS_ENABLED ||
            /* Be careful here, because data("string").toBool is true */
            ( enable && (actions[i]->data().toString() == STATIC_ENTRY ) ) );
163 164 165
    }
}

166 167
/**
 * \return Number of static entries
168
 **/
169
inline int DeleteNonStaticEntries( QMenu *menu )
170
{
171 172
    if( !menu ) return VLC_EGENERIC;

173
    int i_ret = 0;
174

Jean-Philippe Andre's avatar
Jean-Philippe Andre committed
175 176
    QList< QAction* > actions = menu->actions();
    for( int i = 0; i < actions.size(); ++i )
177
    {
178
        if( actions[i]->data().toString() != STATIC_ENTRY )
Jean-Philippe Andre's avatar
Jean-Philippe Andre committed
179
            delete actions[i];
180 181 182
        else
            i_ret++;
    }
183
    return i_ret;
184 185
}

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

200
/*****************************************************************************
201
 * Definitions of variables for the dynamic menus
202
 *****************************************************************************/
203
#define PUSH_VAR( var ) varnames.push_back( var ); \
204
    objects.push_back( VLC_OBJECT(p_object) )
205 206

#define PUSH_INPUTVAR( var ) varnames.push_back( var ); \
207
    objects.push_back( VLC_OBJECT(p_input) );
208

209
static int InputAutoMenuBuilder( input_thread_t *p_object,
210
        vector<vlc_object_t *> &objects,
211
        vector<const char *> &varnames )
212
{
213
    PUSH_VAR( "bookmark" );
214
    PUSH_VAR( "title" );
215
    PUSH_VAR( "chapter" );
216
    PUSH_VAR( "navigation" );
217
    PUSH_VAR( "program" );
218 219 220
    return VLC_SUCCESS;
}

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

243 244 245
    return VLC_SUCCESS;
}

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

258 259
/*****************************************************************************
 * All normal menus
260
 * Simple Code
261 262
 *****************************************************************************/

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

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

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

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

291
// Add an action that is a checkbox
292 293 294 295 296 297
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 );
}
298

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

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

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

317
    addMenuToMainbar( ToolsMenu( bar ), qtr( "&Tools" ), bar );
318 319

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

322
    addMenuToMainbar( HelpMenu( bar ), qtr( "&Help" ), bar );
323

324
}
325 326

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

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

346
    menu->addSeparator();
347 348 349 350 351

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

352
    addDPStaticEntry( menu, qtr( "Open &Location from clipboard" ),
353
                      NULL, SLOT( openUrlDialog() ), "Ctrl+V" );
354

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

363 364 365 366
    addDPStaticEntry( menu, qtr( I_PL_SAVE ), "", SLOT( saveAPlaylist() ),
        "Ctrl+Y" );
    menu->addSeparator();

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

375 376 377 378 379
    action = addMIMStaticEntry( p_intf, menu, qtr( "Quit at the end of playlist" ), "",
                               SLOT( activatePlayQuit( bool ) ) );
    action->setCheckable( true );
    action->setChecked( THEMIM->getPlayExitState() );

380 381 382 383 384 385
    if( mi->getSysTray() )
    {
        action = menu->addAction( qtr( "Close to systray"), mi,
                                 SLOT( toggleUpdateSystrayMenu() ) );
    }

386
    addDPStaticEntry( menu, qtr( "&Quit" ) ,
387
        ":/menu/quit", SLOT( quit() ), "Ctrl+Q" );
388 389 390
    return menu;
}

391
/**
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
392
 * Tools, like Media Information, Preferences or Messages
393
 **/
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
394
QMenu *QVLCMenu::ToolsMenu( QMenu *menu )
Clément Stenac's avatar
Clément Stenac committed
395
{
396
    addDPStaticEntry( menu, qtr( "&Effects and Filters"), ":/menu/settings",
397
            SLOT( extendedDialog() ), "Ctrl+E" );
398

399
    addDPStaticEntry( menu, qtr( "&Track Synchronization"), ":/menu/settings",
400 401
            SLOT( synchroDialog() ), "" );

402
    addDPStaticEntry( menu, qtr( I_MENU_INFO ) , ":/menu/info",
403
        SLOT( mediaInfoDialog() ), "Ctrl+I" );
404
    addDPStaticEntry( menu, qtr( I_MENU_CODECINFO ) ,
405
        ":/menu/info", SLOT( mediaCodecDialog() ), "Ctrl+J" );
406

407
#ifdef ENABLE_VLM
408
    addDPStaticEntry( menu, qtr( I_MENU_VLM ), "", SLOT( vlmDialog() ),
409 410
        "Ctrl+W" );
#endif
411

412 413 414
    addDPStaticEntry( menu, qtr( "Program Guide" ), "", SLOT( epgDialog() ),
        "" );

415
    addDPStaticEntry( menu, qtr( I_MENU_MSG ),
416
        ":/menu/messages", SLOT( messagesDialog() ), "Ctrl+M" );
417

418 419
    addDPStaticEntry( menu, qtr( "Plu&gins and extensions" ),
        "", SLOT( pluginDialog() ) );
Clément Stenac's avatar
Clément Stenac committed
420 421
    menu->addSeparator();

422 423 424
    addDPStaticEntry( menu, qtr( "Customi&ze Interface..." ),
        ":/menu/preferences", SLOT( toolbarDialog() ) );

425
    addDPStaticEntry( menu, qtr( "&Preferences" ),
426
        ":/menu/preferences", SLOT( prefsDialog() ), "Ctrl+P", QAction::PreferencesRole );
427

Clément Stenac's avatar
Clément Stenac committed
428 429 430
    return menu;
}

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

441 442 443
    MainInterface *mi = _mi ? _mi : p_intf->p_sys->p_mi;
    assert( mi );

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

463 464 465 466
    menu->addAction(
#ifndef __APPLE__
            QIcon( ":/menu/playlist_menu" ),
#endif
467 468 469
            qtr( "Play&list" ), mi,
            SLOT( togglePlaylist() ), qtr( "Ctrl+L" ) );

470 471
    menu->addSeparator();

472
    /* Minimal View */
473
    action = menu->addAction( qtr( "Mi&nimal Interface" ) );
474
    action->setShortcut( qtr( "Ctrl+H" ) );
475
    action->setCheckable( true );
476
    action->setChecked( (mi->getControlsVisibilityStatus() & CONTROLS_HIDDEN ) );
477

478 479
    CONNECT( action, triggered( bool ), mi, toggleMinimalView( bool ) );
    CONNECT( mi, minimalViewToggled( bool ), action, setChecked( bool ) );
480 481 482

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

    /* Advanced Controls */
    action = menu->addAction( qtr( "&Advanced Controls" ), mi,
491
            SLOT( toggleAdvancedButtons() ) );
492 493 494 495
    action->setCheckable( true );
    if( mi->getControlsVisibilityStatus() & CONTROLS_ADVANCED )
        action->setChecked( true );

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

513
    menu->addSeparator();
514 515 516 517

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

518
    /* Extensions */
519
    ExtensionsMenu( p_intf, menu );
520

521 522 523
    return menu;
}

524 525 526
/**
 * Interface Sub-Menu, to list extras interface and skins
 **/
527 528
QMenu *QVLCMenu::InterfacesMenu( intf_thread_t *p_intf, QMenu *current )
{
529
    vector<vlc_object_t *> objects;
530 531
    vector<const char *> varnames;
    varnames.push_back( "intf-add" );
532
    objects.push_back( VLC_OBJECT(p_intf) );
Clément Stenac's avatar
Qt4:  
Clément Stenac committed
533

534
    return Populate( p_intf, current, varnames, objects );
535 536
}

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

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

551
    if( !extMgr->isLoaded() && !extMgr->cannotLoad() )
552
    {
553
        extMgr->loadExtensions();
554
    }
555

556
    /* Let the ExtensionsManager build itself the menu */
557
    extMenu->addSeparator();
558
    extMgr->menu( extMenu );
559 560
}

561 562
/**
 * Main Audio Menu
563
 **/
564 565
QMenu *QVLCMenu::AudioMenu( intf_thread_t *p_intf, QMenu * current )
{
566
    vector<vlc_object_t *> objects;
567
    vector<const char *> varnames;
568
    aout_instance_t *p_aout;
569 570 571
    input_thread_t *p_input;

    if( current->isEmpty() )
572
    {
573 574 575
        addActionWithSubmenu( current, "audio-es", qtr( "Audio &Track" ) );
        addActionWithSubmenu( current, "audio-channels", qtr( "Audio &Channels" ) );
        addActionWithSubmenu( current, "audio-device", qtr( "Audio &Device" ) );
576
        current->addSeparator();
577

578
        addActionWithSubmenu( current, "visual", qtr( "&Visualizations" ) );
579 580
        current->addSeparator();

581
        QAction *action = current->addAction( qtr( "Increase Volume" ),
582
                ActionsManager::getInstance( p_intf ), SLOT( AudioUp() ) );
583
        action->setData( STATIC_ENTRY );
584 585
        action = current->addAction( qtr( "Decrease Volume" ),
                ActionsManager::getInstance( p_intf ), SLOT( AudioDown() ) );
586
        action->setData( STATIC_ENTRY );
587 588
        action = current->addAction( qtr( "Mute" ),
                ActionsManager::getInstance( p_intf ), SLOT( toggleMuteAudio() ) );
589
        action->setData( STATIC_ENTRY );
590 591
    }

592
    p_input = THEMIM->getInput();
593
    p_aout = THEMIM->getAout();
594
    EnableStaticEntries( current, ( p_aout != NULL ) );
595
    AudioAutoMenuBuilder( p_aout, p_input, objects, varnames );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
596
    if( p_aout )
597
    {
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
598
        vlc_object_release( p_aout );
599
    }
600

601 602 603
    return Populate( p_intf, current, varnames, objects );
}

604
/* Subtitles */
605
QMenu *QVLCMenu::SubtitleMenu( QMenu *current )
606 607 608 609 610 611 612 613
{
    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();
614
    return submenu;
615 616
}

617 618 619 620
/**
 * Main Video Menu
 * Subtitles are part of Video.
 **/
621
QMenu *QVLCMenu::VideoMenu( intf_thread_t *p_intf, QMenu *current, bool b_subtitle )
622
{
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
623
    vout_thread_t *p_vout;
624
    input_thread_t *p_input;
625
    vector<vlc_object_t *> objects;
626 627
    vector<const char *> varnames;

628
    if( current->isEmpty() )
629
    {
630
        addActionWithSubmenu( current, "video-es", qtr( "Video &Track" ) );
631
        if( b_subtitle)
632
            SubtitleMenu( current );
633

634
        current->addSeparator();
635

636 637 638
        addActionWithCheckbox( current, "fullscreen", qtr( "&Fullscreen" ) );
        addActionWithCheckbox( current, "autoscale", qtr( "Always Fit &Window" ) );
        addActionWithCheckbox( current, "video-on-top", qtr( "Always &on Top" ) );
639
#ifdef WIN32
640
        addActionWithCheckbox( current, "direct3d-desktop", qtr( "Display on &Desktop" ) );
François Cartegnie's avatar
François Cartegnie committed
641
#endif
642
        addAction( current, "video-snapshot", qtr( "Take &Snapshot" ) );
François Cartegnie's avatar
François Cartegnie committed
643
#ifdef WIN32
644
        addActionWithCheckbox( current, "video-wallpaper", qtr( "Set as Wall&paper" ) );
645
#endif
646 647
        current->addSeparator();

648 649 650 651 652 653
        addActionWithSubmenu( current, "zoom", qtr( "&Zoom" ) );
        addActionWithSubmenu( current, "aspect-ratio", qtr( "&Aspect Ratio" ) );
        addActionWithSubmenu( current, "crop", qtr( "&Crop" ) );
        addActionWithSubmenu( current, "deinterlace", qtr( "&Deinterlace" ) );
        addActionWithSubmenu( current, "deinterlace-mode", qtr( "&Deinterlace mode" ) );
        addActionWithSubmenu( current, "postprocess", qtr( "&Post processing" ) );
654
    }
655

656 657
    p_input = THEMIM->getInput();

658
    p_vout = THEMIM->getVout();
659
    VideoAutoMenuBuilder( p_vout, p_input, objects, varnames );
660

661 662
    if( p_vout )
        vlc_object_release( p_vout );
663

664
    return Populate( p_intf, current, varnames, objects );
665 666
}

667 668 669 670
/**
 * Navigation Menu
 * For DVD, MP4, MOV and other chapter based format
 **/
671
QMenu *QVLCMenu::NavigMenu( intf_thread_t *p_intf, QMenu *menu )
672
{
673
    QAction *action;
674

675 676 677 678
    addActionWithSubmenu( menu, "title", qtr( "T&itle" ) );
    addActionWithSubmenu( menu, "chapter", qtr( "&Chapter" ) );
    addActionWithSubmenu( menu, "navigation", qtr( "&Navigation" ) );
    addActionWithSubmenu( menu, "program", qtr( "&Program" ) );
679

680 681 682 683 684 685 686 687
    /* FixMe: sync I_MENU_BOOKMARK string */
    QMenu *submenu = new QMenu( qtr( "Custom &Bookmarks" ), menu );
    addDPStaticEntry( submenu, qtr( "&Manage" ), "",
                      SLOT( bookmarksDialog() ), "Ctrl+B" );
    submenu->addSeparator();
    action = menu->addMenu( submenu );
    action->setData( "bookmark" );

688 689
    menu->addSeparator();
    PopupMenuPlaylistControlEntries( menu, p_intf );
690
    PopupMenuControlEntries( menu, p_intf );
691

692 693
    EnableStaticEntries( menu, ( THEMIM->getInput() != NULL ) );
    return RebuildNavigMenu( p_intf, menu );
694 695 696 697
}

QMenu *QVLCMenu::RebuildNavigMenu( intf_thread_t *p_intf, QMenu *menu )
{
698
    /* */
699 700 701 702
    input_thread_t *p_object;
    vector<vlc_object_t *> objects;
    vector<const char *> varnames;

703
    /* Get the input and hold it */
704
    p_object = THEMIM->getInput();
705

706
    InputAutoMenuBuilder( p_object, objects, varnames );
707

708 709
    menu->addSeparator();

710
    /* Title and so on */
711 712 713 714
    PUSH_VAR( "prev-title" );
    PUSH_VAR( "next-title" );
    PUSH_VAR( "prev-chapter" );
    PUSH_VAR( "next-chapter" );
715

716
    EnableStaticEntries( menu, (p_object != NULL ) );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
717
    return Populate( p_intf, menu, varnames, objects );
718
}
719

720 721 722
/**
 * Help/About Menu
**/
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
723
QMenu *QVLCMenu::HelpMenu( QWidget *parent )
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
724
{
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
725
    QMenu *menu = new QMenu( parent );
726
    addDPStaticEntry( menu, qtr( "&Help..." ) ,
727
        ":/menu/help", SLOT( helpDialog() ), "F1" );
728
#ifdef UPDATE_CHECK
729 730
    addDPStaticEntry( menu, qtr( "Check for &Updates..." ) , "",
                      SLOT( updateDialog() ) );
731
#endif
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
732
    menu->addSeparator();
733
    addDPStaticEntry( menu, qtr( I_MENU_ABOUT ), ":/menu/info",
734
            SLOT( aboutDialog() ), "Shift+F1", QAction::AboutRole );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
735 736 737
    return menu;
}