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

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

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

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

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

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

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

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

67 68 69 70 71 72 73 74 75
enum
{
    ITEM_NORMAL,
    ITEM_CHECK,
    ITEM_RADIO
};

static QActionGroup *currentGroup;

Ludovic Fauvet's avatar
Ludovic Fauvet committed
76 77
QMenu *QVLCMenu::recentsMenu = NULL;

78 79 80 81 82
/****************************************************************************
 * Menu code helpers:
 ****************************************************************************
 * Add static entries to DP in menus
 ***************************************************************************/
83 84
void addDPStaticEntry( QMenu *menu,
                       const QString text,
85
                       const char *icon,
86
                       const char *member,
87
                       const char *shortcut = NULL )
88
{
89
    QAction *action = NULL;
90 91 92
    if( !EMPTY_STR( icon ) > 0 )
    {
        if( !EMPTY_STR( shortcut ) > 0 )
93 94
            action = menu->addAction( QIcon( icon ), text, THEDP,
                                      member, qtr( shortcut ) );
95
        else
96
            action = menu->addAction( QIcon( icon ), text, THEDP, member );
97 98 99 100
    }
    else
    {
        if( !EMPTY_STR( shortcut ) > 0 )
101
            action = menu->addAction( text, THEDP, member, qtr( shortcut ) );
102
        else
103
            action = menu->addAction( text, THEDP, member );
104
    }
Jean-Philippe Andre's avatar
Jean-Philippe Andre committed
105
    action->setData( true );
106
}
107

108 109 110 111 112 113 114 115 116
/***
 * Same for MIM
 ***/
void addMIMStaticEntry( intf_thread_t *p_intf,
                        QMenu *menu,
                        const QString text,
                        const char *icon,
                        const char *member )
{
117
    QAction *action;
118 119
    if( strlen( icon ) > 0 )
    {
120
        action = menu->addAction( text, THEMIM,  member );
121 122 123 124 125 126
        action->setIcon( QIcon( icon ) );
    }
    else
    {
        menu->addAction( text, THEMIM, member );
    }
127
    action->setData( "ignore" );
128 129
}

130 131 132 133 134
/**
 * @brief Enable all static entries, disable the others
 * @param enable if false, disable all entries
 */
void EnableStaticEntries( QMenu *menu, bool enable = true )
135
{
136
    if( !menu ) return;
137

Jean-Philippe Andre's avatar
Jean-Philippe Andre committed
138 139
    QList< QAction* > actions = menu->actions();
    for( int i = 0; i < actions.size(); ++i )
140
    {
141
        actions[i]->setEnabled( actions[i]->data().toString() == "ignore" ||
142
                /* Be careful here, because data("string").toBool is true */
143
                ( enable && (actions[i]->data().toString() == "true" ) ) );
144 145 146
    }
}

147 148 149 150 151
/**
 * \return Number of static entries
 */
int DeleteNonStaticEntries( QMenu *menu )
{
152 153
    if( !menu ) return VLC_EGENERIC;

154
    int i_ret = 0;
155

Jean-Philippe Andre's avatar
Jean-Philippe Andre committed
156 157
    QList< QAction* > actions = menu->actions();
    for( int i = 0; i < actions.size(); ++i )
158
    {
Jean-Philippe Andre's avatar
Jean-Philippe Andre committed
159 160
        if( !actions[i]->data().toBool() )
            delete actions[i];
161 162 163
        else
            i_ret++;
    }
164
    return i_ret;
165 166
}

167 168 169 170
/**
 * \return QAction associated to psz_var variable
 **/
static QAction * FindActionWithVar( QMenu *menu, const char *psz_var )
171
{
172 173
    QList< QAction* > actions = menu->actions();
    for( int i = 0; i < actions.size(); ++i )
174
    {
175 176
        if( actions[i]->data().toString() == psz_var )
            return actions[i];
177
    }
178
    return NULL;
179 180
}

181
/*****************************************************************************
182
 * Definitions of variables for the dynamic menus
183
 *****************************************************************************/
184
#define PUSH_VAR( var ) varnames.push_back( var ); \
185
    objects.push_back( VLC_OBJECT(p_object) )
186 187

