menus.cpp 45.8 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 97 98
                       const char *shortcut = NULL,
                       QAction::MenuRole = QAction::NoRole
                       )
99
{
100
    QAction *action = NULL;
101
#ifndef __APPLE__ /* We don't set icons in menus in MacOS X */
Rémi Duraffort's avatar
Rémi Duraffort committed
102
    if( !EMPTY_STR( icon ) )
103
    {
Rémi Duraffort's avatar
Rémi Duraffort committed
104
        if( !EMPTY_STR( shortcut ) )
105 106
            action = menu->addAction( QIcon( icon ), text, THEDP,
                                      member, qtr( shortcut ) );
107
        else
108
            action = menu->addAction( QIcon( icon ), text, THEDP, member );
109 110
    }
    else
111
#endif
112
    {
Rémi Duraffort's avatar
Rémi Duraffort committed
113
        if( !EMPTY_STR( shortcut ) )
114
            action = menu->addAction( text, THEDP, member, qtr( shortcut ) );
115
        else
116
            action = menu->addAction( text, THEDP, member );
117
    }
118
    action->setData( STATIC_ENTRY );
119
}
120

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

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

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

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

172
    int i_ret = 0;
173

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

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

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

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

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

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

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

246 247 248
    return VLC_SUCCESS;
}

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

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

266
// Static menu
267
#define BAR_ADD( func, title ) { \
268
    QMenu *_menu = func; _menu->setTitle( title ); bar->addMenu( _menu ); }
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
#define ACT_ADD( _menu, val, title ) { \
    QAction *_action = new QAction( title, _menu ); _action->setData( val ); \
    _menu->addAction( _action ); }
281

282
// Add an action with a submenu
283 284
#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
285
    _action->setMenu( new QMenu( _menu ) ); _menu->addAction( _action ); }
286

287
// Add an action that is a checkbox
288 289 290 291
#define ACT_ADDCHECK( _menu, val, title ) { \
    QAction *_action = new QAction( title, _menu ); _action->setData( val ); \
    _action->setCheckable( true ); _menu->addAction( _action ); }

292 293 294
/**
 * Main Menu Bar Creation
 **/
295
void QVLCMenu::createMenuBar( MainInterface *mi,
296
                              intf_thread_t *p_intf )
Clément Stenac's avatar
Qt4:  
Clément Stenac committed
297
{
298 299 300
    /* QMainWindows->menuBar()
       gives the QProcess::destroyed timeout issue on Cleanlooks style with
       setDesktopAware set to false */
301
    QMenuBar *bar = mi->menuBar();
302

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

305
    /* Dynamic menus, rebuilt before being showed */
306
    BAR_DADD( NavigMenu( p_intf, bar ), qtr( "P&layback" ), 3 );
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
307 308
    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
309

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
310
    BAR_ADD( ToolsMenu( bar ), qtr( "&Tools" ) );
311 312 313 314

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

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
315
    BAR_ADD( HelpMenu( bar ), qtr( "&Help" ) );
316

317
}
318
#undef BAR_ADD
319
//#undef BAR_DADD
320 321

