menus.cpp 44.3 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
 */

30 31 32 33
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

34
#include <vlc_intf_strings.h>
35
#include <vlc_services_discovery.h>
36
#include <vlc_aout.h>
37

Clément Stenac's avatar
Clément Stenac committed
38
#include "menus.hpp"
39 40

#include "main_interface.hpp"    /* View modifications */
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
41 42 43
#include "dialogs_provider.hpp"  /* Dialogs display */
#include "input_manager.hpp"     /* Input Management */
#include "recents.hpp"           /* Recent Items */
44
#include "actions_manager.hpp"
Clément Stenac's avatar
Clément Stenac committed
45

46 47 48 49 50 51
#include <QMenu>
#include <QMenuBar>
#include <QAction>
#include <QActionGroup>
#include <QSignalMapper>
#include <QSystemTrayIcon>
Ludovic Fauvet's avatar
Ludovic Fauvet committed
52
#include <QList>
53

54 55 56 57 58 59 60 61 62 63 64 65 66 67
/*
  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.
  */

68 69 70
#define STATIC_ENTRY "__static__"
#define ENTRY_ALWAYS_ENABLED "__ignore__"

71 72 73 74 75 76 77 78 79
enum
{
    ITEM_NORMAL,
    ITEM_CHECK,
    ITEM_RADIO
};

static QActionGroup *currentGroup;

Ludovic Fauvet's avatar
Ludovic Fauvet committed
80 81
QMenu *QVLCMenu::recentsMenu = NULL;

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

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

136 137 138 139 140
/**
 * @brief Enable all static entries, disable the others
 * @param enable if false, disable all entries
 */
void EnableStaticEntries( QMenu *menu, bool enable = true )
141
{
142
    if( !menu ) return;
143

Jean-Philippe Andre's avatar
Jean-Philippe Andre committed
144 145
    QList< QAction* > actions = menu->actions();
    for( int i = 0; i < actions.size(); ++i )
146
    {
147 148 149 150
        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 ) ) );
151 152 153
    }
}

154 155 156 157 158
/**
 * \return Number of static entries
 */
int DeleteNonStaticEntries( QMenu *menu )
{
159 160
    if( !menu ) return VLC_EGENERIC;

161
    int i_ret = 0;
162

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

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

188
/*****************************************************************************
189
 * Definitions of variables for the dynamic menus
190
 *****************************************************************************/
191
#define PUSH_VAR( var ) varnames.push_back( var ); \
192
    objects.push_back( VLC_OBJECT(p_object) )
193 194

#define PUSH_INPUTVAR( var ) varnames.push_back( var ); \
195
    objects.push_back( VLC_OBJECT(p_input) );
196 197

#define PUSH_SEPARATOR if( objects.size() != i_last_separator ) { \
198
    objects.push_back( 0 ); varnames.push_back( "" ); \
199
    i_last_separator = objects.size(); }
200

201
static int InputAutoMenuBuilder( input_thread_t *p_object,
202
        vector<vlc_object_t *> &objects,
203
        vector<const char *> &varnames )
204
{
205
    PUSH_VAR( "bookmark" );
206
    PUSH_VAR( "title" );
207
    PUSH_VAR( "chapter" );
208
    PUSH_VAR( "navigation" );
209
    PUSH_VAR( "program" );
210 211 212
    return VLC_SUCCESS;
}

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

234 235 236
    return VLC_SUCCESS;
}

237
static int AudioAutoMenuBuilder( aout_instance_t *p_object,
238
        input_thread_t *p_input,
239
        vector<vlc_object_t *> &objects,
240
        vector<const char *> &varnames )
241
{
242
    PUSH_INPUTVAR( "audio-es" );
243
    PUSH_VAR( "audio-channels" );
244 245
    PUSH_VAR( "audio-device" );
    PUSH_VAR( "visual" );
246 247 248
    return VLC_SUCCESS;
}

249 250
/*****************************************************************************
 * All normal menus
251
 * Simple Code
252 253 254
 *****************************************************************************/

