menus.cpp 45.9 KB
Newer Older
1 2 3
/*****************************************************************************
 * menus.cpp : Qt menus
 *****************************************************************************
4
 * Copyright © 2006-2009 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_intf_strings.h>
38
#include <vlc_services_discovery.h>
39
#include <vlc_aout.h>
40
#include <vlc_vout.h>
41

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

#include "main_interface.hpp"    /* View modifications */
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
45 46 47
#include "dialogs_provider.hpp"  /* Dialogs display */
#include "input_manager.hpp"     /* Input Management */
#include "recents.hpp"           /* Recent Items */
48
#include "actions_manager.hpp"
49
#include "extensions_manager.hpp"
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>
Ludovic Fauvet's avatar
Ludovic Fauvet committed
57
#include <QList>
58

59 60 61 62 63 64 65 66 67 68 69 70 71 72
/*
  This file defines the main menus and the pop-up menu (right-click menu)
  and the systray menu (in that order in the file)

  There are 3 menus that have to be rebuilt everytime there are called:
  Audio, Video, Navigation
  3 functions are building those menus: AudioMenu, VideoMenu, NavigMenu
  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.
  */

73 74 75
#define STATIC_ENTRY "__static__"
#define ENTRY_ALWAYS_ENABLED "__ignore__"

76 77 78 79 80 81 82 83 84
enum
{
    ITEM_NORMAL,
    ITEM_CHECK,
    ITEM_RADIO
};

static QActionGroup *currentGroup;

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

87 88 89 90 91
/****************************************************************************
 * Menu code helpers:
 ****************************************************************************
 * Add static entries to DP in menus
 ***************************************************************************/
92
void addDPStaticEntry( QMenu *menu,
93
                       const QString& text,
94
                       const char *icon,
95
                       const char *member,
96
                       const char *shortcut = NULL )
97
{
98
    QAction *action = NULL;
Rémi Duraffort's avatar
Rémi Duraffort committed
99
    if( !EMPTY_STR( icon ) )
100
    {
Rémi Duraffort's avatar
Rémi Duraffort committed
101
        if( !EMPTY_STR( shortcut ) )
102 103
            action = menu->addAction( QIcon( icon ), text, THEDP,
                                      member, qtr( shortcut ) );
104
        else
105
            action = menu->addAction( QIcon( icon ), text, THEDP, member );
106 107 108
    }
    else
    {
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
    }
114
    action->setData( STATIC_ENTRY );
115
}
116

117 118 119
/***
 * Same for MIM
 ***/
120 121
QAction* addMIMStaticEntry( intf_thread_t *p_intf,
                            QMenu *menu,
122
                            const QString& text,
123 124 125
                            const char *icon,
                            const char *member,
                            bool bStatic = false )
126
{
127
    QAction *action;
Rémi Duraffort's avatar
Rémi Duraffort committed
128
    if( !EMPTY_STR( icon ) )
129
    {
130
        action = menu->addAction( text, THEMIM,  member );
131 132 133 134
        action->setIcon( QIcon( icon ) );
    }
    else
    {
Rémi Duraffort's avatar
Rémi Duraffort committed
135
        action = menu->addAction( text, THEMIM, member );
136
    }
137
    action->setData( bStatic ? STATIC_ENTRY : ENTRY_ALWAYS_ENABLED );
138
    return action;
139 140
}

141 142 143 144 145
/**
 * @brief Enable all static entries, disable the others
 * @param enable if false, disable all entries
 */
void EnableStaticEntries( QMenu *menu, bool enable = true )
146
{
147
    if( !menu ) return;
148

Jean-Philippe Andre's avatar
Jean-Philippe Andre committed
149 150
    QList< QAction* > actions = menu->actions();
    for( int i = 0; i < actions.size(); ++i )
151
    {
152 153 154 155
        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 ) ) );
156 157 158
    }
}

159 160 161 162 163
/**
 * \return Number of static entries
 */
int DeleteNonStaticEntries( QMenu *menu )
{
164 165
    if( !menu ) return VLC_EGENERIC;

166
    int i_ret = 0;
167

Jean-Philippe Andre's avatar
Jean-Philippe Andre committed
168 169
    QList< QAction* > actions = menu->actions();
    for( int i = 0; i < actions.size(); ++i )
170
    {
171
        if( actions[i]->data().toString() != STATIC_ENTRY )
Jean-Philippe Andre's avatar
Jean-Philippe Andre committed
172
            delete actions[i];
173 174 175
        else
            i_ret++;
    }
176
    return i_ret;
177 178
}