#define PUSH_INPUTVAR( var ) varnames.push_back( var ); \
188
    objects.push_back( VLC_OBJECT(p_input) );
189 190

#define PUSH_SEPARATOR if( objects.size() != i_last_separator ) { \
191
    objects.push_back( 0 ); varnames.push_back( "" ); \
192
    i_last_separator = objects.size(); }
193

194
static int InputAutoMenuBuilder( input_thread_t *p_object,
195
        vector<vlc_object_t *> &objects,
196
        vector<const char *> &varnames )
197
{
198
    PUSH_VAR( "bookmark" );
199
    PUSH_VAR( "title" );
200
    PUSH_VAR( "chapter" );
201
    PUSH_VAR( "navigation" );
202
    PUSH_VAR( "program" );
203 204 205
    return VLC_SUCCESS;
}

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
206
static int VideoAutoMenuBuilder( vout_thread_t *p_object,
207
        input_thread_t *p_input,
208
        vector<vlc_object_t *> &objects,
209
        vector<const char *> &varnames )
210
{
211 212
    PUSH_INPUTVAR( "video-es" );
    PUSH_INPUTVAR( "spu-es" );
213 214
    PUSH_VAR( "fullscreen" );
    PUSH_VAR( "video-on-top" );
215
#ifdef WIN32
216
    PUSH_VAR( "directx-wallpaper" );
217
#endif
218
    PUSH_VAR( "video-snapshot" );
219
    PUSH_VAR( "zoom" );
220
    PUSH_VAR( "autoscale" );
221 222 223
    PUSH_VAR( "aspect-ratio" );
    PUSH_VAR( "crop" );
    PUSH_VAR( "deinterlace" );
224
    PUSH_VAR( "postprocess" );
225

226 227 228
    return VLC_SUCCESS;
}

229
static int AudioAutoMenuBuilder( aout_instance_t *p_object,
230
        input_thread_t *p_input,
231
        vector<vlc_object_t *> &objects,
232
        vector<const char *> &varnames )
233
{
234
    PUSH_INPUTVAR( "audio-es" );
235
    PUSH_VAR( "audio-channels" );
236 237
    PUSH_VAR( "audio-device" );
    PUSH_VAR( "visual" );
238 239 240
    return VLC_SUCCESS;
}

241 242
/*****************************************************************************
 * All normal menus
243
 * Simple Code
244 245 246
 *****************************************************************************/

#define BAR_ADD( func, title ) { \
247
    QMenu *_menu = func; _menu->setTitle( title ); bar->addMenu( _menu ); }
248 249

#define BAR_DADD( func, title, id ) { \
250 251 252 253 254 255 256 257
    QMenu *_menu = func; _menu->setTitle( title ); bar->addMenu( _menu ); \
    MenuFunc *f = new MenuFunc( _menu, id ); \
    CONNECT( _menu, aboutToShow(), THEDP->menusUpdateMapper, map() ); \
    THEDP->menusUpdateMapper->setMapping( _menu, f ); }

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

259 260
#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
261
    _action->setMenu( new QMenu( _menu ) ); _menu->addAction( _action ); }
262 263 264 265 266

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

267 268 269
/**
 * Main Menu Bar Creation
 **/
270
void QVLCMenu::createMenuBar( MainInterface *mi,
271
                              intf_thread_t *p_intf )
Clément Stenac's avatar
Qt4:  
Clément Stenac committed
272
{
273 274 275
    /* QMainWindows->menuBar()
       gives the QProcess::destroyed timeout issue on Cleanlooks style with
       setDesktopAware set to false */
276
    QMenuBar *bar = mi->menuBar();
277

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

280
    /* Dynamic menus, rebuilt before being showed */
281
    BAR_DADD( NavigMenu( p_intf, bar ), qtr( "P&layback" ), 3 );
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
282 283
    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
284

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
285
    BAR_ADD( ToolsMenu( bar ), qtr( "&Tools" ) );
286
    BAR_ADD( ViewMenu( p_intf, mi ), qtr( "V&iew" ) );
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
287
    BAR_ADD( HelpMenu( bar ), qtr( "&Help" ) );
288
}
289 290
#undef BAR_ADD
#undef BAR_DADD
291 292