#define BAR_ADD( func, title ) { \
255
    QMenu *_menu = func; _menu->setTitle( title ); bar->addMenu( _menu ); }
256 257

#define BAR_DADD( func, title, id ) { \
258 259 260 261 262 263 264 265
    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 ); }
266

267 268
#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
269
    _action->setMenu( new QMenu( _menu ) ); _menu->addAction( _action ); }
270 271 272 273 274

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

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

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

288
    /* Dynamic menus, rebuilt before being showed */
289
    BAR_DADD( NavigMenu( p_intf, bar ), qtr( "P&layback" ), 3 );
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
290 291
    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
292

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
293
    BAR_ADD( ToolsMenu( bar ), qtr( "&Tools" ) );
294
    BAR_ADD( ViewMenu( p_intf, mi ), qtr( "V&iew" ) );
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
295
    BAR_ADD( HelpMenu( bar ), qtr( "&Help" ) );
296
}
297 298
#undef BAR_ADD
#undef BAR_DADD
299 300

/**
301
 * Media ( File ) Menu
302 303
 * Opening, streaming and quit
 **/
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
304
QMenu *QVLCMenu::FileMenu( intf_thread_t *p_intf, QWidget *parent )
305
{
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
306
    QMenu *menu = new QMenu( parent );
307

308
    addDPStaticEntry( menu, qtr( "&Open File..." ),
309
        ":/type/file-asym", SLOT( simpleOpenDialog() ), "Ctrl+O" );
310
    addDPStaticEntry( menu, qtr( "Advanced Open File..." ),
311
        ":/type/file-asym", SLOT( openFileDialog() ), "Ctrl+Shift+O" );
312
    addDPStaticEntry( menu, qtr( I_OPEN_FOLDER ),
313
        ":/type/folder-grey", SLOT( PLOpenDir() ), "Ctrl+F" );
314
    addDPStaticEntry( menu, qtr( "Open &Disc..." ),
315
        ":/type/disc", SLOT( openDiscDialog() ), "Ctrl+D" );
316
    addDPStaticEntry( menu, qtr( "Open &Network Stream..." ),
317
        ":/type/network", SLOT( openNetDialog() ), "Ctrl+N" );
318
    addDPStaticEntry( menu, qtr( "Open &Capture Device..." ),
319
        ":/type/capture-card", SLOT( openCaptureDialog() ),
320
        "Ctrl+C" );
321

322
    menu->addSeparator();
323
    addDPStaticEntry( menu, qtr( "Open &Location from clipboard" ),
324
                      NULL, SLOT( openUrlDialog() ), "Ctrl+V" );
325

326 327 328 329 330 331
    if( config_GetInt( p_intf, "qt-recentplay" ) )
    {
        recentsMenu = new QMenu( qtr( "&Recent Media" ), menu );
        updateRecents( p_intf );
        menu->addMenu( recentsMenu );
    }
332 333
    menu->addMenu( SDMenu( p_intf, menu ) );
    menu->addSeparator();
334

335 336 337 338
    addDPStaticEntry( menu, qtr( I_PL_SAVE ), "", SLOT( saveAPlaylist() ),
        "Ctrl+Y" );
    menu->addSeparator();

339
#ifdef ENABLE_SOUT
340
    addDPStaticEntry( menu, qtr( "Conve&rt / Save..." ), "",
341
        SLOT( openAndTranscodingDialogs() ), "Ctrl+R" );
342
    addDPStaticEntry( menu, qtr( "&Streaming..." ),
343
        ":/menu/stream", SLOT( openAndStreamingDialogs() ),
344
        "Ctrl+S" );
345
    menu->addSeparator();
346
#endif
347

348
    addDPStaticEntry( menu, qtr( "&Quit" ) ,
349
        ":/menu/quit", SLOT( quit() ), "Ctrl+Q" );
350 351 352
    return menu;
}

