menus.cpp 46 KB
Newer Older
1 2 3
/*****************************************************************************
 * menus.cpp : Qt menus
 *****************************************************************************
4
 * Copyright © 2006-2011 the VideoLAN team
5
 * $Id$
6
 *
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
7
 * Authors: Clément Stenac <zorglub@videolan.org>
8
 *          Jean-Baptiste Kempf <jb@videolan.org>
9
 *          Jean-Philippe André <jpeg@videolan.org>
10 11 12 13
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
14
 * ( at your option ) any later version.
15 16 17 18 19 20 21 22 23 24 25
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

26 27 28 29
/** \todo
 * - Remove static currentGroup
 */

Rémi Duraffort's avatar
Rémi Duraffort committed
30 31 32
#define __STDC_FORMAT_MACROS 1
#define __STDC_CONSTANT_MACROS 1

33 34 35 36
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

37
#include <vlc_intf_strings.h>
38
#include <vlc_services_discovery.h> /*vlc_sd_GetNames*/
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 45 46 47 48 49
#include "main_interface.hpp"      /* View modifications */
#include "dialogs_provider.hpp"    /* Dialogs display */
#include "input_manager.hpp"       /* Input Management */
#include "recents.hpp"             /* Recent Items */
#include "actions_manager.hpp"     /* Actions Management: play+volume */
#include "extensions_manager.hpp"  /* Extensions menu*/
Clément Stenac's avatar
Clément Stenac committed
50

51 52 53 54 55 56 57
#include <QMenu>
#include <QMenuBar>
#include <QAction>
#include <QActionGroup>
#include <QSignalMapper>
#include <QSystemTrayIcon>

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
void 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
}
117

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

144
/**
145 146
 * @brief Enable all static entries of a menu, disable the others
 * @param menu the menu in which the entries will be disabled
147
 * @param enable if false, disable all entries
148
 **/
149
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
/**
 * \return Number of static entries
165
 **/
166
inline int DeleteNonStaticEntries( QMenu *menu )
167
{
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
// Static menu
265 266 267 268
static inline void addMenuToMainbar( QMenu *func, QString title, QMenuBar *bar ) {
    func->setTitle( title );
    bar->addMenu( func);
}
269

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

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

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

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

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

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

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

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

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

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

325
}
326 327

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

335
    addDPStaticEntry( menu, qtr( "&Open File..." ),
336
        ":/type/file-asym", SLOT( simpleOpenDialog() ), "Ctrl+O" );
337
    addDPStaticEntry( menu, qtr( "Advanced Open File..." ),
338
        ":/type/file-asym", SLOT( openFileDialog() ), "Ctrl+Shift+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
    addDPStaticEntry( menu, qtr( "Open &Location from clipboard" ),
350
                      NULL, SLOT( openUrlDialog() ), "Ctrl+V" );
351

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

360 361 362 363
    addDPStaticEntry( menu, qtr( I_PL_SAVE ), "", SLOT( saveAPlaylist() ),
        "Ctrl+Y" );
    menu->addSeparator();

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

372
    addDPStaticEntry( menu, qtr( "&Quit" ) ,
373
        ":/menu/quit", SLOT( quit() ), "Ctrl+Q" );
374 375 376
    return menu;
}