179 180 181 182
/**
 * \return QAction associated to psz_var variable
 **/
static QAction * FindActionWithVar( QMenu *menu, const char *psz_var )
183
{
184 185
    QList< QAction* > actions = menu->actions();
    for( int i = 0; i < actions.size(); ++i )
186
    {
187 188
        if( actions[i]->data().toString() == psz_var )
            return actions[i];
189
    }
190
    return NULL;
191 192
}

193
/*****************************************************************************
194
 * Definitions of variables for the dynamic menus
195
 *****************************************************************************/
196
#define PUSH_VAR( var ) varnames.push_back( var ); \
197
    objects.push_back( VLC_OBJECT(p_object) )
198 199

#define PUSH_INPUTVAR( var ) varnames.push_back( var ); \
200
    objects.push_back( VLC_OBJECT(p_input) );
201 202

#define PUSH_SEPARATOR if( objects.size() != i_last_separator ) { \
203
    objects.push_back( 0 ); varnames.push_back( "" ); \
204
    i_last_separator = objects.size(); }
205

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

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

240 241 242
    return VLC_SUCCESS;
}

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

255 256
/*****************************************************************************
 * All normal menus
257
 * Simple Code
258 259 260
 *****************************************************************************/

#define BAR_ADD( func, title ) { \
261
    QMenu *_menu = func; _menu->setTitle( title ); bar->addMenu( _menu ); }
262 263

#define BAR_DADD( func, title, id ) { \
264 265 266 267 268 269 270 271
    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 ); }

#define ACT_ADD( _menu, val, title ) { \
    QAction *_action = new QAction( title, _menu ); _action->setData( val ); \
    _menu->addAction( _action ); }
272

273 274
#define ACT_ADDMENU( _menu, val, title ) { \
    QAction *_action = new QAction( title, _menu ); _action->setData( val ); \
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
275
    _action->setMenu( new QMenu( _menu ) ); _menu->addAction( _action ); }
276 277 278 279 280

#define ACT_ADDCHECK( _menu, val, title ) { \
    QAction *_action = new QAction( title, _menu ); _action->setData( val ); \
    _action->setCheckable( true ); _menu->addAction( _action ); }

281 282 283
/**
 * Main Menu Bar Creation
 **/
284
void QVLCMenu::createMenuBar( MainInterface *mi,
285
                              intf_thread_t *p_intf )
Clément Stenac's avatar
Qt4:  
Clément Stenac committed
286
{
287 288 289
    /* QMainWindows->menuBar()
       gives the QProcess::destroyed timeout issue on Cleanlooks style with
       setDesktopAware set to false */
290
    QMenuBar *bar = mi->menuBar();
291

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
292
    BAR_ADD( FileMenu( p_intf, bar ), qtr( "&Media" ) );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
293

294
    /* Dynamic menus, rebuilt before being showed */
295
    BAR_DADD( NavigMenu( p_intf, bar ), qtr( "P&layback" ), 3 );
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
296 297
    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
298

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
299
    BAR_ADD( ToolsMenu( bar ), qtr( "&Tools" ) );
300 301 302 303
    QMenu *_menu = ViewMenu( p_intf, bar );
    _menu->setTitle( qtr( "V&iew" ) );
    bar->addMenu( _menu );
    ViewMenu( p_intf, _menu, mi );
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
304
    BAR_ADD( HelpMenu( bar ), qtr( "&Help" ) );
305

306
}
307 308
#undef BAR_ADD
#undef BAR_DADD
309 310