353
/**
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
354
 * Tools, like Media Information, Preferences or Messages
355
 **/
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
356
QMenu *QVLCMenu::ToolsMenu( QMenu *menu )
Clément Stenac's avatar
Clément Stenac committed
357
{
358
    addDPStaticEntry( menu, qtr( "&Effects and Filters"), ":/menu/settings",
359
            SLOT( extendedDialog() ), "Ctrl+E" );
360

361
    addDPStaticEntry( menu, qtr( "&Track Synchronization"), ":/menu/settings",
362 363
            SLOT( synchroDialog() ), "" );

364
    addDPStaticEntry( menu, qtr( I_MENU_INFO ) , ":/menu/info",
365
        SLOT( mediaInfoDialog() ), "Ctrl+I" );
366
    addDPStaticEntry( menu, qtr( I_MENU_CODECINFO ) ,
367
        ":/menu/info", SLOT( mediaCodecDialog() ), "Ctrl+J" );
368

369
    addDPStaticEntry( menu, qtr( I_MENU_BOOKMARK ),"",
370 371
                      SLOT( bookmarksDialog() ), "Ctrl+B" );
#ifdef ENABLE_VLM
372
    addDPStaticEntry( menu, qtr( I_MENU_VLM ), "", SLOT( vlmDialog() ),
373 374
        "Ctrl+W" );
#endif
375 376

    addDPStaticEntry( menu, qtr( I_MENU_MSG ),
377
        ":/menu/messages", SLOT( messagesDialog() ),
378 379
        "Ctrl+M" );

380 381
    addDPStaticEntry( menu, qtr( "Plu&gins and extensions" ),
        "", SLOT( pluginDialog() ) );
Clément Stenac's avatar
Clément Stenac committed
382 383
    menu->addSeparator();

384
    addDPStaticEntry( menu, qtr( "&Preferences" ),
385
        ":/menu/preferences", SLOT( prefsDialog() ), "Ctrl+P" );
386

Clément Stenac's avatar
Clément Stenac committed
387 388 389
    return menu;
}

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
390 391 392 393 394
QMenu *QVLCMenu::ToolsMenu( QWidget *parent )
{
    return ToolsMenu( new QMenu( parent ) );
}

395
/**
396
 * View Menu
397
 * Interface Modification
398
 **/
399
QMenu *QVLCMenu::ViewMenu( intf_thread_t *p_intf,
400 401
                            MainInterface *mi,
                            bool with_intf )
402
{
403 404 405 406
    assert( mi );

    QMenu *menu = new QMenu( qtr( "V&iew" ), mi );

407
    QAction *act = menu->addAction( QIcon( ":/menu/playlist_menu" ),
408 409 410
            qtr( "Play&list" ), mi,
            SLOT( togglePlaylist() ), qtr( "Ctrl+L" ) );

411 412 413 414
    /*menu->addSeparator();
    menu->addAction( qtr( "Undock from Interface" ), mi,
                     SLOT( undockPlaylist() ), qtr( "Ctrl+U" ) );*/

415 416
    menu->addSeparator();

417 418
    if( with_intf )
    {
419
        QMenu *intfmenu = InterfacesMenu( p_intf, menu );
420 421 422
        MenuFunc *f = new MenuFunc( intfmenu, 4 );
        CONNECT( intfmenu, aboutToShow(), THEDP->menusUpdateMapper, map() );
        THEDP->menusUpdateMapper->setMapping( intfmenu, f );
423 424
        menu->addSeparator();
    }
425

426
    /* Minimal View */
427 428
    QAction *action = menu->addAction( qtr( "Mi&nimal View" ) );
    action->setShortcut( qtr( "Ctrl+H" ) );
429
    action->setCheckable( true );
430
    action->setChecked( !with_intf &&
431
            (mi->getControlsVisibilityStatus() & CONTROLS_HIDDEN ) );
432

433 434
    CONNECT( action, triggered( bool ), mi, toggleMinimalView( bool ) );
    CONNECT( mi, minimalViewToggled( bool ), action, setChecked( bool ) );
435 436 437 438 439

    /* FullScreen View */
    action = menu->addAction( qtr( "&Fullscreen Interface" ), mi,
            SLOT( toggleFullScreen() ), QString( "F11" ) );
    action->setCheckable( true );
440 441 442
    action->setChecked( mi->isFullScreen() );
    CONNECT( mi, fullscreenInterfaceToggled( bool ),
             action, setChecked( bool ) );
443 444 445 446 447 448 449 450

    /* Advanced Controls */
    action = menu->addAction( qtr( "&Advanced Controls" ), mi,
            SLOT( toggleAdvanced() ) );
    action->setCheckable( true );
    if( mi->getControlsVisibilityStatus() & CONTROLS_ADVANCED )
        action->setChecked( true );

451 452 453 454 455 456 457 458
    if( with_intf )
    // I don't want to manage consistency between menus, so no popup-menu
    {
        action = menu->addAction( qtr( "Quit after Playback" ) );
        action->setCheckable( true );
        CONNECT( action, triggered( bool ), THEMIM, activatePlayQuit( bool ) );
    }

459
#if 0 /* For Visualisations. Not yet working */
460 461 462 463
    adv = menu->addAction( qtr( "Visualizations selector" ),
            mi, SLOT( visual() ) );
    adv->setCheckable( true );
    if( visual_selector_enabled ) adv->setChecked( true );
464
#endif
465

466
    menu->addSeparator();
467
    addDPStaticEntry( menu, qtr( "Customi&ze Interface..." ),
468
        ":/menu/preferences", SLOT( toolbarDialog() ) );
469
    menu->addSeparator();
470

471 472 473
    return menu;
}

