menus.cpp 47.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 40
#include <vlc_vout.h>                             /* vout_thread_t */
#include <vlc_aout.h>                             /* audio_output_t */
41

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

44 45 46 47 48 49 50 51
#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 */
#include "util/qmenuview.hpp"                     /* Simple Playlist menu */
#include "components/playlist/playlist_model.hpp" /* PLModel getter */
Clément Stenac's avatar
Clément Stenac committed
52

53 54 55 56 57 58
#include <QMenu>
#include <QMenuBar>
#include <QAction>
#include <QActionGroup>
#include <QSignalMapper>
#include <QSystemTrayIcon>
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
59
#include <QStatusBar>
60
#include <QFontMetrics>
61

62 63 64 65
/*
  This file defines the main menus and the pop-up menu (right-click menu)
  and the systray menu (in that order in the file)

66 67 68
  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
69 70 71 72 73 74 75
  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.
  */

76 77 78
#define STATIC_ENTRY "__static__"
#define ENTRY_ALWAYS_ENABLED "__ignore__"

79 80
enum
{
81 82 83
    ITEM_NORMAL, /* not a checkbox, nor a radio */
    ITEM_CHECK,  /* Checkbox */
    ITEM_RADIO   /* Radiobox */
84 85 86 87
};

static QActionGroup *currentGroup;

88
QMenu *QVLCMenuManager::recentsMenu = NULL;
Ludovic Fauvet's avatar
Ludovic Fauvet committed
89

90 91 92
/**
 * @brief Add static entries to DP in menus
 **/
93
QAction *addDPStaticEntry( QMenu *menu,
94
                       const QString& text,
95
                       const char *icon,
96
                       const char *member,
97 98 99
                       const char *shortcut = NULL,
                       QAction::MenuRole = QAction::NoRole
                       )
100
{
101
    QAction *action = NULL;
102
#ifndef __APPLE__ /* We don't set icons in menus in MacOS X */
Rémi Duraffort's avatar
Rémi Duraffort committed
103
    if( !EMPTY_STR( icon ) )
104
    {
Rémi Duraffort's avatar
Rémi Duraffort committed
105
        if( !EMPTY_STR( shortcut ) )
106 107
            action = menu->addAction( QIcon( icon ), text, THEDP,
                                      member, qtr( shortcut ) );
108
        else
109
            action = menu->addAction( QIcon( icon ), text, THEDP, member );
110 111
    }
    else
112
#endif
113
    {
Rémi Duraffort's avatar
Rémi Duraffort committed
114
        if( !EMPTY_STR( shortcut ) )
115
            action = menu->addAction( text, THEDP, member, qtr( shortcut ) );
116
        else
117
            action = menu->addAction( text, THEDP, member );
118
    }
119
    action->setData( STATIC_ENTRY );
120
    return action;
121
}
122

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

149
/**
150 151
 * @brief Enable all static entries of a menu, disable the others
 * @param menu the menu in which the entries will be disabled
152
 * @param enable if false, disable all entries
153
 **/