/**
311
 * Media ( File ) Menu
312 313
 * Opening, streaming and quit
 **/
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
314
QMenu *QVLCMenu::FileMenu( intf_thread_t *p_intf, QWidget *parent )
315
{
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
316
    QMenu *menu = new QMenu( parent );
317

318
    addDPStaticEntry( menu, qtr( "&Open File..." ),
319
        ":/type/file-asym", SLOT( simpleOpenDialog() ), "Ctrl+O" );
320
    addDPStaticEntry( menu, qtr( "Advanced Open File..." ),
321
        ":/type/file-asym", SLOT( openFileDialog() ), "Ctrl+Shift+O" );
322
    addDPStaticEntry( menu, qtr( I_OP_OPDIR ),
323
        ":/type/folder-grey", SLOT( PLOpenDir() ), "Ctrl+F" );
324
    addDPStaticEntry( menu, qtr( "Open &Disc..." ),
325
        ":/type/disc", SLOT( openDiscDialog() ), "Ctrl+D" );
326
    addDPStaticEntry( menu, qtr( "Open &Network Stream..." ),
327
        ":/type/network", SLOT( openNetDialog() ), "Ctrl+N" );
328
    addDPStaticEntry( menu, qtr( "Open &Capture Device..." ),
329
        ":/type/capture-card", SLOT( openCaptureDialog() ),
330
        "Ctrl+C" );
331

332
    menu->addSeparator();
333
    addDPStaticEntry( menu, qtr( "Open &Location from clipboard" ),
334
                      NULL, SLOT( openUrlDialog() ), "Ctrl+V" );
335

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
336
    if( var_InheritBool( p_intf, "qt-recentplay" ) )
337 338 339 340 341
    {
        recentsMenu = new QMenu( qtr( "&Recent Media" ), menu );
        updateRecents( p_intf );
        menu->addMenu( recentsMenu );
    }
342
    menu->addSeparator();
343

344 345 346 347
    addDPStaticEntry( menu, qtr( I_PL_SAVE ), "", SLOT( saveAPlaylist() ),
        "Ctrl+Y" );
    menu->addSeparator();

348
#ifdef ENABLE_SOUT
349
    addDPStaticEntry( menu, qtr( "Conve&rt / Save..." ), "",
350
        SLOT( openAndTranscodingDialogs() ), "Ctrl+R" );
351
    addDPStaticEntry( menu, qtr( "&Streaming..." ),
352
        ":/menu/stream", SLOT( openAndStreamingDialogs() ),
353
        "Ctrl+S" );
354
    menu->addSeparator();
355
#endif
356

357
    addDPStaticEntry( menu, qtr( "&Quit" ) ,
358
        ":/menu/quit", SLOT( quit() ), "Ctrl+Q" );
359 360 361
    return menu;
}

362
/**
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
363
 * Tools, like Media Information, Preferences or Messages
364
 **/
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
365
QMenu *QVLCMenu::ToolsMenu( QMenu *menu )
Clément Stenac's avatar
Clément Stenac committed
366
{
367
    addDPStaticEntry( menu, qtr( "&Effects and Filters"), ":/menu/settings",
368
            SLOT( extendedDialog() ), "Ctrl+E" );
369

370
    addDPStaticEntry( menu, qtr( "&Track Synchronization"), ":/menu/settings",
371 372
            SLOT( synchroDialog() ), "" );

373
    addDPStaticEntry( menu, qtr( I_MENU_INFO ) , ":/menu/info",
374
        SLOT( mediaInfoDialog() ), "Ctrl+I" );
375
    addDPStaticEntry( menu, qtr( I_MENU_CODECINFO ) ,
376
        ":/menu/info", SLOT( mediaCodecDialog() ), "Ctrl+J" );
377

378
    addDPStaticEntry( menu, qtr( I_MENU_BOOKMARK ),"",
379 380
                      SLOT( bookmarksDialog() ), "Ctrl+B" );
#ifdef ENABLE_VLM
381
    addDPStaticEntry( menu, qtr( I_MENU_VLM ), "", SLOT( vlmDialog() ),
382 383
        "Ctrl+W" );
#endif
384

385 386 387
    addDPStaticEntry( menu, qtr( "Program Guide" ), "", SLOT( epgDialog() ),
        "" );

388
    addDPStaticEntry( menu, qtr( I_MENU_MSG ),
389
        ":/menu/messages", SLOT( messagesDialog() ),
390 391
        "Ctrl+M" );

392 393
    addDPStaticEntry( menu, qtr( "Plu&gins and extensions" ),
        "", SLOT( pluginDialog() ) );
Clément Stenac's avatar
Clément Stenac committed
394 395
    menu->addSeparator();

396
    addDPStaticEntry( menu, qtr( "&Preferences" ),
397
        ":/menu/preferences", SLOT( prefsDialog() ), "Ctrl+P" );
398

Clément Stenac's avatar
Clément Stenac committed
399 400 401
    return menu;
}

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
402 403 404 405 406
QMenu *QVLCMenu::ToolsMenu( QWidget *parent )
{
    return ToolsMenu( new QMenu( parent ) );
}

407 408 409 410 411 412 413 414 415 416 417 418 419
/**
 * Dynamic View Menu
 * Connect signal "aboutToShow" to the creation of the View Menu
 **/
