menus.cpp 45.8 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

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

43 44 45 46 47 48
#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
49

50 51 52 53 54 55
#include <QMenu>
#include <QMenuBar>
#include <QAction>
#include <QActionGroup>
#include <QSignalMapper>
#include <QSystemTrayIcon>
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
56
#include <QStatusBar>
57

58 59 60 61
/*
  This file defines the main menus and the pop-up menu (right-click menu)
  and the systray menu (in that order in the file)

62 63 64
  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
65 66 67 68 69 70 71
  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.
  */

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

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

static QActionGroup *currentGroup;

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

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

119 120 121
/**
 * @brief Add static entries to MIM in menus
 **/
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
 * @brief Enable all static entries of a menu, disable the others
 * @param menu the menu in which the entries will be disabled
148
 * @param enable if false, disable all entries
149
 **/
150
void EnableStaticEntries( QMenu *menu, bool enable = true )
151
{
152
    if( !menu ) return;
153

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

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

171
    int i_ret = 0;
172

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

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

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

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

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

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

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

245 246 247
    return VLC_SUCCESS;
}

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

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

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

271
// Dynamic menu
272
#define BAR_DADD( func, title, id ) { \
273 274 275 276 277
    QMenu *_menu = func; _menu->setTitle( title ); bar->addMenu( _menu ); \
    MenuFunc *f = new MenuFunc( _menu, id ); \
    CONNECT( _menu, aboutToShow(), THEDP->menusUpdateMapper, map() ); \
    THEDP->menusUpdateMapper->setMapping( _menu, f ); }

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

285
// Add an action with a submenu
286 287 288 289 290 291
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 );
}
292

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

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

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

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

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

    /* View menu, a bit different */
    BAR_DADD( ViewMenu( p_intf, _menu, mi ), qtr( "V&iew" ), 4 );

324
    addMenuToMainbar( HelpMenu( bar ), qtr( "&Help" ), bar );
325

326
}
327 328

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

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

348
    menu->addSeparator();
349 350 351 352 353

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

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

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

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

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

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

382
    addDPStaticEntry( menu, qtr( "&Quit" ) ,
383
        ":/menu/quit", SLOT( quit() ), "Ctrl+Q" );
384 385 386
    return menu;
}

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

395
    addDPStaticEntry( menu, qtr( "&Track Synchronization"), ":/menu/settings",
396 397
            SLOT( synchroDialog() ), "" );

398
    addDPStaticEntry( menu, qtr( I_MENU_INFO ) , ":/menu/info",
399
        SLOT( mediaInfoDialog() ), "Ctrl+I" );
400
    addDPStaticEntry( menu, qtr( I_MENU_CODECINFO ) ,
401
        ":/menu/info", SLOT( mediaCodecDialog() ), "Ctrl+J" );
402

403
#ifdef ENABLE_VLM
404
    addDPStaticEntry( menu, qtr( I_MENU_VLM ), "", SLOT( vlmDialog() ),
405 406
        "Ctrl+W" );
#endif
407

408 409 410
    addDPStaticEntry( menu, qtr( "Program Guide" ), "", SLOT( epgDialog() ),
        "" );

411
    addDPStaticEntry( menu, qtr( I_MENU_MSG ),
412
        ":/menu/messages", SLOT( messagesDialog() ), "Ctrl+M" );
413

414 415
    addDPStaticEntry( menu, qtr( "Plu&gins and extensions" ),
        "", SLOT( pluginDialog() ) );
Clément Stenac's avatar
Clément Stenac committed
416 417
    menu->addSeparator();

418 419 420
    addDPStaticEntry( menu, qtr( "Customi&ze Interface..." ),
        ":/menu/preferences", SLOT( toolbarDialog() ) );

421
    addDPStaticEntry( menu, qtr( "&Preferences" ),
422
        ":/menu/preferences", SLOT( prefsDialog() ), "Ctrl+P", QAction::PreferencesRole );
423

Clément Stenac's avatar
Clément Stenac committed
424 425 426
    return menu;
}

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

436 437 438
    MainInterface *mi = _mi ? _mi : p_intf->p_sys->p_mi;
    assert( mi );

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

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

465 466
    menu->addSeparator();

467
    /* Minimal View */
468
    action = menu->addAction( qtr( "Mi&nimal Interface" ) );
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 ) );

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

508
    menu->addSeparator();
509 510 511 512

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

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
        addActionWithSubmenu( current, "audio-es", qtr( "Audio &Track" ) );
        addActionWithSubmenu( current, "audio-channels", qtr( "Audio &Channels" ) );
        addActionWithSubmenu( current, "audio-device", qtr( "Audio &Device" ) );
571
        current->addSeparator();
572

573
        addActionWithSubmenu( 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 );
}

599
/* Subtitles */
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
600
QMenu *QVLCMenu::SubtitleMenu( intf_thread_t *p_intf, QMenu *current )
601 602 603 604 605 606 607 608
{
    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();
609
    return submenu;
610 611
}

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

623
    if( current->isEmpty() )
624
    {
625
        addActionWithSubmenu( current, "video-es", qtr( "Video &Track" ) );
626
        if( b_subtitle)
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
627
            SubtitleMenu( p_intf, current );
628

629
        current->addSeparator();
630

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

643 644 645 646 647 648
        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" ) );
649
    }
650

651 652
    p_input = THEMIM->getInput();

653
    p_vout = THEMIM->getVout();
654
    VideoAutoMenuBuilder( p_vout, p_input, objects, varnames );
655

656 657
    if( p_vout )
        vlc_object_release( p_vout );
658

659
    return Populate( p_intf, current, varnames, objects );
660 661
}

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

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

675 676 677 678 679 680 681 682
    /* 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" );

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

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

733
/*****************************************************************************
734
 * Popup menus - Right Click menus                                           *
735
 *****************************************************************************/
736
#define POPUP_BOILERPLATE \