/**
322
 * Media ( File ) Menu
323 324
 * Opening, streaming and quit
 **/
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
325
QMenu *QVLCMenu::FileMenu( intf_thread_t *p_intf, QWidget *parent )
326
{
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
327
    QMenu *menu = new QMenu( parent );
328

329
    addDPStaticEntry( menu, qtr( "&Open File..." ),
330
        ":/type/file-asym", SLOT( simpleOpenDialog() ), "Ctrl+O" );
331
    addDPStaticEntry( menu, qtr( "Advanced Open File..." ),
332
        ":/type/file-asym", SLOT( openFileDialog() ), "Ctrl+Shift+O" );
333
    addDPStaticEntry( menu, qtr( I_OP_OPDIR ),
334
        ":/type/folder-grey", SLOT( PLOpenDir() ), "Ctrl+F" );
335
    addDPStaticEntry( menu, qtr( "Open &Disc..." ),
336
        ":/type/disc", SLOT( openDiscDialog() ), "Ctrl+D" );
337
    addDPStaticEntry( menu, qtr( "Open &Network Stream..." ),
338
        ":/type/network", SLOT( openNetDialog() ), "Ctrl+N" );
339
    addDPStaticEntry( menu, qtr( "Open &Capture Device..." ),
340
        ":/type/capture-card", SLOT( openCaptureDialog() ),
341
        "Ctrl+C" );
342

343
    menu->addSeparator();
344
    addDPStaticEntry( menu, qtr( "Open &Location from clipboard" ),
345
                      NULL, SLOT( openUrlDialog() ), "Ctrl+V" );
346

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
347
    if( var_InheritBool( p_intf, "qt-recentplay" ) )
348 349 350 351 352
    {
        recentsMenu = new QMenu( qtr( "&Recent Media" ), menu );
        updateRecents( p_intf );
        menu->addMenu( recentsMenu );
    }
353
    menu->addSeparator();
354

355 356 357 358
    addDPStaticEntry( menu, qtr( I_PL_SAVE ), "", SLOT( saveAPlaylist() ),
        "Ctrl+Y" );
    menu->addSeparator();

359
#ifdef ENABLE_SOUT
360
    addDPStaticEntry( menu, qtr( "Conve&rt / Save..." ), "",
361
        SLOT( openAndTranscodingDialogs() ), "Ctrl+R" );
362
    addDPStaticEntry( menu, qtr( "&Streaming..." ),
363
        ":/menu/stream", SLOT( openAndStreamingDialogs() ),
364
        "Ctrl+S" );
365
    menu->addSeparator();
366
#endif
367

368
    addDPStaticEntry( menu, qtr( "&Quit" ) ,
369
        ":/menu/quit", SLOT( quit() ), "Ctrl+Q" );
370 371 372
    return menu;
}

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

381
    addDPStaticEntry( menu, qtr( "&Track Synchronization"), ":/menu/settings",
382 383
            SLOT( synchroDialog() ), "" );

384
    addDPStaticEntry( menu, qtr( I_MENU_INFO ) , ":/menu/info",
385
        SLOT( mediaInfoDialog() ), "Ctrl+I" );
386
    addDPStaticEntry( menu, qtr( I_MENU_CODECINFO ) ,
387
        ":/menu/info", SLOT( mediaCodecDialog() ), "Ctrl+J" );
388

389
#ifdef ENABLE_VLM
390
    addDPStaticEntry( menu, qtr( I_MENU_VLM ), "", SLOT( vlmDialog() ),
391 392
        "Ctrl+W" );
#endif
393

394 395 396
    addDPStaticEntry( menu, qtr( "Program Guide" ), "", SLOT( epgDialog() ),
        "" );

397
    addDPStaticEntry( menu, qtr( I_MENU_MSG ),
398
        ":/menu/messages", SLOT( messagesDialog() ),
399 400
        "Ctrl+M" );

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

405 406 407
    addDPStaticEntry( menu, qtr( "Customi&ze Interface..." ),
        ":/menu/preferences", SLOT( toolbarDialog() ) );

408
    addDPStaticEntry( menu, qtr( "&Preferences" ),
409
        ":/menu/preferences", SLOT( prefsDialog() ), "Ctrl+P", QAction::PreferencesRole );
410

Clément Stenac's avatar
Clément Stenac committed
411 412 413
    return menu;
}

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

423 424 425
    MainInterface *mi = _mi ? _mi : p_intf->p_sys->p_mi;
    assert( mi );

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

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

452 453
    menu->addSeparator();

454 455
    QMenu *intfmenu = InterfacesMenu( p_intf, menu );
    menu->addSeparator();
456

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