QMenu *QVLCMenu::ViewMenu( intf_thread_t *p_intf, QWidget* parent )
{
    QMenu *viewMenu = new QMenu( parent );
    MenuFunc *f = new MenuFunc( viewMenu, 4 );
    CONNECT( viewMenu, aboutToShow(), THEDP->menusUpdateMapper, map() );
    THEDP->menusUpdateMapper->setMapping( viewMenu, f );
    return viewMenu;
}

420
/**
421
 * View Menu
422
 * Interface modification, load other interfaces, activate Extensions
423
 **/
424
QMenu *QVLCMenu::ViewMenu( intf_thread_t *p_intf, QMenu *current, MainInterface *_mi )
425
{
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
426
    QAction *action;
427
    QMenu *menu;
428

429 430 431
    MainInterface *mi = _mi ? _mi : p_intf->p_sys->p_mi;
    assert( mi );

432 433
    if( !current )
    {
434
        menu = new QMenu( qtr( "&View" ), mi );
435
    }
436 437 438
    else
    {
        menu = current;
439 440 441 442 443 444 445 446
        //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 );
447
            if( m && m->parent() == menu ) delete m;
448
        }
449
    }
450

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
451
    menu->addAction( QIcon( ":/menu/playlist_menu" ),
452 453 454
            qtr( "Play&list" ), mi,
            SLOT( togglePlaylist() ), qtr( "Ctrl+L" ) );

455 456
    menu->addSeparator();

457 458
    QMenu *intfmenu = InterfacesMenu( p_intf, menu );
    menu->addSeparator();
459

460
    /* Minimal View */
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
461
    action = menu->addAction( qtr( "Mi&nimal View" ) );
462
    action->setShortcut( qtr( "Ctrl+H" ) );
463
    action->setCheckable( true );
464
    action->setChecked( (mi->getControlsVisibilityStatus() & CONTROLS_HIDDEN ) );
465

466 467
    CONNECT( action, triggered( bool ), mi, toggleMinimalView( bool ) );
    CONNECT( mi, minimalViewToggled( bool ), action, setChecked( bool ) );
468 469 470

    /* FullScreen View */
    action = menu->addAction( qtr( "&Fullscreen Interface" ), mi,
471
            SLOT( toggleInterfaceFullScreen() ), QString( "F11" ) );
472
    action->setCheckable( true );
473
    action->setChecked( mi->isInterfaceFullScreen() );
474 475
    CONNECT( mi, fullscreenInterfaceToggled( bool ),
             action, setChecked( bool ) );
476 477 478

    /* Advanced Controls */
    action = menu->addAction( qtr( "&Advanced Controls" ), mi,
479
            SLOT( toggleAdvancedButtons() ) );
480 481 482 483
    action->setCheckable( true );
    if( mi->getControlsVisibilityStatus() & CONTROLS_ADVANCED )
        action->setChecked( true );

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
484 485 486 487 488 489
    /* Docked Playlist */
    action = menu->addAction( qtr( "Docked Playlist" ) );
    action->setCheckable( true );
    action->setChecked( mi->isPlDocked() );
    CONNECT( action, triggered( bool ), mi, dockPlaylist( bool ) );

490 491 492 493
    action = menu->addAction( qtr( "Quit after Playback" ) );
    action->setCheckable( true );
    action->setChecked( THEMIM->getPlayExitState() );
    CONNECT( action, triggered( bool ), THEMIM, activatePlayQuit( bool ) );
494

495
#if 0 /* For Visualisations. Not yet working */
496 497 498 499
    adv = menu->addAction( qtr( "Visualizations selector" ),
            mi, SLOT( visual() ) );
    adv->setCheckable( true );
    if( visual_selector_enabled ) adv->setChecked( true );
500
#endif
501

502
    menu->addSeparator();
503
    addDPStaticEntry( menu, qtr( "Customi&ze Interface..." ),
504
        ":/menu/preferences", SLOT( toolbarDialog() ) );
505

506
    /* Extensions */
507
    ExtensionsMenu( p_intf, menu );
508

509 510 511
    return menu;
}

512 513 514
/**
 * Interface Sub-Menu, to list extras interface and skins
 **/
515 516
QMenu *QVLCMenu::InterfacesMenu( intf_thread_t *p_intf, QMenu *current )
{
517
    vector<vlc_object_t *> objects;
518 519
    vector<const char *> varnames;
    varnames.push_back( "intf-add" );
520
    objects.push_back( VLC_OBJECT(p_intf) );
Clément Stenac's avatar
Qt4:  
Clément Stenac committed
521

522
    return Populate( p_intf, current, varnames, objects );
523 524
}