/**
293
 * Media ( File ) Menu
294 295
 * Opening, streaming and quit
 **/
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
296
QMenu *QVLCMenu::FileMenu( intf_thread_t *p_intf, QWidget *parent )
297
{
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
298
    QMenu *menu = new QMenu( parent );
299

300
    addDPStaticEntry( menu, qtr( "&Open File..." ),
301
        ":/file-asym", SLOT( simpleOpenDialog() ), "Ctrl+O" );
302
    addDPStaticEntry( menu, qtr( "Advanced Open File..." ),
303
        ":/file-asym", SLOT( openFileDialog() ), "Ctrl+Shift+O" );
304
    addDPStaticEntry( menu, qtr( I_OPEN_FOLDER ),
305
        ":/folder-grey", SLOT( PLOpenDir() ), "Ctrl+F" );
306
    addDPStaticEntry( menu, qtr( "Open &Disc..." ),
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
307
        ":/disc", SLOT( openDiscDialog() ), "Ctrl+D" );
308
    addDPStaticEntry( menu, qtr( "Open &Network Stream..." ),
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
309
        ":/network", SLOT( openNetDialog() ), "Ctrl+N" );
310
    addDPStaticEntry( menu, qtr( "Open &Capture Device..." ),
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
311
        ":/capture-card", SLOT( openCaptureDialog() ),
312
        "Ctrl+C" );
313

314
    menu->addSeparator();
315
    addDPStaticEntry( menu, qtr( "Open &Location from clipboard" ),
316
                      NULL, SLOT( openUrlDialog() ), "Ctrl+V" );
317

318 319 320 321 322 323
    if( config_GetInt( p_intf, "qt-recentplay" ) )
    {
        recentsMenu = new QMenu( qtr( "&Recent Media" ), menu );
        updateRecents( p_intf );
        menu->addMenu( recentsMenu );
    }
324 325
    menu->addMenu( SDMenu( p_intf, menu ) );
    menu->addSeparator();
326

327 328 329 330
    addDPStaticEntry( menu, qtr( I_PL_SAVE ), "", SLOT( saveAPlaylist() ),
        "Ctrl+Y" );
    menu->addSeparator();

331
    addDPStaticEntry( menu, qtr( "Conve&rt / Save..." ), "",
332
        SLOT( openAndTranscodingDialogs() ), "Ctrl+R" );
333
    addDPStaticEntry( menu, qtr( "&Streaming..." ),
334
        ":/stream", SLOT( openAndStreamingDialogs() ),
335
        "Ctrl+S" );
336
    menu->addSeparator();
337

338
    addDPStaticEntry( menu, qtr( "&Quit" ) ,
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
339
        ":/quit", SLOT( quit() ), "Ctrl+Q" );
340 341 342
    return menu;
}

343 344 345
/**
 * Tools, like Media Information, Preferences or Messages 
 **/
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
346
QMenu *QVLCMenu::ToolsMenu( QMenu *menu )
Clément Stenac's avatar
Clément Stenac committed
347
{
348
    addDPStaticEntry( menu, qtr( "&Effects and Filters"), ":/settings",
349
            SLOT( extendedDialog() ), "Ctrl+E" );
350

351
    addDPStaticEntry( menu, qtr( "&Track Synchronization"), ":/settings",
352 353
            SLOT( synchroDialog() ), "" );

354
    addDPStaticEntry( menu, qtr( I_MENU_INFO ) , ":/info",
355
        SLOT( mediaInfoDialog() ), "Ctrl+I" );
356
    addDPStaticEntry( menu, qtr( I_MENU_CODECINFO ) ,
357
        ":/info", SLOT( mediaCodecDialog() ), "Ctrl+J" );
358

359
    addDPStaticEntry( menu, qtr( I_MENU_BOOKMARK ),"",
360 361
                      SLOT( bookmarksDialog() ), "Ctrl+B" );
#ifdef ENABLE_VLM
362
    addDPStaticEntry( menu, qtr( I_MENU_VLM ), "", SLOT( vlmDialog() ),
363 364
        "Ctrl+W" );
#endif
365 366 367 368 369

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

370 371
    addDPStaticEntry( menu, qtr( "Plu&gins and extensions" ),
        "", SLOT( pluginDialog() ) );
Clément Stenac's avatar
Clément Stenac committed
372 373
    menu->addSeparator();

374
    addDPStaticEntry( menu, qtr( "&Preferences" ),
375 376
        ":/preferences", SLOT( prefsDialog() ), "Ctrl+P" );

Clément Stenac's avatar
Clément Stenac committed
377 378 379
    return menu;
}

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
380 381 382 383 384
QMenu *QVLCMenu::ToolsMenu( QWidget *parent )
{
    return ToolsMenu( new QMenu( parent ) );
}