377
/**
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
378
 * Tools, like Media Information, Preferences or Messages
379
 **/
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
380
QMenu *QVLCMenu::ToolsMenu( QMenu *menu )
Clément Stenac's avatar
Clément Stenac committed
381
{
382
    addDPStaticEntry( menu, qtr( "&Effects and Filters"), ":/menu/settings",
383
            SLOT( extendedDialog() ), "Ctrl+E" );
384

385
    addDPStaticEntry( menu, qtr( "&Track Synchronization"), ":/menu/settings",
386 387
            SLOT( synchroDialog() ), "" );

388
    addDPStaticEntry( menu, qtr( I_MENU_INFO ) , ":/menu/info",
389
        SLOT( mediaInfoDialog() ), "Ctrl+I" );
390
    addDPStaticEntry( menu, qtr( I_MENU_CODECINFO ) ,
391
        ":/menu/info", SLOT( mediaCodecDialog() ), "Ctrl+J" );
392

393
#ifdef ENABLE_VLM
394
    addDPStaticEntry( menu, qtr( I_MENU_VLM ), "", SLOT( vlmDialog() ),
395 396
        "Ctrl+W" );
#endif
397

398 399 400
    addDPStaticEntry( menu, qtr( "Program Guide" ), "", SLOT( epgDialog() ),
        "" );

401
    addDPStaticEntry( menu, qtr( I_MENU_MSG ),
402
        ":/menu/messages", SLOT( messagesDialog() ), "Ctrl+M" );
403

404 405
    addDPStaticEntry( menu, qtr( "Plu&gins and extensions" ),
        "", SLOT( pluginDialog() ) );
Clément Stenac's avatar
Clément Stenac committed
406 407
    menu->addSeparator();

408 409 410
    addDPStaticEntry( menu, qtr( "Customi&ze Interface..." ),
        ":/menu/preferences", SLOT( toolbarDialog() ) );

411
    addDPStaticEntry( menu, qtr( "&Preferences" ),
412
        ":/menu/preferences", SLOT( prefsDialog() ), "Ctrl+P", QAction::PreferencesRole );
413

Clément Stenac's avatar
Clément Stenac committed
414 415 416
    return menu;
}

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

426 427 428
    MainInterface *mi = _mi ? _mi : p_intf->p_sys->p_mi;
    assert( mi );

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

448 449 450 451
    menu->addAction(
#ifndef __APPLE__
            QIcon( ":/menu/playlist_menu" ),
#endif
452 453 454
            qtr( "Play&list" ), mi,
            SLOT( togglePlaylist() ), qtr( "Ctrl+L" ) );

455 456
    menu->addSeparator();

457
    InterfacesMenu( p_intf, menu );
458
    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
    adv = menu->addAction( qtr( "Visualizations selector" ), mi,
                           SLOT( visual() ) );
498 499
    adv->setCheckable( true );
    if( visual_selector_enabled ) adv->setChecked( true );
500
#endif
501

502
    menu->addSeparator();
503
    /* Extensions */
504
    ExtensionsMenu( p_intf, menu );
505

506 507 508
    return menu;
}

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

519
    return Populate( p_intf, current, varnames, objects );
520 521
}

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

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

536
    if( !extMgr->isLoaded() && !extMgr->cannotLoad() )
537
    {
538
        extMgr->loadExtensions();
539
    }
540

541
    /* Let the ExtensionsManager build itself the menu */
542
    extMenu->addSeparator();
543
    extMgr->menu( extMenu );
544 545
}

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

    if( current->isEmpty() )