525
/**
526
 * Extensions menu: populate the current menu with extensions
527
 **/
528
void QVLCMenu::ExtensionsMenu( intf_thread_t *p_intf, QMenu *extMenu )
529
{
530
    /* Get ExtensionsManager and load extensions if needed */
531
    ExtensionsManager *extMgr = ExtensionsManager::getInstance( p_intf );
532 533 534 535 536 537 538

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

539
    if( !extMgr->isLoaded() && !extMgr->cannotLoad() )
540
    {
541
        extMgr->loadExtensions();
542
    }
543

544
    /* Let the ExtensionsManager build itself the menu */
545
    extMenu->addSeparator();
546
    extMgr->menu( extMenu );
547 548
}

549 550
/**
 * Main Audio Menu
551
 **/
552 553
QMenu *QVLCMenu::AudioMenu( intf_thread_t *p_intf, QMenu * current )
{
554
    vector<vlc_object_t *> objects;
555
    vector<const char *> varnames;
556
    aout_instance_t *p_aout;
557 558 559
    input_thread_t *p_input;

    if( current->isEmpty() )
560
    {
561 562 563
        ACT_ADDMENU( current, "audio-es", qtr( "Audio &Track" ) );
        ACT_ADDMENU( current, "audio-channels", qtr( "Audio &Channels" ) );
        ACT_ADDMENU( current, "audio-device", qtr( "Audio &Device" ) );
564
        current->addSeparator();
565

566
        ACT_ADDMENU( current, "visual", qtr( "&Visualizations" ) );
567 568
        current->addSeparator();

569
        QAction *action = current->addAction( qtr( "Increase Volume" ),
570
                ActionsManager::getInstance( p_intf ), SLOT( AudioUp() ) );
571
        action->setData( STATIC_ENTRY );
572 573
        action = current->addAction( qtr( "Decrease Volume" ),
                ActionsManager::getInstance( p_intf ), SLOT( AudioDown() ) );
574
        action->setData( STATIC_ENTRY );
575 576
        action = current->addAction( qtr( "Mute" ),
                ActionsManager::getInstance( p_intf ), SLOT( toggleMuteAudio() ) );
577
        action->setData( STATIC_ENTRY );
578 579
    }

580
    p_input = THEMIM->getInput();
581
    p_aout = THEMIM->getAout();
582
    EnableStaticEntries( current, ( p_aout != NULL ) );
583
    AudioAutoMenuBuilder( p_aout, p_input, objects, varnames );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
584
    if( p_aout )
585
    {
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
586
        vlc_object_release( p_aout );
587
    }
588

589 590 591
    return Populate( p_intf, current, varnames, objects );
}

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
592 593 594 595 596
QMenu *QVLCMenu::AudioMenu( intf_thread_t *p_intf, QWidget *parent )
{
    return AudioMenu( p_intf, new QMenu( parent ) );
}

597 598 599 600
/**
 * Main Video Menu
 * Subtitles are part of Video.
 **/
601
QMenu *QVLCMenu::VideoMenu( intf_thread_t *p_intf, QMenu *current )
602
{
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
603
    vout_thread_t *p_vout;
604
    input_thread_t *p_input;
605
    vector<vlc_object_t *> objects;
606 607
    vector<const char *> varnames;

608
    if( current->isEmpty() )
609
    {
610
        ACT_ADDMENU( current, "video-es", qtr( "Video &Track" ) );
611 612 613 614 615

        QAction *action;
        QMenu *submenu = new QMenu( qtr( "&Subtitles Track" ), current );
        action = current->addMenu( submenu );
        action->setData( "spu-es" );
616
        addDPStaticEntry( submenu, qtr( "Open File..." ), "",
617
                          SLOT( loadSubtitlesFile() ) );
618
        submenu->addSeparator();
619
        current->addSeparator();
620

621 622
        ACT_ADDCHECK( current, "fullscreen", qtr( "&Fullscreen" ) );
        ACT_ADDCHECK( current, "video-on-top", qtr( "Always &On Top" ) );
623
        ACT_ADDCHECK( current, "video-wallpaper", qtr( "DirectX Wallpaper" ) );
624
#ifdef WIN32
625
        ACT_ADDCHECK( current, "direct3d-desktop", qtr( "Direct3D Desktop mode" ) );
626
#endif
627
        ACT_ADD( current, "video-snapshot", qtr( "Sna&pshot" ) );
628

629 630
        current->addSeparator();

631 632 633 634
        ACT_ADDMENU( current, "zoom", qtr( "&Zoom" ) );
        ACT_ADDCHECK( current, "autoscale", qtr( "Sca&le" ) );
        ACT_ADDMENU( current, "aspect-ratio", qtr( "&Aspect Ratio" ) );
        ACT_ADDMENU( current, "crop", qtr( "&Crop" ) );
635 636
        ACT_ADDMENU( current, "deinterlace", qtr( "&Deinterlace" ) );
        ACT_ADDMENU( current, "deinterlace-mode", qtr( "&Deinterlace mode" ) );
637
        ACT_ADDMENU( current, "postprocess", qtr( "&Post processing" ) );
638
    }
639

640 641
    p_input = THEMIM->getInput();

642
    p_vout = THEMIM->getVout();
643
    VideoAutoMenuBuilder( p_vout, p_input, objects, varnames );
644

645 646
    if( p_vout )
        vlc_object_release( p_vout );
647

648
    return Populate( p_intf, current, varnames, objects );
649 650
}

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
651 652 653 654 655
QMenu *QVLCMenu::VideoMenu( intf_thread_t *p_intf, QWidget *parent )
{
    return VideoMenu( p_intf, new QMenu( parent ) );
}

