menus.cpp 46.4 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;
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( STATIC_ENTRY );
117
}
118

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

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

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

163 164 165 166 167
/**
 * \return Number of static entries
 */
int DeleteNonStaticEntries( QMenu *menu )
{
168 169
    if( !menu ) return VLC_EGENERIC;

170
    int i_ret = 0;
171

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

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

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

#define PUSH_INPUTVAR( var ) varnames.push_back( var ); \
204
    objects.push_back( VLC_OBJECT(p_input) );
205 206

#define PUSH_SEPARATOR if( objects.size() != i_last_separator ) { \
207
    objects.push_back( 0 ); varnames.push_back( "" ); \
208
    i_last_separator = objects.size(); }
209

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

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

244 245 246
    return VLC_SUCCESS;
}

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

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

#define BAR_ADD( func, title ) { \
265
    QMenu *_menu = func; _menu->setTitle( title ); bar->addMenu( _menu ); }
266 267

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

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

277 278
#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
279
    _action->setMenu( new QMenu( _menu ) ); _menu->addAction( _action ); }
280 281 282 283 284

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

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

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

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

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
303
    BAR_ADD( ToolsMenu( bar ), qtr( "&Tools" ) );
304 305 306 307
    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
308
    BAR_ADD( HelpMenu( bar ), qtr( "&Help" ) );
309

310
}
311 312
#undef BAR_ADD
#undef BAR_DADD
313 314

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

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

336
    menu->addSeparator();
337
    addDPStaticEntry( menu, qtr( "Open &Location from clipboard" ),
338
                      NULL, SLOT( openUrlDialog() ), "Ctrl+V" );
339

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

348 349 350 351
    addDPStaticEntry( menu, qtr( I_PL_SAVE ), "", SLOT( saveAPlaylist() ),
        "Ctrl+Y" );
    menu->addSeparator();

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

361
    addDPStaticEntry( menu, qtr( "&Quit" ) ,
362
        ":/menu/quit", SLOT( quit() ), "Ctrl+Q" );
363 364 365
    return menu;
}

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

374
    addDPStaticEntry( menu, qtr( "&Track Synchronization"), ":/menu/settings",
375 376
            SLOT( synchroDialog() ), "" );

377
    addDPStaticEntry( menu, qtr( I_MENU_INFO ) , ":/menu/info",
378
        SLOT( mediaInfoDialog() ), "Ctrl+I" );
379
    addDPStaticEntry( menu, qtr( I_MENU_CODECINFO ) ,
380
        ":/menu/info", SLOT( mediaCodecDialog() ), "Ctrl+J" );
381

382
    addDPStaticEntry( menu, qtr( I_MENU_BOOKMARK ),"",
383 384
                      SLOT( bookmarksDialog() ), "Ctrl+B" );
#ifdef ENABLE_VLM
385
    addDPStaticEntry( menu, qtr( I_MENU_VLM ), "", SLOT( vlmDialog() ),
386 387
        "Ctrl+W" );
#endif
388

389 390 391
    addDPStaticEntry( menu, qtr( "Program Guide" ), "", SLOT( epgDialog() ),
        "" );

392
    addDPStaticEntry( menu, qtr( I_MENU_MSG ),
393
        ":/menu/messages", SLOT( messagesDialog() ),
394 395
        "Ctrl+M" );

396 397
    addDPStaticEntry( menu, qtr( "Plu&gins and extensions" ),
        "", SLOT( pluginDialog() ) );
Clément Stenac's avatar
Clément Stenac committed
398 399
    menu->addSeparator();

400
    addDPStaticEntry( menu, qtr( "&Preferences" ),
401
        ":/menu/preferences", SLOT( prefsDialog() ), "Ctrl+P" );
402

Clément Stenac's avatar
Clément Stenac committed
403 404 405
    return menu;
}

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
406 407 408 409 410
QMenu *QVLCMenu::ToolsMenu( QWidget *parent )
{
    return ToolsMenu( new QMenu( parent ) );
}