385
/**
386
 * View Menu
387
 * Interface Modification
388
 **/
389
QMenu *QVLCMenu::ViewMenu( intf_thread_t *p_intf,
390 391
                            MainInterface *mi,
                            bool with_intf )
392
{
393 394 395 396 397 398 399 400
    assert( mi );

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

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

401 402 403 404
    /*menu->addSeparator();
    menu->addAction( qtr( "Undock from Interface" ), mi,
                     SLOT( undockPlaylist() ), qtr( "Ctrl+U" ) );*/

405 406
    menu->addSeparator();

407 408
    if( with_intf )
    {
409
        QMenu *intfmenu = InterfacesMenu( p_intf, menu );
410 411 412
        MenuFunc *f = new MenuFunc( intfmenu, 4 );
        CONNECT( intfmenu, aboutToShow(), THEDP->menusUpdateMapper, map() );
        THEDP->menusUpdateMapper->setMapping( intfmenu, f );
413 414
        menu->addSeparator();
    }
415

416
    /* Minimal View */
417 418
    QAction *action = menu->addAction( qtr( "Mi&nimal View" ) );
    action->setShortcut( qtr( "Ctrl+H" ) );
419
    action->setCheckable( true );
420
    action->setChecked( !with_intf &&
421
            (mi->getControlsVisibilityStatus() & CONTROLS_HIDDEN ) );
422

423 424
    CONNECT( action, triggered( bool ), mi, toggleMinimalView( bool ) );
    CONNECT( mi, minimalViewToggled( bool ), action, setChecked( bool ) );
425 426 427 428 429

    /* FullScreen View */
    action = menu->addAction( qtr( "&Fullscreen Interface" ), mi,
            SLOT( toggleFullScreen() ), QString( "F11" ) );
    action->setCheckable( true );
430 431 432
    action->setChecked( mi->isFullScreen() );
    CONNECT( mi, fullscreenInterfaceToggled( bool ),
             action, setChecked( bool ) );
433 434 435 436 437 438 439 440

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

441 442 443 444 445 446 447 448
    if( with_intf )
    // I don't want to manage consistency between menus, so no popup-menu
    {
        action = menu->addAction( qtr( "Quit after Playback" ) );
        action->setCheckable( true );
        CONNECT( action, triggered( bool ), THEMIM, activatePlayQuit( bool ) );
    }

449
#if 0 /* For Visualisations. Not yet working */
450 451 452 453
    adv = menu->addAction( qtr( "Visualizations selector" ),
            mi, SLOT( visual() ) );
    adv->setCheckable( true );
    if( visual_selector_enabled ) adv->setChecked( true );
454
#endif
455

456
    menu->addSeparator();
457 458 459
    addDPStaticEntry( menu, qtr( "Customi&ze Interface..." ),
        ":/preferences", SLOT( toolbarDialog() ) );
    menu->addSeparator();
460

461 462 463
    return menu;
}

464 465 466
/**
 * Interface Sub-Menu, to list extras interface and skins
 **/
467 468
QMenu *QVLCMenu::InterfacesMenu( intf_thread_t *p_intf, QMenu *current )
{
469
    vector<vlc_object_t *> objects;
470 471
    vector<const char *> varnames;
    varnames.push_back( "intf-add" );
472
    objects.push_back( VLC_OBJECT(p_intf) );
Clément Stenac's avatar
Qt4:  
Clément Stenac committed
473

474
    return Populate( p_intf, current, varnames, objects );
475 476
}

477 478
/**
 * Main Audio Menu
479
 **/