154
void EnableStaticEntries( QMenu *menu, bool enable = true )
155
{
156
    if( !menu ) return;
157

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

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

175
    int i_ret = 0;
176

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

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

202
/*****************************************************************************
203
 * Definitions of variables for the dynamic menus
204
 *****************************************************************************/
205 206
#define PUSH_VAR( var ) varnames.append( var ); \
    objects.append( VLC_OBJECT(p_object) )
207

208 209
#define PUSH_INPUTVAR( var ) varnames.append( var ); \
    objects.append( VLC_OBJECT(p_input) );
210

211
static int InputAutoMenuBuilder( input_thread_t *p_object,
212 213
        QVector<vlc_object_t *> &objects,
        QVector<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 226
        QVector<vlc_object_t *> &objects,
        QVector<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( audio_output_t *p_object,
249
        input_thread_t *p_input,
250 251
        QVector<vlc_object_t *> &objects,
        QVector<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
static inline QMenu *addActionWithSubmenu( QMenu *_menu, QVariant val, QString title ) {
287
    QAction *_action = new QAction( title, _menu );
288
    QMenu *_submenu = new QMenu( _menu );
289
    _action->setData( val );
290
    _action->setMenu( _submenu );
291
    _menu->addAction( _action );
292
    return _submenu;
293
}
294

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

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

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

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

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

    /* View menu, a bit different */
Rémi Duraffort's avatar
Rémi Duraffort committed
324
    BAR_DADD( ViewMenu( p_intf, NULL, mi ), qtr( "V&iew" ), 4 );
325

326
    addMenuToMainbar( HelpMenu( bar ), qtr( "&Help" ), bar );
327

328
}
329 330

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

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

350
    menu->addSeparator();
351 352 353 354 355

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

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

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

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

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

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

384 385 386 387 388 389
    if( mi->getSysTray() )
    {
        action = menu->addAction( qtr( "Close to systray"), mi,
                                 SLOT( toggleUpdateSystrayMenu() ) );
    }

390
    addDPStaticEntry( menu, qtr( "&Quit" ) ,
391
        ":/menu/quit", SLOT( quit() ), "Ctrl+Q" );
392 393 394
    return menu;
}

395
/**
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
396
 * Tools, like Media Information, Preferences or Messages
397
 **/
398
QMenu *QVLCMenuManager::ToolsMenu( QMenu *menu )
Clément Stenac's avatar
Clément Stenac committed
399
{
400
    addDPStaticEntry( menu, qtr( "&Effects and Filters"), ":/menu/settings",
401
            SLOT( extendedDialog() ), "Ctrl+E" );
402

403
    addDPStaticEntry( menu, qtr( "&Track Synchronization"), ":/menu/settings",
404 405
            SLOT( synchroDialog() ), "" );

406
    addDPStaticEntry( menu, qtr( I_MENU_INFO ) , ":/menu/info",
407
        SLOT( mediaInfoDialog() ), "Ctrl+I" );
408
    addDPStaticEntry( menu, qtr( I_MENU_CODECINFO ) ,
409
        ":/menu/info", SLOT( mediaCodecDialog() ), "Ctrl+J" );
410

411
#ifdef ENABLE_VLM
412
    addDPStaticEntry( menu, qtr( I_MENU_VLM ), "", SLOT( vlmDialog() ),
413 414
        "Ctrl+W" );
#endif
415

416 417 418
    addDPStaticEntry( menu, qtr( "Program Guide" ), "", SLOT( epgDialog() ),
        "" );

419
    addDPStaticEntry( menu, qtr( I_MENU_MSG ),
420
        ":/menu/messages", SLOT( messagesDialog() ), "Ctrl+M" );
421

422 423
    addDPStaticEntry( menu, qtr( "Plu&gins and extensions" ),
        "", SLOT( pluginDialog() ) );
Clément Stenac's avatar
Clément Stenac committed
424 425
    menu->addSeparator();

426 427 428
    addDPStaticEntry( menu, qtr( "Customi&ze Interface..." ),
        ":/menu/preferences", SLOT( toolbarDialog() ) );

429
    addDPStaticEntry( menu, qtr( "&Preferences" ),
430
        ":/menu/preferences", SLOT( prefsDialog() ), "Ctrl+P", QAction::PreferencesRole );
431

Clément Stenac's avatar
Clément Stenac committed
432 433 434
    return menu;
}

435
/**
436
 * View Menu
437
 * Interface modification, load other interfaces, activate Extensions
438
 * \param current, set to NULL for menu creation, else for menu update
439
 **/
440
QMenu *QVLCMenuManager::ViewMenu( intf_thread_t *p_intf, QMenu *current, MainInterface *_mi )
441
{
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
442
    QAction *action;
443
    QMenu *menu;
444

445 446 447
    MainInterface *mi = _mi ? _mi : p_intf->p_sys->p_mi;
    assert( mi );

448 449
    if( !current )
    {
450
        menu = new QMenu( qtr( "&View" ), mi );
451
    }
452 453 454
    else
    {
        menu = current;
455 456 457 458 459 460 461 462
        //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 );
463
            if( m && m->parent() == menu ) delete m;
464
        }
465
    }
466

467 468 469 470
    menu->addAction(
#ifndef __APPLE__
            QIcon( ":/menu/playlist_menu" ),
#endif
471 472 473
            qtr( "Play&list" ), mi,
            SLOT( togglePlaylist() ), qtr( "Ctrl+L" ) );

474 475
    menu->addSeparator();

476
    /* Minimal View */
477
    action = menu->addAction( qtr( "Mi&nimal Interface" ) );
478
    action->setShortcut( qtr( "Ctrl+H" ) );
479
    action->setCheckable( true );
480
    action->setChecked( (mi->getControlsVisibilityStatus() & CONTROLS_HIDDEN ) );
481

482 483
    CONNECT( action, triggered( bool ), mi, toggleMinimalView( bool ) );
    CONNECT( mi, minimalViewToggled( bool ), action, setChecked( bool ) );
484 485 486

    /* FullScreen View */
    action = menu->addAction( qtr( "&Fullscreen Interface" ), mi,
487
            SLOT( toggleInterfaceFullScreen() ), QString( "F11" ) );
488
    action->setCheckable( true );
489
    action->setChecked( mi->isInterfaceFullScreen() );
490 491
    CONNECT( mi, fullscreenInterfaceToggled( bool ),
             action, setChecked( bool ) );
492 493 494

    /* Advanced Controls */
    action = menu->addAction( qtr( "&Advanced Controls" ), mi,
495
            SLOT( toggleAdvancedButtons() ) );
496 497 498 499
    action->setCheckable( true );
    if( mi->getControlsVisibilityStatus() & CONTROLS_ADVANCED )
        action->setChecked( true );

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
500 501 502 503 504 505
    /* 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
506 507 508 509
    action = menu->addAction( qtr( "Status Bar" ) );
    action->setCheckable( true );
    action->setChecked( mi->statusBar()->isVisible() );
    CONNECT( action, triggered( bool ), mi, setStatusBarVisibility( bool) );
510
#if 0 /* For Visualisations. Not yet working */
511 512
    adv = menu->addAction( qtr( "Visualizations selector" ), mi,
                           SLOT( visual() ) );
513 514
    adv->setCheckable( true );
    if( visual_selector_enabled ) adv->setChecked( true );
515
#endif
516

517
    menu->addSeparator();
518 519 520 521

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

522
    /* Extensions */
523
    ExtensionsMenu( p_intf, menu );
524

525 526 527
    return menu;
}