474 475 476
/**
 * Interface Sub-Menu, to list extras interface and skins
 **/
477 478
QMenu *QVLCMenu::InterfacesMenu( intf_thread_t *p_intf, QMenu *current )
{
479
    vector<vlc_object_t *> objects;
480 481
    vector<const char *> varnames;
    varnames.push_back( "intf-add" );
482
    objects.push_back( VLC_OBJECT(p_intf) );
Clément Stenac's avatar
Qt4:  
Clément Stenac committed
483

484
    return Populate( p_intf, current, varnames, objects );
485 486
}

487 488
/**
 * Main Audio Menu
489
 **/
490 491
QMenu *QVLCMenu::AudioMenu( intf_thread_t *p_intf, QMenu * current )
{
492
    vector<vlc_object_t *> objects;
493
    vector<const char *> varnames;
494
    aout_instance_t *p_aout;
495 496 497
    input_thread_t *p_input;

    if( current->isEmpty() )
498
    {
499 500 501
        ACT_ADDMENU( current, "audio-es", qtr( "Audio &Track" ) );
        ACT_ADDMENU( current, "audio-channels", qtr( "Audio &Channels" ) );
        ACT_ADDMENU( current, "audio-device", qtr( "Audio &Device" ) );
502
        current->addSeparator();
503

504
        ACT_ADDMENU( current, "visual", qtr( "&Visualizations" ) );
505 506
        current->addSeparator();

507
        QAction *action = current->addAction( qtr( "Increase Volume" ),
508
                ActionsManager::getInstance( p_intf ), SLOT( AudioUp() ) );
509
        action->setData( STATIC_ENTRY );
510 511
        action = current->addAction( qtr( "Decrease Volume" ),
                ActionsManager::getInstance( p_intf ), SLOT( AudioDown() ) );
512
        action->setData( STATIC_ENTRY );
513 514
        action = current->addAction( qtr( "Mute" ),
                ActionsManager::getInstance( p_intf ), SLOT( toggleMuteAudio() ) );
515
        action->setData( STATIC_ENTRY );
516 517
    }

518
    p_input = THEMIM->getInput();
519
    p_aout = THEMIM->getAout();
520
    EnableStaticEntries( current, ( p_aout != NULL ) );
521
    AudioAutoMenuBuilder( p_aout, p_input, objects, varnames );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
522
    if( p_aout )
523
    {
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
524
        vlc_object_release( p_aout );
525
    }
526

527 528 529
    return Populate( p_intf, current, varnames, objects );
}

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
530 531 532 533 534
QMenu *QVLCMenu::AudioMenu( intf_thread_t *p_intf, QWidget *parent )
{
    return AudioMenu( p_intf, new QMenu( parent ) );
}