411 412 413 414 415 416 417 418 419 420 421 422 423
/**
 * 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;
}

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

433 434 435
    MainInterface *mi = _mi ? _mi : p_intf->p_sys->p_mi;
    assert( mi );

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

455 456 457 458
    menu->addAction(
#ifndef __APPLE__
            QIcon( ":/menu/playlist_menu" ),
#endif
459 460 461
            qtr( "Play&list" ), mi,
            SLOT( togglePlaylist() ), qtr( "Ctrl+L" ) );

462 463
    menu->addSeparator();

464 465
    QMenu *intfmenu = InterfacesMenu( p_intf, menu );
    menu->addSeparator();
466

467
    /* Minimal View */
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
468
    action = menu->addAction( qtr( "Mi&nimal View" ) );
469
    action->setShortcut( qtr( "Ctrl+H" ) );
470
    action->setCheckable( true );
471
    action->setChecked( (mi->getControlsVisibilityStatus() & CONTROLS_HIDDEN ) );
472

473 474
    CONNECT( action, triggered( bool ), mi, toggleMinimalView( bool ) );
    CONNECT( mi, minimalViewToggled( bool ), action, setChecked( bool ) );
475 476 477

    /* FullScreen View */
    action = menu->addAction( qtr( "&Fullscreen Interface" ), mi,
478
            SLOT( toggleInterfaceFullScreen() ), QString( "F11" ) );
479
    action->setCheckable( true );
480
    action->setChecked( mi->isInterfaceFullScreen() );
481 482
    CONNECT( mi, fullscreenInterfaceToggled( bool ),
             action, setChecked( bool ) );
483 484 485

    /* Advanced Controls */
    action = menu->addAction( qtr( "&Advanced Controls" ), mi,
486
            SLOT( toggleAdvancedButtons() ) );
487 488 489 490
    action->setCheckable( true );
    if( mi->getControlsVisibilityStatus() & CONTROLS_ADVANCED )
        action->setChecked( true );

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
491 492 493 494 495 496
    /* Docked Playlist */
    action = menu->addAction( qtr( "Docked Playlist" ) );
    action->setCheckable( true );
    action->setChecked( mi->isPlDocked() );
    CONNECT( action, triggered( bool ), mi, dockPlaylist( bool ) );

497 498 499 500
    action = menu->addAction( qtr( "Quit after Playback" ) );
    action->setCheckable( true );
    action->setChecked( THEMIM->getPlayExitState() );
    CONNECT( action, triggered( bool ), THEMIM, activatePlayQuit( bool ) );
501

502
#if 0 /* For Visualisations. Not yet working */
503 504 505 506
    adv = menu->addAction( qtr( "Visualizations selector" ),
            mi, SLOT( visual() ) );
    adv->setCheckable( true );
    if( visual_selector_enabled ) adv->setChecked( true );
507
#endif
508

509
    menu->addSeparator();
510
    addDPStaticEntry( menu, qtr( "Customi&ze Interface..." ),
511
        ":/menu/preferences", SLOT( toolbarDialog() ) );
512

513
    /* Extensions */
514
    ExtensionsMenu( p_intf, menu );
515

516 517 518
    return menu;
}

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

529
    return Populate( p_intf, current, varnames, objects );
530 531
}

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

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

546
    if( !extMgr->isLoaded() && !extMgr->cannotLoad() )
547
    {
548
        extMgr->loadExtensions();
549
    }
550

551
    /* Let the ExtensionsManager build itself the menu */
552
    extMenu->addSeparator();
553
    extMgr->menu( extMenu );
554 555
}

556 557
/**
 * Main Audio Menu
558
 **/