656 657 658 659
/**
 * Navigation Menu
 * For DVD, MP4, MOV and other chapter based format
 **/
660
QMenu *QVLCMenu::NavigMenu( intf_thread_t *p_intf, QMenu *menu )
661
{
662
    QAction *action;
663

664 665 666 667 668 669
    QMenu *submenu = new QMenu( qtr( "&Bookmarks" ), menu );
    addDPStaticEntry( submenu, qtr( "Manage &bookmarks" ), "",
                      SLOT( bookmarksDialog() ) );
    submenu->addSeparator();
    action = menu->addMenu( submenu );
    action->setData( "bookmark" );
670

671 672 673 674
    ACT_ADDMENU( menu, "title", qtr( "T&itle" ) );
    ACT_ADDMENU( menu, "chapter", qtr( "&Chapter" ) );
    ACT_ADDMENU( menu, "navigation", qtr( "&Navigation" ) );
    ACT_ADDMENU( menu, "program", qtr( "&Program" ) );
675

676 677
    menu->addSeparator();
    PopupMenuPlaylistControlEntries( menu, p_intf );
678
    PopupMenuControlEntries( menu, p_intf );
679

680 681
    EnableStaticEntries( menu, ( THEMIM->getInput() != NULL ) );
    return RebuildNavigMenu( p_intf, menu );
682 683 684 685
}

QMenu *QVLCMenu::RebuildNavigMenu( intf_thread_t *p_intf, QMenu *menu )
{
686
    /* */
687 688 689 690
    input_thread_t *p_object;
    vector<vlc_object_t *> objects;
    vector<const char *> varnames;

691
    /* Get the input and hold it */
692
    p_object = THEMIM->getInput();
693

694
    InputAutoMenuBuilder( p_object, objects, varnames );
695

696 697
    menu->addSeparator();

698
    /* Title and so on */
699 700 701 702
    PUSH_VAR( "prev-title" );
    PUSH_VAR( "next-title" );
    PUSH_VAR( "prev-chapter" );
    PUSH_VAR( "next-chapter" );
703

704
    EnableStaticEntries( menu, (p_object != NULL ) );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
705
    return Populate( p_intf, menu, varnames, objects );
706
}
707

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
708 709 710 711 712
QMenu *QVLCMenu::NavigMenu( intf_thread_t *p_intf, QWidget *parent )
{
    return NavigMenu( p_intf, new QMenu( parent ) );
}

713
/**
714
 * Service Discovery SubMenu
715
 **/
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
716
QMenu *QVLCMenu::SDMenu( intf_thread_t *p_intf, QWidget *parent )
Clément Stenac's avatar
Clément Stenac committed
717
{
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
718
    QMenu *menu = new QMenu( parent );
719
    menu->setTitle( qtr( I_PL_SD ) );
720

721
    char **ppsz_longnames;
722
    char **ppsz_names = vlc_sd_GetNames( p_intf, &ppsz_longnames, NULL );
723 724 725
    if( !ppsz_names )
        return menu;

726 727
    char **ppsz_name = ppsz_names, **ppsz_longname = ppsz_longnames;
    for( ; *ppsz_name; ppsz_name++, ppsz_longname++ )