535 536 537 538
/**
 * Main Video Menu
 * Subtitles are part of Video.
 **/
539
QMenu *QVLCMenu::VideoMenu( intf_thread_t *p_intf, QMenu *current )
540
{
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
541
    vout_thread_t *p_vout;
542
    input_thread_t *p_input;
543
    vector<vlc_object_t *> objects;
544 545
    vector<const char *> varnames;

546
    if( current->isEmpty() )
547
    {
548
        ACT_ADDMENU( current, "video-es", qtr( "Video &Track" ) );
549 550 551 552 553

        QAction *action;
        QMenu *submenu = new QMenu( qtr( "&Subtitles Track" ), current );
        action = current->addMenu( submenu );
        action->setData( "spu-es" );
554
        addDPStaticEntry( submenu, qtr( "Open File..." ), "",
555
                          SLOT( loadSubtitlesFile() ) );
556
        submenu->addSeparator();
557
        current->addSeparator();
558

559 560
        ACT_ADDCHECK( current, "fullscreen", qtr( "&Fullscreen" ) );
        ACT_ADDCHECK( current, "video-on-top", qtr( "Always &On Top" ) );
561
#ifdef WIN32
562
        ACT_ADDCHECK( current, "directx-wallpaper", qtr( "DirectX Wallpaper" ) );
563
        ACT_ADDCHECK( current, "direct3d-desktop", qtr( "Direct3D Desktop mode" ) );
564
#endif
565
        ACT_ADD( current, "video-snapshot", qtr( "Sna&pshot" ) );
566

567 568
        current->addSeparator();

569 570 571 572 573
        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" ) );
        ACT_ADDMENU( current, "deinterlace", qtr( "&Deinterlace" ) );
574
        ACT_ADDMENU( current, "postprocess", qtr( "&Post processing" ) );
575
    }
576

577 578
    p_input = THEMIM->getInput();

579
    p_vout = THEMIM->getVout();
580
    VideoAutoMenuBuilder( p_vout, p_input, objects, varnames );
581

582 583
    if( p_vout )
        vlc_object_release( p_vout );
584

585
    return Populate( p_intf, current, varnames, objects );
586 587
}

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
588 589 590 591 592
QMenu *QVLCMenu::VideoMenu( intf_thread_t *p_intf, QWidget *parent )
{
    return VideoMenu( p_intf, new QMenu( parent ) );
}

593 594 595 596
/**
 * Navigation Menu
 * For DVD, MP4, MOV and other chapter based format
 **/
597
QMenu *QVLCMenu::NavigMenu( intf_thread_t *p_intf, QMenu *menu )
598
{
599
    QAction *action;
600

601 602 603 604 605 606
    QMenu *submenu = new QMenu( qtr( "&Bookmarks" ), menu );
    addDPStaticEntry( submenu, qtr( "Manage &bookmarks" ), "",
                      SLOT( bookmarksDialog() ) );
    submenu->addSeparator();
    action = menu->addMenu( submenu );
    action->setData( "bookmark" );
607

608 609 610 611
    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" ) );
612

613 614
    menu->addSeparator();
    PopupMenuPlaylistControlEntries( menu, p_intf );
615
    PopupMenuControlEntries( menu, p_intf );
616

617 618
    EnableStaticEntries( menu, ( THEMIM->getInput() != NULL ) );
    return RebuildNavigMenu( p_intf, menu );
619 620 621 622
}

QMenu *QVLCMenu::RebuildNavigMenu( intf_thread_t *p_intf, QMenu *menu )
{
623
    /* */
624 625 626 627
    input_thread_t *p_object;
    vector<vlc_object_t *> objects;
    vector<const char *> varnames;

628
    /* Get the input and hold it */
629
    p_object = THEMIM->getInput();
630

631
    InputAutoMenuBuilder( p_object, objects, varnames );
632

633 634
    menu->addSeparator();

635
    /* Title and so on */
636 637 638 639
    PUSH_VAR( "prev-title" );
    PUSH_VAR( "next-title" );
    PUSH_VAR( "prev-chapter" );
    PUSH_VAR( "next-chapter" );
640

641
    EnableStaticEntries( menu, (p_object != NULL ) );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
642
    return Populate( p_intf, menu, varnames, objects );
643
}
644

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
645 646 647 648 649
QMenu *QVLCMenu::NavigMenu( intf_thread_t *p_intf, QWidget *parent )
{
    return NavigMenu( p_intf, new QMenu( parent ) );
}