559 560
QMenu *QVLCMenu::AudioMenu( intf_thread_t *p_intf, QMenu * current )
{
561
    vector<vlc_object_t *> objects;
562
    vector<const char *> varnames;
563
    aout_instance_t *p_aout;
564 565 566
    input_thread_t *p_input;

    if( current->isEmpty() )
567
    {
568 569 570
        ACT_ADDMENU( current, "audio-es", qtr( "Audio &Track" ) );
        ACT_ADDMENU( current, "audio-channels", qtr( "Audio &Channels" ) );
        ACT_ADDMENU( current, "audio-device", qtr( "Audio &Device" ) );
571
        current->addSeparator();
572

573
        ACT_ADDMENU( current, "visual", qtr( "&Visualizations" ) );
574 575
        current->addSeparator();

576
        QAction *action = current->addAction( qtr( "Increase Volume" ),
577
                ActionsManager::getInstance( p_intf ), SLOT( AudioUp() ) );
578
        action->setData( STATIC_ENTRY );
579 580
        action = current->addAction( qtr( "Decrease Volume" ),
                ActionsManager::getInstance( p_intf ), SLOT( AudioDown() ) );
581
        action->setData( STATIC_ENTRY );
582 583
        action = current->addAction( qtr( "Mute" ),
                ActionsManager::getInstance( p_intf ), SLOT( toggleMuteAudio() ) );
584
        action->setData( STATIC_ENTRY );
585 586
    }

587
    p_input = THEMIM->getInput();
588
    p_aout = THEMIM->getAout();
589
    EnableStaticEntries( current, ( p_aout != NULL ) );
590
    AudioAutoMenuBuilder( p_aout, p_input, objects, varnames );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
591
    if( p_aout )
592
    {
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
593
        vlc_object_release( p_aout );
594
    }
595

596 597 598
    return Populate( p_intf, current, varnames, objects );
}

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
599 600 601 602 603
QMenu *QVLCMenu::AudioMenu( intf_thread_t *p_intf, QWidget *parent )
{
    return AudioMenu( p_intf, new QMenu( parent ) );
}

604 605 606 607
/**
 * Main Video Menu
 * Subtitles are part of Video.
 **/
608
QMenu *QVLCMenu::VideoMenu( intf_thread_t *p_intf, QMenu *current )
609
{
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
610
    vout_thread_t *p_vout;
611
    input_thread_t *p_input;
612
    vector<vlc_object_t *> objects;
613 614
    vector<const char *> varnames;

615
    if( current->isEmpty() )
616
    {
617
        ACT_ADDMENU( current, "video-es", qtr( "Video &Track" ) );
618 619 620 621 622

        QAction *action;
        QMenu *submenu = new QMenu( qtr( "&Subtitles Track" ), current );
        action = current->addMenu( submenu );
        action->setData( "spu-es" );
623
        addDPStaticEntry( submenu, qtr( "Open File..." ), "",
624
                          SLOT( loadSubtitlesFile() ) );
625
        submenu->addSeparator();
626
        current->addSeparator();
627

628 629
        ACT_ADDCHECK( current, "fullscreen", qtr( "&Fullscreen" ) );
        ACT_ADDCHECK( current, "video-on-top", qtr( "Always &On Top" ) );
630
        ACT_ADDCHECK( current, "video-wallpaper", qtr( "DirectX Wallpaper" ) );
631
#ifdef WIN32
632
        ACT_ADDCHECK( current, "direct3d-desktop", qtr( "Direct3D Desktop mode" ) );
633
#endif
634
        ACT_ADD( current, "video-snapshot", qtr( "Sna&pshot" ) );
635

636 637
        current->addSeparator();

638 639 640 641
        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" ) );
642 643
        ACT_ADDMENU( current, "deinterlace", qtr( "&Deinterlace" ) );
        ACT_ADDMENU( current, "deinterlace-mode", qtr( "&Deinterlace mode" ) );
644
        ACT_ADDMENU( current, "postprocess", qtr( "&Post processing" ) );
645
    }
646

647 648
    p_input = THEMIM->getInput();

649
    p_vout = THEMIM->getVout();
650
    VideoAutoMenuBuilder( p_vout, p_input, objects, varnames );
651

652 653
    if( p_vout )
        vlc_object_release( p_vout );
654

655
    return Populate( p_intf, current, varnames, objects );
656 657
}

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
658 659 660 661 662
QMenu *QVLCMenu::VideoMenu( intf_thread_t *p_intf, QWidget *parent )
{
    return VideoMenu( p_intf, new QMenu( parent ) );
}