480 481
QMenu *QVLCMenu::AudioMenu( intf_thread_t *p_intf, QMenu * current )
{
482
    vector<vlc_object_t *> objects;
483
    vector<const char *> varnames;
484
    aout_instance_t *p_aout;
485 486 487
    input_thread_t *p_input;

    if( current->isEmpty() )
488
    {
489 490 491
        ACT_ADDMENU( current, "audio-es", qtr( "Audio &Track" ) );
        ACT_ADDMENU( current, "audio-channels", qtr( "Audio &Channels" ) );
        ACT_ADDMENU( current, "audio-device", qtr( "Audio &Device" ) );
492
        current->addSeparator();
493

494
        ACT_ADDMENU( current, "visual", qtr( "&Visualizations" ) );
495 496
        current->addSeparator();

497
        QAction *action = current->addAction( qtr( "Increase Volume" ),
498 499 500 501 502
                ActionsManager::getInstance( p_intf ), SLOT( AudioUp() ) );
        action->setData( true );
        action = current->addAction( qtr( "Decrease Volume" ),
                ActionsManager::getInstance( p_intf ), SLOT( AudioDown() ) );
        action->setData( true );
503 504 505
        action = current->addAction( qtr( "Mute" ),
                ActionsManager::getInstance( p_intf ), SLOT( toggleMuteAudio() ) );
        action->setData( true );
506 507
    }

508
    p_input = THEMIM->getInput();
509
    p_aout = THEMIM->getAout();
510
    EnableStaticEntries( current, ( p_aout != NULL ) );
511
    AudioAutoMenuBuilder( p_aout, p_input, objects, varnames );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
512
    if( p_aout )
513
    {
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
514
        vlc_object_release( p_aout );
515
    }
516

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

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
520 521 522 523 524
QMenu *QVLCMenu::AudioMenu( intf_thread_t *p_intf, QWidget *parent )
{
    return AudioMenu( p_intf, new QMenu( parent ) );
}

525 526 527 528
/**
 * Main Video Menu
 * Subtitles are part of Video.
 **/
529
QMenu *QVLCMenu::VideoMenu( intf_thread_t *p_intf, QMenu *current )
530
{
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
531
    vout_thread_t *p_vout;
532
    input_thread_t *p_input;
533
    vector<vlc_object_t *> objects;
534 535
    vector<const char *> varnames;

536
    if( current->isEmpty() )
537
    {
538
        ACT_ADDMENU( current, "video-es", qtr( "Video &Track" ) );
539 540 541 542 543

        QAction *action;
        QMenu *submenu = new QMenu( qtr( "&Subtitles Track" ), current );
        action = current->addMenu( submenu );
        action->setData( "spu-es" );
544
        addDPStaticEntry( submenu, qtr( "Open File..." ), "",
545
                          SLOT( loadSubtitlesFile() ) );
546
        submenu->addSeparator();
547
        current->addSeparator();
548

549 550
        ACT_ADDCHECK( current, "fullscreen", qtr( "&Fullscreen" ) );
        ACT_ADDCHECK( current, "video-on-top", qtr( "Always &On Top" ) );
551
#ifdef WIN32
552
        ACT_ADDCHECK( current, "directx-wallpaper", qtr( "DirectX Wallpaper" ) );
553
#endif
554
        ACT_ADD( current, "video-snapshot", qtr( "Sna&pshot" ) );
555

556 557
        current->addSeparator();

558 559 560 561 562
        ACT_ADDMENU( current, "zoom", qtr( "&Zoom" ) );
        ACT_ADDCHECK( current, "autoscale", qtr( "Sca&le" ) );
        ACT_ADDMENU( current, "aspect-ratio", qtr( "&Aspect Ratio" ) );
        ACT_ADDMENU( current, "crop", qtr( "&Crop" ) );
        ACT_ADDMENU( current, "deinterlace", qtr( "&Deinterlace" ) );
563
        ACT_ADDMENU( current, "postprocess", qtr( "&Post processing" ) );
564
    }
565

566 567
    p_input = THEMIM->getInput();

568
    p_vout = THEMIM->getVout();
569
    VideoAutoMenuBuilder( p_vout, p_input, objects, varnames );
570

571 572
    if( p_vout )
        vlc_object_release( p_vout );
573

574
    return Populate( p_intf, current, varnames, objects );
575 576
}

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
577 578 579 580 581
QMenu *QVLCMenu::VideoMenu( intf_thread_t *p_intf, QWidget *parent )
{
    return VideoMenu( p_intf, new QMenu( parent ) );
}

582 583 584 585
/**
 * Navigation Menu
 * For DVD, MP4, MOV and other chapter based format
 **/
586
QMenu *QVLCMenu::NavigMenu( intf_thread_t *p_intf, QMenu *menu )
587
{
588
    QAction *action;
589

590 591 592 593 594 595
    QMenu *submenu = new QMenu( qtr( "&Bookmarks" ), menu );
    addDPStaticEntry( submenu, qtr( "Manage &bookmarks" ), "",
                      SLOT( bookmarksDialog() ) );
    submenu->addSeparator();
    action = menu->addMenu( submenu );
    action->setData( "bookmark" );
596

597 598 599 600
    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" ) );
601

602 603
    menu->addSeparator();
    PopupMenuPlaylistControlEntries( menu, p_intf );
604
    PopupMenuControlEntries( menu, p_intf );
605 606 607 608 609 610

    return menu;
}

QMenu *QVLCMenu::RebuildNavigMenu( intf_thread_t *p_intf, QMenu *menu )
{
611
    /* */
612 613 614 615
    input_thread_t *p_object;
    vector<vlc_object_t *> objects;
    vector<const char *> varnames;

616
    /* Get the input and hold it */
617
    p_object = THEMIM->getInput();
618

619
    InputAutoMenuBuilder( p_object, objects, varnames );
620

621 622
    menu->addSeparator();

623
    /* Title and so on */
624 625 626 627
    PUSH_VAR( "prev-title" );
    PUSH_VAR( "next-title" );
    PUSH_VAR( "prev-chapter" );
    PUSH_VAR( "next-chapter" );
628

629
    EnableStaticEntries( menu, (p_object != NULL ) );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
630
    return Populate( p_intf, menu, varnames, objects );
631
}
632

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
633 634 635 636 637
QMenu *QVLCMenu::NavigMenu( intf_thread_t *p_intf, QWidget *parent )
{
    return NavigMenu( p_intf, new QMenu( parent ) );
}

638
/**
639
 * Service Discovery SubMenu
640
 **/
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
641
QMenu *QVLCMenu::SDMenu( intf_thread_t *p_intf, QWidget *parent )
Clément Stenac's avatar
Clément Stenac committed
642
{
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
643
    QMenu *menu = new QMenu( parent );
644
    menu->setTitle( qtr( I_PL_SD ) );
645

646
    char **ppsz_longnames;
647
    char **ppsz_names = vlc_sd_GetNames( &ppsz_longnames );
648 649 650
    if( !ppsz_names )
        return menu;

651 652
    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
653
    {
654
        QAction *a = new QAction( qfu( *ppsz_longname ), menu );
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
655
        a->setCheckable( true );
656
        if( playlist_IsServicesDiscoveryLoaded( THEPL, *ppsz_name ) )
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
657
            a->setChecked( true );
658
        CONNECT( a, triggered(), THEDP->SDMapper, map() );
659
        THEDP->SDMapper->setMapping( a, QString( *ppsz_name ) );
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
660
        menu->addAction( a );
661

662
        /* Special case for podcast */
663
        if( !strcmp( *ppsz_name, "podcast" ) )
664
        {
Christophe Mutricy's avatar
Christophe Mutricy committed
665
            QAction *b = new QAction( qtr( "Configure podcasts..." ), menu );
666 667 668 669
            //b->setEnabled( a->isChecked() );
            menu->addAction( b );
            CONNECT( b, triggered(), THEDP, podcastConfigureDialog() );
        }
670 671
        free( *ppsz_name );
        free( *ppsz_longname );
Clément Stenac's avatar
Clément Stenac committed
672
    }
673 674
    free( ppsz_names );
    free( ppsz_longnames );
Clément Stenac's avatar
Clément Stenac committed
675 676
    return menu;
}
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
677

678 679 680
/**
 * Help/About Menu
**/
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
681
QMenu *QVLCMenu::HelpMenu( QWidget *parent )
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
682
{
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
683
    QMenu *menu = new QMenu( parent );
684
    addDPStaticEntry( menu, qtr( "&Help..." ) ,
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
685
        ":/help", SLOT( helpDialog() ), "F1" );
686
#ifdef UPDATE_CHECK
687 688
    addDPStaticEntry( menu, qtr( "Check for &Updates..." ) , "",
                      SLOT( updateDialog() ) );
689
#endif
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
690
    menu->addSeparator();
691
    addDPStaticEntry( menu, qtr( I_MENU_ABOUT ), ":/info",
692
            SLOT( aboutDialog() ), "Shift+F1" );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
693 694 695
    return menu;
}

696
/*****************************************************************************
697
 * Popup menus - Right Click menus                                           *
698
 *****************************************************************************/
699 700
#define POPUP_BOILERPLATE \
    unsigned int i_last_separator = 0; \
701
    vector<vlc_object_t *> objects; \
702 703 704 705 706 707 708
    vector<const char *> varnames; \
    input_thread_t *p_input = THEMIM->getInput();

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

712
void QVLCMenu::PopupPlayEntries( QMenu *menu,
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
713 714 715
                                        intf_thread_t *p_intf,
                                        input_thread_t *p_input )
{
716 717 718
    QAction *action;

    /* Play or Pause action and icon */
719 720
    if( !p_input || var_GetInteger( p_input, "state" ) != PLAYING_S )
    {
721
        action = menu->addAction( qtr( "Play" ),
722 723 724 725
                ActionsManager::getInstance( p_intf ), SLOT( play() ) );
        action->setIcon( QIcon( ":/play" ) );
    }
    else
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
726
    {
727
         addMIMStaticEntry( p_intf, menu, qtr( "Pause" ),
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
728
                    ":/pause", SLOT( togglePlayPause() ) );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
729
    }
730 731 732 733 734
}

void QVLCMenu::PopupMenuControlEntries( QMenu *menu, intf_thread_t *p_intf )
{
    QAction *action;
735 736

    /* Faster/Slower */
737
    action = menu->addAction( qtr( "&Faster" ), THEMIM->getIM(),
738
                              SLOT( faster() ) );
739
    action->setIcon( QIcon( ":/faster") );
740 741
    action->setData( true );

742 743 744 745
    action = menu->addAction( qtr( "Faster (fine)" ), THEMIM->getIM(),
                              SLOT( littlefaster() ) );
    action->setData( true );

746
    action = menu->addAction( qtr( "N&ormal Speed" ), THEMIM->getIM(),
747 748 749
                              SLOT( normalRate() ) );
    action->setData( true );

750 751 752 753
    action = menu->addAction( qtr( "Slower (fine)" ), THEMIM->getIM(),
                              SLOT( littleslower() ) );
    action->setData( true );

754
    action = menu->addAction( qtr( "Slo&wer" ), THEMIM->getIM(),
755
                              SLOT( slower() ) );
756
    action->setIcon( QIcon( ":/slower") );
757
    action->setData( true );
758 759

    menu->addSeparator();
760

761
    action = menu->addAction( qtr( "&Jump Forward" ), THEMIM->getIM(),
762 763
             SLOT( jumpFwd() ) );
    action->setIcon( QIcon( ":/skip_fw") );
764 765
    action->setData( true );

766
    action = menu->addAction( qtr( "Jump Bac&kward" ), THEMIM->getIM(),
767 768
             SLOT( jumpBwd() ) );
    action->setIcon( QIcon( ":/skip_back") );
769 770 771 772
    action->setData( true );
    addDPStaticEntry( menu, qtr( I_MENU_GOTOTIME ),"",
                      SLOT( gotoTimeDialog() ), "Ctrl+T" );
    menu->addSeparator();
773 774 775 776
}


void QVLCMenu::PopupMenuPlaylistControlEntries( QMenu *menu,
777
                                                intf_thread_t *p_intf )
778
{
779
    addMIMStaticEntry( p_intf, menu, qtr( "&Stop" ), ":/stop", SLOT( stop() ) );
780

781
    /* Next / Previous */
782
    addMIMStaticEntry( p_intf, menu, qtr( "Pre&vious" ),
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
783
            ":/previous", SLOT( prev() ) );
784
    addMIMStaticEntry( p_intf, menu, qtr( "Ne&xt" ),