528 529 530
/**
 * Interface Sub-Menu, to list extras interface and skins
 **/
531
QMenu *QVLCMenuManager::InterfacesMenu( intf_thread_t *p_intf, QMenu *current )
532
{
533 534 535 536
    QVector<vlc_object_t *> objects;
    QVector<const char *> varnames;
    varnames.append( "intf-add" );
    objects.append( VLC_OBJECT(p_intf) );
Clément Stenac's avatar
Qt4:  
Clément Stenac committed
537

538
    return Populate( p_intf, current, varnames, objects );
539 540
}

541
/**
542
 * Extensions menu: populate the current menu with extensions
543
 **/
544
void QVLCMenuManager::ExtensionsMenu( intf_thread_t *p_intf, QMenu *extMenu )
545
{
546
    /* Get ExtensionsManager and load extensions if needed */
547
    ExtensionsManager *extMgr = ExtensionsManager::getInstance( p_intf );
548 549 550 551 552 553 554

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

555
    if( !extMgr->isLoaded() && !extMgr->cannotLoad() )
556
    {
557
        extMgr->loadExtensions();
558
    }
559

560
    /* Let the ExtensionsManager build itself the menu */
561
    extMenu->addSeparator();
562
    extMgr->menu( extMenu );
563 564
}

565 566 567 568 569 570 571 572 573 574 575 576 577 578 579
static inline void VolumeEntries( intf_thread_t *p_intf, QMenu *current )
{
        current->addSeparator();

        QAction *action = current->addAction( qtr( "Increase Volume" ),
                ActionsManager::getInstance( p_intf ), SLOT( AudioUp() ) );
        action->setData( STATIC_ENTRY );
        action = current->addAction( qtr( "Decrease Volume" ),
                ActionsManager::getInstance( p_intf ), SLOT( AudioDown() ) );
        action->setData( STATIC_ENTRY );
        action = current->addAction( qtr( "Mute" ),
                ActionsManager::getInstance( p_intf ), SLOT( toggleMuteAudio() ) );
        action->setData( STATIC_ENTRY );
}

580 581
/**
 * Main Audio Menu
582
 **/
583
QMenu *QVLCMenuManager::AudioMenu( intf_thread_t *p_intf, QMenu * current )
584
{
585 586
    QVector<vlc_object_t *> objects;
    QVector<const char *> varnames;
587
    audio_output_t *p_aout;
588 589 590
    input_thread_t *p_input;

    if( current->isEmpty() )
591
    {
592 593 594
        addActionWithSubmenu( current, "audio-es", qtr( "Audio &Track" ) );
        addActionWithSubmenu( current, "audio-channels", qtr( "Audio &Channels" ) );
        addActionWithSubmenu( current, "audio-device", qtr( "Audio &Device" ) );
595
        current->addSeparator();
596

597
        addActionWithSubmenu( current, "visual", qtr( "&Visualizations" ) );
598
        VolumeEntries( p_intf, current );
599 600
    }

601
    p_input = THEMIM->getInput();
602
    p_aout = THEMIM->getAout();
603
    EnableStaticEntries( current, ( p_aout != NULL ) );
604
    AudioAutoMenuBuilder( p_aout, p_input, objects, varnames );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
605
    if( p_aout )
606
    {
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
607
        vlc_object_release( p_aout );
608
    }
609

610 611 612
    return Populate( p_intf, current, varnames, objects );
}