663 664 665 666
/**
 * Navigation Menu
 * For DVD, MP4, MOV and other chapter based format
 **/
667
QMenu *QVLCMenu::NavigMenu( intf_thread_t *p_intf, QMenu *menu )
668
{
669
    QAction *action;
670

671 672 673 674 675 676
    QMenu *submenu = new QMenu( qtr( "&Bookmarks" ), menu );
    addDPStaticEntry( submenu, qtr( "Manage &bookmarks" ), "",
                      SLOT( bookmarksDialog() ) );
    submenu->addSeparator();
    action = menu->addMenu( submenu );
    action->setData( "bookmark" );
677

678 679 680 681
    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" ) );
682

683 684
    menu->addSeparator();
    PopupMenuPlaylistControlEntries( menu, p_intf );
685
    PopupMenuControlEntries( menu, p_intf );
686

687 688
    EnableStaticEntries( menu, ( THEMIM->getInput() != NULL ) );
    return RebuildNavigMenu( p_intf, menu );
689 690 691 692
}

QMenu *QVLCMenu::RebuildNavigMenu( intf_thread_t *p_intf, QMenu *menu )
{
693
    /* */
694 695 696 697
    input_thread_t *p_object;
    vector<vlc_object_t *> objects;
    vector<const char *> varnames;

698
    /* Get the input and hold it */
699
    p_object = THEMIM->getInput();
700

701
    InputAutoMenuBuilder( p_object, objects, varnames );
702

703 704
    menu->addSeparator();

705
    /* Title and so on */
706 707 708 709
    PUSH_VAR( "prev-title" );
    PUSH_VAR( "next-title" );
    PUSH_VAR( "prev-chapter" );
    PUSH_VAR( "next-chapter" );
710

711
    EnableStaticEntries( menu, (p_object != NULL ) );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
712
    return Populate( p_intf, menu, varnames, objects );
713
}
714

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
715 716 717 718 719
QMenu *QVLCMenu::NavigMenu( intf_thread_t *p_intf, QWidget *parent )
{
    return NavigMenu( p_intf, new QMenu( parent ) );
}

720
/**
721
 * Service Discovery SubMenu
722
 **/
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
723
QMenu *QVLCMenu::SDMenu( intf_thread_t *p_intf, QWidget *parent )
Clément Stenac's avatar
Clément Stenac committed
724
{
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
725
    QMenu *menu = new QMenu( parent );
726
    menu->setTitle( qtr( I_PL_SD ) );
727

728
    char **ppsz_longnames;
729
    char **ppsz_names = vlc_sd_GetNames( p_intf, &ppsz_longnames, NULL );
730 731 732
    if( !ppsz_names )
        return menu;

733 734
    char **ppsz_name = ppsz_names, **ppsz_longname = ppsz_longnames;
    for( ; *ppsz_name; ppsz_name++, ppsz_longname++ )
Clément Stenac's avatar
Clément Stenac committed
735
    {
736
        if( !strcmp( *ppsz_name, "podcast" ) )
737
        {
Christophe Mutricy's avatar
Christophe Mutricy committed
738
            QAction *b = new QAction( qtr( "Configure podcasts..." ), menu );
739 740 741 742
            //b->setEnabled( a->isChecked() );
            menu->addAction( b );
            CONNECT( b, triggered(), THEDP, podcastConfigureDialog() );
        }
743 744
        free( *ppsz_name );
        free( *ppsz_longname );
Clément Stenac's avatar
Clément Stenac committed
745
    }
746 747
    free( ppsz_names );
    free( ppsz_longnames );
Clément Stenac's avatar
Clément Stenac committed
748 749
    return menu;
}
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
750