557
    {
558 559 560
        addActionWithSubmenu( current, "audio-es", qtr( "Audio &Track" ) );
        addActionWithSubmenu( current, "audio-channels", qtr( "Audio &Channels" ) );
        addActionWithSubmenu( current, "audio-device", qtr( "Audio &Device" ) );
561
        current->addSeparator();
562

563
        addActionWithSubmenu( current, "visual", qtr( "&Visualizations" ) );
564 565
        current->addSeparator();

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

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

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

589 590 591 592
/**
 * Main Video Menu
 * Subtitles are part of Video.
 **/
593
QMenu *QVLCMenu::VideoMenu( intf_thread_t *p_intf, QMenu *current )
594
{
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
595
    vout_thread_t *p_vout;
596
    input_thread_t *p_input;
597
    vector<vlc_object_t *> objects;
598 599
    vector<const char *> varnames;

600
    if( current->isEmpty() )
601
    {
602
        addActionWithSubmenu( current, "video-es", qtr( "Video &Track" ) );
603 604 605 606 607

        QAction *action;
        QMenu *submenu = new QMenu( qtr( "&Subtitles Track" ), current );
        action = current->addMenu( submenu );
        action->setData( "spu-es" );
608
        addDPStaticEntry( submenu, qtr( "Open File..." ), "",
609
                          SLOT( loadSubtitlesFile() ) );
610
        submenu->addSeparator();
611
        current->addSeparator();
612

613 614 615
        addActionWithCheckbox( current, "fullscreen", qtr( "&Fullscreen" ) );
        addActionWithCheckbox( current, "autoscale", qtr( "Always Fit &Window" ) );
        addActionWithCheckbox( current, "video-on-top", qtr( "Always &on Top" ) );
616
#ifdef WIN32
617
        addActionWithCheckbox( current, "direct3d-desktop", qtr( "Display on &Desktop" ) );
François Cartegnie's avatar
François Cartegnie committed
618
#endif
619
        addAction( current, "video-snapshot", qtr( "Take &Snapshot" ) );
François Cartegnie's avatar
François Cartegnie committed
620
#ifdef WIN32
621
        addActionWithCheckbox( current, "video-wallpaper", qtr( "Set as Wall&paper" ) );
622
#endif
623 624
        current->addSeparator();

625 626 627 628 629 630
        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" ) );
631
    }
632

633 634
    p_input = THEMIM->getInput();

635
    p_vout = THEMIM->getVout();
636
    VideoAutoMenuBuilder( p_vout, p_input, objects, varnames );
637

638 639
    if( p_vout )
        vlc_object_release( p_vout );
640

641
    return Populate( p_intf, current, varnames, objects );
642 643
}

644 645 646 647
/**
 * Navigation Menu
 * For DVD, MP4, MOV and other chapter based format
 **/
648
QMenu *QVLCMenu::NavigMenu( intf_thread_t *p_intf, QMenu *menu )
649
{
650
    QAction *action;
651

652 653 654 655
    addActionWithSubmenu( menu, "title", qtr( "T&itle" ) );
    addActionWithSubmenu( menu, "chapter", qtr( "&Chapter" ) );
    addActionWithSubmenu( menu, "navigation", qtr( "&Navigation" ) );
    addActionWithSubmenu( menu, "program", qtr( "&Program" ) );
656

657 658 659 660 661 662 663 664
    /* 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" );

665 666
    menu->addSeparator();
    PopupMenuPlaylistControlEntries( menu, p_intf );
667
    PopupMenuControlEntries( menu, p_intf );
668

669 670
    EnableStaticEntries( menu, ( THEMIM->getInput() != NULL ) );
    return RebuildNavigMenu( p_intf, menu );
671 672 673 674
}

QMenu *QVLCMenu::RebuildNavigMenu( intf_thread_t *p_intf, QMenu *menu )
{
675
    /* */
676 677 678 679
    input_thread_t *p_object;
    vector<vlc_object_t *> objects;
    vector<const char *> varnames;

680
    /* Get the input and hold it */
681
    p_object = THEMIM->getInput();
682

683
    InputAutoMenuBuilder( p_object, objects, varnames );
684

685 686
    menu->addSeparator();

687
    /* Title and so on */
688 689 690 691
    PUSH_VAR( "prev-title" );
    PUSH_VAR( "next-title" );
    PUSH_VAR( "prev-chapter" );
    PUSH_VAR( "next-chapter" );
692

693
    EnableStaticEntries( menu, (p_object != NULL ) );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
694
    return Populate( p_intf, menu, varnames, objects );
695
}
696

697
/**
698
 * Service Discovery SubMenu
699
 **/
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
700
QMenu *QVLCMenu::SDMenu( intf_thread_t *p_intf, QWidget *parent )
Clément Stenac's avatar
Clément Stenac committed
701
{
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
702
    QMenu *menu = new QMenu( parent );
703
    menu->setTitle( qtr( I_PL_SD ) );
704

705
    char **ppsz_longnames;
706
    char **ppsz_names = vlc_sd_GetNames( p_intf, &ppsz_longnames, NULL );
707 708 709
    if( !ppsz_names )
        return menu;

710 711
    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
712
    {
713
        if( !strcmp( *ppsz_name, "podcast" ) )
714
        {
Christophe Mutricy's avatar
Christophe Mutricy committed
715
            QAction *b = new QAction( qtr( "Configure podcasts..." ), menu );
716 717 718 719
            //b->setEnabled( a->isChecked() );
            menu->addAction( b );
            CONNECT( b, triggered(), THEDP, podcastConfigureDialog() );
        }
720 721
        free( *ppsz_name );
        free( *ppsz_longname );
Clément Stenac's avatar
Clément Stenac committed
722
    }
723 724
    free( ppsz_names );
    free( ppsz_longnames );
Clément Stenac's avatar
Clément Stenac committed
725 726
    return menu;
}
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
727

728 729 730
/**
 * Help/About Menu
**/