613
/* Subtitles */
614
QMenu *QVLCMenuManager::SubtitleMenu( QMenu *current )
615 616 617 618 619 620 621 622
{
    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();
623
    return submenu;
624 625
}

626 627 628 629
/**
 * Main Video Menu
 * Subtitles are part of Video.
 **/
630
QMenu *QVLCMenuManager::VideoMenu( intf_thread_t *p_intf, QMenu *current, bool b_subtitle )
631
{
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
632
    vout_thread_t *p_vout;
633
    input_thread_t *p_input;
634 635
    QVector<vlc_object_t *> objects;
    QVector<const char *> varnames;
636

637
    if( current->isEmpty() )
638
    {
639
        addActionWithSubmenu( current, "video-es", qtr( "Video &Track" ) );
640
        if( b_subtitle)
641
            SubtitleMenu( current );
642

643
        current->addSeparator();
644
        /* Surface modifiers */
645 646 647
        addActionWithCheckbox( current, "fullscreen", qtr( "&Fullscreen" ) );
        addActionWithCheckbox( current, "autoscale", qtr( "Always Fit &Window" ) );
        addActionWithCheckbox( current, "video-on-top", qtr( "Always &on Top" ) );
648
#ifdef WIN32
649
        addActionWithCheckbox( current, "direct3d-desktop", qtr( "Display on &Desktop" ) );
François Cartegnie's avatar
François Cartegnie committed
650
#endif
651

François Cartegnie's avatar
François Cartegnie committed
652
#ifdef WIN32
653
        addActionWithCheckbox( current, "video-wallpaper", qtr( "Set as Wall&paper" ) );
654
#endif
655
        current->addSeparator();
656
        /* Size modifiers */
657 658 659
        addActionWithSubmenu( current, "zoom", qtr( "&Zoom" ) );
        addActionWithSubmenu( current, "aspect-ratio", qtr( "&Aspect Ratio" ) );
        addActionWithSubmenu( current, "crop", qtr( "&Crop" ) );
660 661 662

        current->addSeparator();
        /* Rendering modifiers */
663 664 665
        addActionWithSubmenu( current, "deinterlace", qtr( "&Deinterlace" ) );
        addActionWithSubmenu( current, "deinterlace-mode", qtr( "&Deinterlace mode" ) );
        addActionWithSubmenu( current, "postprocess", qtr( "&Post processing" ) );
666 667 668 669

        current->addSeparator();
        /* Other actions */
        addAction( current, "video-snapshot", qtr( "Take &Snapshot" ) );
670
    }
671

672 673
    p_input = THEMIM->getInput();

674
    p_vout = THEMIM->getVout();
675
    VideoAutoMenuBuilder( p_vout, p_input, objects, varnames );
676

677 678
    if( p_vout )
        vlc_object_release( p_vout );
679

680
    return Populate( p_intf, current, varnames, objects );
681 682
}

683 684 685 686
/**
 * Navigation Menu
 * For DVD, MP4, MOV and other chapter based format
 **/
687
QMenu *QVLCMenuManager::NavigMenu( intf_thread_t *p_intf, QMenu *menu )
688
{
689
    QAction *action;
690
    QMenu *submenu;
691

692 693
    addActionWithSubmenu( menu, "title", qtr( "T&itle" ) );
    addActionWithSubmenu( menu, "chapter", qtr( "&Chapter" ) );
694 695
    submenu = addActionWithSubmenu( menu, "navigation", qtr( "&Navigation" ) );
    submenu->setTearOffEnabled( true );
696
    addActionWithSubmenu( menu, "program", qtr( "&Program" ) );
697

698
    /* FixMe: sync I_MENU_BOOKMARK string */
699 700
    submenu = new QMenu( qtr( "Custom &Bookmarks" ), menu );
    submenu->setTearOffEnabled( true );
701 702 703 704 705 706
    addDPStaticEntry( submenu, qtr( "&Manage" ), "",
                      SLOT( bookmarksDialog() ), "Ctrl+B" );
    submenu->addSeparator();
    action = menu->addMenu( submenu );
    action->setData( "bookmark" );

707 708
    menu->addSeparator();
    PopupMenuPlaylistControlEntries( menu, p_intf );
709
    PopupMenuControlEntries( menu, p_intf );
710

711 712
    EnableStaticEntries( menu, ( THEMIM->getInput() != NULL ) );
    return RebuildNavigMenu( p_intf, menu );
713 714
}

715
QMenu *QVLCMenuManager::RebuildNavigMenu( intf_thread_t *p_intf, QMenu *menu )
716
{
717
    /* */