463 464
    CONNECT( action, triggered( bool ), mi, toggleMinimalView( bool ) );
    CONNECT( mi, minimalViewToggled( bool ), action, setChecked( bool ) );
465 466 467

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

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

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

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

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

499
    menu->addSeparator();
500
    /* Extensions */
501
    ExtensionsMenu( p_intf, menu );
502

503 504 505
    return menu;
}

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

516
    return Populate( p_intf, current, varnames, objects );
517 518
}

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

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

533
    if( !extMgr->isLoaded() && !extMgr->cannotLoad() )
534
    {
535
        extMgr->loadExtensions();
536
    }
537

538
    /* Let the ExtensionsManager build itself the menu */
539
    extMenu->addSeparator();
540
    extMgr->menu( extMenu );
541 542
}

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

    if( current->isEmpty() )
554
    {
555 556 557
        ACT_ADDMENU( current, "audio-es", qtr( "Audio &Track" ) );
        ACT_ADDMENU( current, "audio-channels", qtr( "Audio &Channels" ) );
        ACT_ADDMENU( current, "audio-device", qtr( "Audio &Device" ) );
558
        current->addSeparator();
559

560
        ACT_ADDMENU( current, "visual", qtr( "&Visualizations" ) );
561 562
        current->addSeparator();

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

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

583 584 585
    return Populate( p_intf, current, varnames, objects );
}

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

597
    if( current->isEmpty() )
598
    {
599
        ACT_ADDMENU( current, "video-es", qtr( "Video &Track" ) );
600 601 602 603 604

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

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

622 623 624
        ACT_ADDMENU( current, "zoom", qtr( "&Zoom" ) );
        ACT_ADDMENU( current, "aspect-ratio", qtr( "&Aspect Ratio" ) );
        ACT_ADDMENU( current, "crop", qtr( "&Crop" ) );
625 626
        ACT_ADDMENU( current, "deinterlace", qtr( "&Deinterlace" ) );
        ACT_ADDMENU( current, "deinterlace-mode", qtr( "&Deinterlace mode" ) );
627
        ACT_ADDMENU( current, "postprocess", qtr( "&Post processing" ) );
628
    }
629

630 631
    p_input = THEMIM->getInput();

632
    p_vout = THEMIM->getVout();
633
    VideoAutoMenuBuilder( p_vout, p_input, objects, varnames );
634

635 636
    if( p_vout )
        vlc_object_release( p_vout );
637

638
    return Populate( p_intf, current, varnames, objects );
639 640
}

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

649 650 651 652
    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" ) );
653

654 655 656 657 658 659 660 661
    /* 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" );

662 663
    menu->addSeparator();
    PopupMenuPlaylistControlEntries( menu, p_intf );
664
    PopupMenuControlEntries( menu, p_intf );
665

666 667
    EnableStaticEntries( menu, ( THEMIM->getInput() != NULL ) );
    return RebuildNavigMenu( p_intf, menu );
668 669 670 671
}

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

677
    /* Get the input and hold it */
678
    p_object = THEMIM->getInput();
679

680
    InputAutoMenuBuilder( p_object, objects, varnames );
681

682 683
    menu->addSeparator();

684
    /* Title and so on */
685 686 687 688
    PUSH_VAR( "prev-title" );
    PUSH_VAR( "next-title" );
    PUSH_VAR( "prev-chapter" );
    PUSH_VAR( "next-chapter" );
689

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

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

702
    char **ppsz_longnames;
703
    char **ppsz_names = vlc_sd_GetNames( p_intf, &ppsz_longnames, NULL );
704 705 706
    if( !ppsz_names )
        return menu;

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

725 726 727
/**
 * Help/About Menu
**/
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
728
QMenu *QVLCMenu::HelpMenu( QWidget *parent )
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
729
{
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
730
    QMenu *menu = new QMenu( parent );
731
    addDPStaticEntry( menu, qtr( "&Help..." ) ,
732
        ":/menu/help", SLOT(