650
/**
651
 * Service Discovery SubMenu
652
 **/
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
653
QMenu *QVLCMenu::SDMenu( intf_thread_t *p_intf, QWidget *parent )
Clément Stenac's avatar
Clément Stenac committed
654
{
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
655
    QMenu *menu = new QMenu( parent );
656
    menu->setTitle( qtr( I_PL_SD ) );
657

658
    char **ppsz_longnames;
659
    char **ppsz_names = vlc_sd_GetNames( &ppsz_longnames );
660 661 662
    if( !ppsz_names )
        return menu;

663 664
    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
665
    {
666
        QAction *a = new QAction( qfu( *ppsz_longname ), menu );
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
667
        a->setCheckable( true );
668
        if( playlist_IsServicesDiscoveryLoaded( THEPL, *ppsz_name ) )
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
669
            a->setChecked( true );
670
        CONNECT( a, triggered(), THEDP->SDMapper, map() );
671
        THEDP->SDMapper->setMapping( a, QString( *ppsz_name ) );
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
672
        menu->addAction( a );
673

674
        /* Special case for podcast */
675
        if( !strcmp( *ppsz_name, "podcast" ) )
676
        {
Christophe Mutricy's avatar
Christophe Mutricy committed
677
            QAction *b = new QAction( qtr( "Configure podcasts..." ), menu );
678 679 680 681
            //b->setEnabled( a->isChecked() );
            menu->addAction( b );
            CONNECT( b, triggered(), THEDP, podcastConfigureDialog() );
        }
682 683
        free( *ppsz_name );
        free( *ppsz_longname );
Clément Stenac's avatar
Clément Stenac committed
684
    }
685 686
    free( ppsz_names );
    free( ppsz_longnames );
Clément Stenac's avatar
Clément Stenac committed
687 688
    return menu;
}
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
689

690 691 692
/**
 * Help/About Menu
**/
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
693
QMenu *QVLCMenu::HelpMenu( QWidget *parent )
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
694
{
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
695
    QMenu *menu = new QMenu( parent );
696
    addDPStaticEntry( menu, qtr( "&Help..." ) ,
697
        ":/menu/help", SLOT( helpDialog() ), "F1" );
698
#ifdef UPDATE_CHECK
699 700
    addDPStaticEntry( menu, qtr( "Check for &Updates..." ) , "",
                      SLOT( updateDialog() ) );
701
#endif
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
702
    menu->addSeparator();
703
    addDPStaticEntry( menu, qtr( I_MENU_ABOUT ), ":/menu/info",
704
            SLOT( aboutDialog() ), "Shift+F1" );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
705 706 707
    return menu;
}

708
/*****************************************************************************
709
 * Popup menus - Right Click menus                                           *
710
 *****************************************************************************/
711 712
#define POPUP_BOILERPLATE \
    unsigned int i_last_separator = 0; \
713
    vector<vlc_object_t *> objects; \
714 715 716 717 718 719 720
    vector<const char *> varnames; \
    input_thread_t *p_input = THEMIM->getInput();

#define CREATE_POPUP \
    Populate( p_intf, menu, varnames, objects ); \
    p_intf->p_sys->p_popup_menu = menu; \
    menu->popup( QCursor::pos() ); \
721
    p_intf->p_sys->p_popup_menu = NULL; \
722
    i_last_separator = 0;
723

724
void QVLCMenu::PopupPlayEntries( QMenu *menu,
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
725 726 727
                                        intf_thread_t *p_intf,
                                        input_thread_t *p_input )
{
728 729 730
    QAction