]> git.sesse.net Git - vlc/blob - modules/gui/qt4/menus.cpp
dbf733659411a0ddf3e3939a31439bf2007a9177
[vlc] / modules / gui / qt4 / menus.cpp
1 /*****************************************************************************
2  * menus.cpp : Qt menus
3  *****************************************************************************
4  * Copyright © 2006-2009 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Clément Stenac <zorglub@videolan.org>
8  *          Jean-Baptiste Kempf <jb@videolan.org>
9  *          Jean-Philippe André <jpeg@videolan.org>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * ( at your option ) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24  *****************************************************************************/
25
26 /** \todo
27  * - Remove static currentGroup
28  */
29
30 #ifdef HAVE_CONFIG_H
31 # include "config.h"
32 #endif
33
34 #include <vlc_intf_strings.h>
35 #include <vlc_services_discovery.h>
36
37 #include "menus.hpp"
38
39 #include "main_interface.hpp"    /* View modifications */
40 #include "dialogs_provider.hpp"  /* Dialogs display */
41 #include "input_manager.hpp"     /* Input Management */
42 #include "recents.hpp"           /* Recent Items */
43
44 #include <QMenu>
45 #include <QMenuBar>
46 #include <QAction>
47 #include <QActionGroup>
48 #include <QSignalMapper>
49 #include <QSystemTrayIcon>
50 #include <QList>
51
52 /*
53   This file defines the main menus and the pop-up menu (right-click menu)
54   and the systray menu (in that order in the file)
55
56   There are 3 menus that have to be rebuilt everytime there are called:
57   Audio, Video, Navigation
58   3 functions are building those menus: AudioMenu, VideoMenu, NavigMenu
59   and 3 functions associated are collecting the objects :
60   InputAutoMenuBuilder, AudioAutoMenuBuilder, VideoAutoMenuBuilder.
61
62   A QSignalMapper decides when to rebuild those menus cf MenuFunc in the .hpp
63   Just before one of those menus are aboutToShow(), they are rebuild.
64   */
65
66 enum
67 {
68     ITEM_NORMAL,
69     ITEM_CHECK,
70     ITEM_RADIO
71 };
72
73 static QActionGroup *currentGroup;
74
75 /* HACK for minimalView to go around a Qt bug/feature
76  * that doesn't update the QAction checked state when QMenu is hidden */
77 QAction *QVLCMenu::minimalViewAction = NULL;
78
79 QMenu *QVLCMenu::recentsMenu = NULL;
80
81 /****************************************************************************
82  * Menu code helpers:
83  ****************************************************************************
84  * Add static entries to DP in menus
85  ***************************************************************************/
86 void addDPStaticEntry( QMenu *menu,
87                        const QString text,
88                        const char *icon,
89                        const char *member,
90                        const char *shortcut = NULL )
91 {
92     QAction *action = NULL;
93     if( !EMPTY_STR( icon ) > 0 )
94     {
95         if( !EMPTY_STR( shortcut ) > 0 )
96             action = menu->addAction( QIcon( icon ), text, THEDP,
97                                       member, qtr( shortcut ) );
98         else
99             action = menu->addAction( QIcon( icon ), text, THEDP, member );
100     }
101     else
102     {
103         if( !EMPTY_STR( shortcut ) > 0 )
104             action = menu->addAction( text, THEDP, member, qtr( shortcut ) );
105         else
106             action = menu->addAction( text, THEDP, member );
107     }
108     action->setData( true );
109 }
110
111 /**
112  * @brief Enable all static entries, disable the others
113  * @param enable if false, disable all entries
114  */
115 void EnableStaticEntries( QMenu *menu, bool enable = true )
116 {
117     if( !menu ) return;
118
119     QList< QAction* > actions = menu->actions();
120     for( int i = 0; i < actions.size(); ++i )
121     {
122         actions[i]->setEnabled( enable && actions[i]->data().toBool() );
123     }
124 }
125
126 /**
127  * \return Number of static entries
128  */
129 int DeleteNonStaticEntries( QMenu *menu )
130 {
131     int i_ret = 0;
132     if( !menu )
133         return VLC_EGENERIC;
134     QList< QAction* > actions = menu->actions();
135     for( int i = 0; i < actions.size(); ++i )
136     {
137         if( !actions[i]->data().toBool() )
138             delete actions[i];
139         else
140             i_ret++;
141     }
142     return i_ret;
143 }
144
145 /***
146  * Same for MIM
147  ***/
148 void addMIMStaticEntry( intf_thread_t *p_intf,
149                         QMenu *menu,
150                         const QString text,
151                         const char *icon,
152                         const char *member )
153 {
154     if( strlen( icon ) > 0 )
155     {
156         QAction *action = menu->addAction( text, THEMIM,  member );
157         action->setIcon( QIcon( icon ) );
158     }
159     else
160     {
161         menu->addAction( text, THEMIM, member );
162     }
163 }
164
165 /*****************************************************************************
166  * Definitions of variables for the dynamic menus
167  *****************************************************************************/
168 #define PUSH_VAR( var ) varnames.push_back( var ); \
169     objects.push_back( VLC_OBJECT(p_object) )
170
171 #define PUSH_INPUTVAR( var ) varnames.push_back( var ); \
172     objects.push_back( VLC_OBJECT(p_input) );
173
174 #define PUSH_SEPARATOR if( objects.size() != i_last_separator ) { \
175     objects.push_back( 0 ); varnames.push_back( "" ); \
176     i_last_separator = objects.size(); }
177
178 static int InputAutoMenuBuilder( input_thread_t *p_object,
179         vector<vlc_object_t *> &objects,
180         vector<const char *> &varnames )
181 {
182     PUSH_VAR( "bookmark" );
183     PUSH_VAR( "title" );
184     PUSH_VAR( "chapter" );
185     PUSH_VAR( "program" );
186     PUSH_VAR( "navigation" );
187     PUSH_VAR( "dvd_menus" );
188     return VLC_SUCCESS;
189 }
190
191 static int VideoAutoMenuBuilder( vout_thread_t *p_object,
192         input_thread_t *p_input,
193         vector<vlc_object_t *> &objects,
194         vector<const char *> &varnames )
195 {
196     PUSH_INPUTVAR( "video-es" );
197     PUSH_INPUTVAR( "spu-es" );
198     PUSH_VAR( "fullscreen" );
199     PUSH_VAR( "zoom" );
200     PUSH_VAR( "scaling" );
201     PUSH_VAR( "deinterlace" );
202     PUSH_VAR( "aspect-ratio" );
203     PUSH_VAR( "crop" );
204     PUSH_VAR( "video-on-top" );
205 #ifdef WIN32
206     PUSH_VAR( "directx-wallpaper" );
207 #endif
208     PUSH_VAR( "video-snapshot" );
209
210     /* Special case for postproc */
211     // FIXME
212     if( p_object )
213     {
214         /* p_object is the vout, so the decoder is our parent and the
215          * postproc filter one of the decoder's children */
216         vlc_object_t *p_dec = (vlc_object_t *)
217                               vlc_object_find( p_object, VLC_OBJECT_DECODER,
218                                                FIND_PARENT );
219         if( p_dec )
220         {
221             vlc_object_t *p_pp = (vlc_object_t *)
222                                  vlc_object_find_name( p_dec, "postproc",
223                                                        FIND_CHILD );
224             if( p_pp )
225             {
226                 vlc_object_t *p_object = p_pp;
227                 PUSH_VAR( "postproc-q" );
228                 vlc_object_release( p_pp );
229             }
230
231             vlc_object_release( p_dec );
232         }
233     }
234     return VLC_SUCCESS;
235 }
236
237 static int AudioAutoMenuBuilder( aout_instance_t *p_object,
238         input_thread_t *p_input,
239         vector<vlc_object_t *> &objects,
240         vector<const char *> &varnames )
241 {
242     PUSH_INPUTVAR( "audio-es" );
243     PUSH_VAR( "audio-device" );
244     PUSH_VAR( "audio-channels" );
245     PUSH_VAR( "visual" );
246     return VLC_SUCCESS;
247 }
248
249 static QAction * FindActionWithVar( QMenu *menu, const char *psz_var )
250 {
251     QList< QAction* > actions = menu->actions();
252     for( int i = 0; i < actions.size(); ++i )
253     {
254         if( actions[i]->data().toString() == psz_var )
255             return actions[i];
256     }
257     return NULL;
258 }
259
260 /*****************************************************************************
261  * All normal menus
262  * Simple Code
263  *****************************************************************************/
264
265 #define BAR_ADD( func, title ) { \
266     QMenu *_menu = func; _menu->setTitle( title ); bar->addMenu( _menu ); }
267
268 #define BAR_DADD( func, title, id ) { \
269     QMenu *_menu = func; _menu->setTitle( title ); bar->addMenu( _menu ); \
270     MenuFunc *f = new MenuFunc( _menu, id ); \
271     CONNECT( _menu, aboutToShow(), THEDP->menusUpdateMapper, map() ); \
272     THEDP->menusUpdateMapper->setMapping( _menu, f ); }
273
274 #define ACT_ADD( _menu, val, title ) { \
275     QAction *_action = new QAction( title, _menu ); _action->setData( val ); \
276     _menu->addAction( _action ); }
277
278 /**
279  * Main Menu Bar Creation
280  **/
281 void QVLCMenu::createMenuBar( MainInterface *mi,
282                               intf_thread_t *p_intf,
283                               bool visual_selector_enabled )
284 /* FIXME remove this visual dependency */
285 {
286     /* QMainWindows->menuBar()
287        gives the QProcess::destroyed timeout issue on Cleanlooks style with
288        setDesktopAware set to false */
289     QMenuBar *bar = mi->menuBar();
290     BAR_ADD( FileMenu( p_intf ), qtr( "&Media" ) );
291
292     BAR_DADD( AudioMenu( p_intf, NULL ), qtr( "&Audio" ), 1 );
293     BAR_DADD( VideoMenu( p_intf, NULL ), qtr( "&Video" ), 2 );
294     BAR_DADD( NavigMenu( p_intf, NULL ), qtr( "P&layback" ), 3 );
295
296     BAR_ADD( ToolsMenu( NULL ), qtr( "&Tools" ) );
297     BAR_ADD( ViewMenu( p_intf, NULL, mi, visual_selector_enabled, true ),
298              qtr( "V&iew" ) );
299
300     BAR_ADD( HelpMenu( NULL ), qtr( "&Help" ) );
301 }
302 #undef BAR_ADD
303 #undef BAR_DADD
304
305 /**
306  * Media ( File ) Menu
307  * Opening, streaming and quit
308  **/
309 QMenu *QVLCMenu::FileMenu( intf_thread_t *p_intf )
310 {
311     QMenu *menu = new QMenu();
312
313     addDPStaticEntry( menu, qtr( "&Open File..." ),
314         ":/file-asym", SLOT( simpleOpenDialog() ), "Ctrl+O" );
315     addDPStaticEntry( menu, qtr( "Advanced Open File..." ),
316         ":/file-asym", SLOT( openFileDialog() ), "Ctrl+Shift+O" );
317     addDPStaticEntry( menu, qtr( I_OPEN_FOLDER ),
318         ":/folder-grey", SLOT( PLOpenDir() ), "Ctrl+F" );
319     addDPStaticEntry( menu, qtr( "Open &Disc..." ),
320         ":/disc", SLOT( openDiscDialog() ), "Ctrl+D" );
321     addDPStaticEntry( menu, qtr( "Open &Network..." ),
322         ":/network", SLOT( openNetDialog() ), "Ctrl+N" );
323     addDPStaticEntry( menu, qtr( "Open &Capture Device..." ),
324         ":/capture-card", SLOT( openCaptureDialog() ),
325         "Ctrl+C" );
326
327     menu->addSeparator();
328     addDPStaticEntry( menu, qtr( "Paste &MRL" ),
329                       NULL, SLOT( openUrlDialog() ), "Ctrl+V" );
330
331     addDPStaticEntry( menu, qtr( I_PL_LOAD ), "", SLOT( openAPlaylist() ),
332         "Ctrl+X" );
333     addDPStaticEntry( menu, qtr( I_PL_SAVE ), "", SLOT( saveAPlaylist() ),
334         "Ctrl+Y" );
335
336     menu->addSeparator();
337
338     recentsMenu = new QMenu( qtr( "Recently &Played" ), menu );
339     updateRecents( p_intf );
340     menu->addMenu( recentsMenu );
341     menu->addSeparator();
342
343     addDPStaticEntry( menu, qtr( "Conve&rt / Save..." ), "",
344         SLOT( openAndTranscodingDialogs() ), "Ctrl+R" );
345     addDPStaticEntry( menu, qtr( "&Streaming..." ),
346         ":/stream", SLOT( openAndStreamingDialogs() ),
347         "Ctrl+S" );
348     menu->addSeparator();
349
350     addDPStaticEntry( menu, qtr( "&Quit" ) ,
351         ":/quit", SLOT( quit() ), "Ctrl+Q" );
352     return menu;
353 }
354
355 /* Playlist/MediaLibrary Control */
356 QMenu *QVLCMenu::ToolsMenu( QMenu *parent )
357 {
358     QMenu *menu;
359     if( parent == NULL )
360         menu = new QMenu();
361     else
362         menu = parent;
363     addDPStaticEntry( menu, qtr( I_MENU_EXT ), ":/settings",
364             SLOT( extendedDialog() ), "Ctrl+E" );
365
366     addDPStaticEntry( menu, qtr( I_MENU_INFO ) , ":/info",
367         SLOT( mediaInfoDialog() ), "Ctrl+I" );
368     addDPStaticEntry( menu, qtr( I_MENU_CODECINFO ) ,
369         ":/info", SLOT( mediaCodecDialog() ), "Ctrl+J" );
370
371     addDPStaticEntry( menu, qtr( I_MENU_BOOKMARK ),"",
372                       SLOT( bookmarksDialog() ), "Ctrl+B" );
373 #ifdef ENABLE_VLM
374     addDPStaticEntry( menu, qtr( I_MENU_VLM ), "", SLOT( vlmDialog() ),
375         "Ctrl+W" );
376 #endif
377
378     addDPStaticEntry( menu, qtr( I_MENU_MSG ),
379         ":/messages", SLOT( messagesDialog() ),
380         "Ctrl+M" );
381
382     addDPStaticEntry( menu, qtr( "Plu&gins and extensions" ),
383         "", SLOT( pluginDialog() ) );
384     menu->addSeparator();
385
386     addDPStaticEntry( menu, qtr( "&Preferences" ),
387         ":/preferences", SLOT( prefsDialog() ), "Ctrl+P" );
388
389     return menu;
390 }
391
392 /**
393  * View Menu
394  * This menu can be an interface menu but also a right click menu.
395  **/
396 QMenu *QVLCMenu::ViewMenu( intf_thread_t *p_intf,
397                             QMenu *current,
398                             MainInterface *mi,
399                             bool visual_selector_enabled,
400                             bool with_intf )
401 {
402     QMenu *menu = new QMenu( current );
403     QAction *act;
404     if( mi )
405     {
406         act = menu->addAction( QIcon( ":/playlist_menu" ),
407                                qtr( "Play&list" ), mi,
408                                SLOT( togglePlaylist() ), qtr( "Ctrl+L" ) );
409         act->setData( true );
410     }
411     act = menu->addMenu( SDMenu( p_intf ) );
412     act->setData( true );
413     /*menu->addSeparator();
414     menu->addAction( qtr( "Undock from Interface" ), mi,
415                      SLOT( undockPlaylist() ), qtr( "Ctrl+U" ) );*/
416
417
418     menu->addSeparator();
419
420     if( with_intf )
421     {
422         QMenu *intfmenu = InterfacesMenu( p_intf, menu );
423         MenuFunc *f = new MenuFunc( intfmenu, 4 );
424         CONNECT( intfmenu, aboutToShow(), THEDP->menusUpdateMapper, map() );
425         THEDP->menusUpdateMapper->setMapping( intfmenu, f );
426         menu->addSeparator();
427     }
428     if( mi )
429     {
430         /* Minimal View */
431         QAction *action = menu->addAction( qtr( "Mi&nimal View" ), mi,
432                                 SLOT( toggleMinimalView() ), qtr( "Ctrl+H" ) );
433         action->setCheckable( true );
434         action->setData( true );
435         if( mi->getControlsVisibilityStatus() & CONTROLS_VISIBLE )
436             action->setChecked( true );
437         minimalViewAction = action; /* HACK for minimalView */
438
439         /* FullScreen View */
440         action = menu->addAction( qtr( "&Fullscreen Interface" ), mi,
441                                   SLOT( toggleFullScreen() ), QString( "F11" ) );
442         action->setCheckable( true );
443         action->setData( true );
444
445         /* Advanced Controls */
446         action = menu->addAction( qtr( "&Advanced Controls" ), mi,
447                                   SLOT( toggleAdvanced() ) );
448         action->setCheckable( true );
449         action->setData( true );
450         if( mi->getControlsVisibilityStatus() & CONTROLS_ADVANCED )
451             action->setChecked( true );
452 #if 0 /* For Visualisations. Not yet working */
453         adv = menu->addAction( qtr( "Visualizations selector" ),
454                 mi, SLOT( visual() ) );
455         adv->setCheckable( true );
456         if( visual_selector_enabled ) adv->setChecked( true );
457 #endif
458     }
459
460     menu->addSeparator();
461     addDPStaticEntry( menu, qtr( "Customi&ze Interface..." ),
462         ":/preferences", SLOT( toolbarDialog() ) );
463     menu->addSeparator();
464
465     return menu;
466 }
467
468 /**
469  * Interface Sub-Menu, to list extras interface and skins
470  **/
471 QMenu *QVLCMenu::InterfacesMenu( intf_thread_t *p_intf, QMenu *current )
472 {
473     vector<vlc_object_t *> objects;
474     vector<const char *> varnames;
475     /** \todo add "switch to XXX" */
476     varnames.push_back( "intf-add" );
477     objects.push_back( VLC_OBJECT(p_intf) );
478
479     return Populate( p_intf, current, varnames, objects );
480 }
481
482 /**
483  * Main Audio Menu
484  */
485 QMenu *QVLCMenu::AudioMenu( intf_thread_t *p_intf, QMenu * current )
486 {
487     vector<vlc_object_t *> objects;
488     vector<const char *> varnames;
489     aout_instance_t *p_aout;
490     input_thread_t *p_input;
491
492     if( !current ) current = new QMenu();
493
494     if( current->isEmpty() )
495     {
496         ACT_ADD( current, "audio-es", qtr( "Audio &Track" ) );
497         ACT_ADD( current, "audio-device", qtr( "Audio &Device" ) );
498         ACT_ADD( current, "audio-channels", qtr( "Audio &Channels" ) );
499         current->addSeparator();
500         ACT_ADD( current, "visual", qtr( "&Visualizations" ) );
501     }
502
503     p_input = THEMIM->getInput();
504     if( p_input )
505         vlc_object_hold( p_input );
506     p_aout = THEMIM->getAout();
507     AudioAutoMenuBuilder( p_aout, p_input, objects, varnames );
508     EnableStaticEntries( current, ( p_aout != NULL ) );
509     if( p_aout )
510     {
511         vlc_object_release( p_aout );
512     }
513     if( p_input )
514         vlc_object_release( p_input );
515
516     return Populate( p_intf, current, varnames, objects );
517 }
518
519 /**
520  * Main Video Menu
521  * Subtitles are part of Video.
522  **/
523 QMenu *QVLCMenu::VideoMenu( intf_thread_t *p_intf, QMenu *current )
524 {
525     vout_thread_t *p_vout;
526     input_thread_t *p_input;
527     vector<vlc_object_t *> objects;
528     vector<const char *> varnames;
529
530     if( !current ) current = new QMenu();
531
532     if( current->isEmpty() )
533     {
534         ACT_ADD( current, "video-es", qtr( "Video &Track" ) );
535
536         QAction *action;
537         QMenu *submenu = new QMenu( qtr( "&Subtitles Track" ), current );
538         action = current->addMenu( submenu );
539         action->setData( "spu-es" );
540         addDPStaticEntry( submenu, qtr( "Open File..." ), "",
541                           SLOT( loadSubtitlesFile() ) );
542         submenu->addSeparator();
543
544         ACT_ADD( current, "fullscreen", qtr( "&Fullscreen" ) );
545         ACT_ADD( current, "zoom", qtr( "&Zoom" ) );
546         ACT_ADD( current, "deinterlace", qtr( "&Deinterlace" ) );
547         ACT_ADD( current, "aspect-ratio", qtr( "&Aspect Ratio" ) );
548         ACT_ADD( current, "crop", qtr( "&Crop" ) );
549         ACT_ADD( current, "video-on-top", qtr( "Always &On Top" ) );
550 #ifdef WIN32
551         ACT_ADD( current, "directx-wallpaper", qtr( "DirectX Wallpaper" ) );
552 #endif
553         ACT_ADD( current, "video-snapshot", qtr( "Sna&pshot" ) );
554         ACT_ADD( current, "postproc-q", qtr( "Post processing" ) );
555     }
556
557     p_input = THEMIM->getInput();
558     if( p_input )
559         vlc_object_hold( p_input );
560
561     p_vout = THEMIM->getVout();
562     VideoAutoMenuBuilder( p_vout, p_input, objects, varnames );
563     EnableStaticEntries( current, ( p_vout != NULL ) );
564     if( p_vout )
565     {
566         vlc_object_release( p_vout );
567     }
568     if( p_input )
569         vlc_object_release( p_input );
570
571     return Populate( p_intf, current, varnames, objects );
572 }
573
574 /**
575  * Navigation Menu
576  * For DVD, MP4, MOV and other chapter based format
577  **/
578 QMenu *QVLCMenu::NavigMenu( intf_thread_t *p_intf, QMenu *menu )
579 {
580     if( !menu ) menu = new QMenu();
581
582     if( menu->isEmpty() )
583     {
584         addDPStaticEntry( menu, qtr( I_MENU_GOTOTIME ),"",
585                           SLOT( gotoTimeDialog() ), "Ctrl+T" );
586         menu->addSeparator();
587
588         ACT_ADD( menu, "bookmark", qtr( "&Bookmarks" ) );
589         ACT_ADD( menu, "title", qtr( "T&itle" ) );
590         ACT_ADD( menu, "chapter", qtr( "&Chapter" ) );
591         ACT_ADD( menu, "program", qtr( "&Program" ) );
592         ACT_ADD( menu, "navigation", qtr( "&Navigation" ) );
593     }
594
595     input_thread_t *p_object;
596     vector<vlc_object_t *> objects;
597     vector<const char *> varnames;
598
599     p_object = THEMIM->getInput();
600     if( p_object )
601         vlc_object_hold( p_object );
602     InputAutoMenuBuilder( p_object, objects, varnames );
603     PUSH_VAR( "prev-title" );
604     PUSH_VAR( "next-title" );
605     PUSH_VAR( "prev-chapter" );
606     PUSH_VAR( "next-chapter" );
607     EnableStaticEntries( menu, ( p_object != NULL ) );
608     if( p_object )
609     {
610         vlc_object_release( p_object );
611     }
612     return Populate( p_intf, menu, varnames, objects );
613 }
614
615 /**
616  * Service Discovery SubMenu
617  **/
618 QMenu *QVLCMenu::SDMenu( intf_thread_t *p_intf )
619 {
620     QMenu *menu = new QMenu();
621     menu->setTitle( qtr( I_PL_SD ) );
622     char **ppsz_longnames;
623     char **ppsz_names = vlc_sd_GetNames( &ppsz_longnames );
624     if( !ppsz_names )
625         return menu;
626
627     char **ppsz_name = ppsz_names, **ppsz_longname = ppsz_longnames;
628     for( ; *ppsz_name; ppsz_name++, ppsz_longname++ )
629     {
630         QAction *a = new QAction( qfu( *ppsz_longname ), menu );
631         a->setCheckable( true );
632         if( playlist_IsServicesDiscoveryLoaded( THEPL, *ppsz_name ) )
633             a->setChecked( true );
634         CONNECT( a , triggered(), THEDP->SDMapper, map() );
635         THEDP->SDMapper->setMapping( a, QString( *ppsz_name ) );
636         menu->addAction( a );
637
638         if( !strcmp( *ppsz_name, "podcast" ) )
639         {
640             QAction *b = new QAction( qtr( "Configure podcasts..." ), menu );
641             //b->setEnabled( a->isChecked() );
642             menu->addAction( b );
643             CONNECT( b, triggered(), THEDP, podcastConfigureDialog() );
644         }
645         free( *ppsz_name );
646         free( *ppsz_longname );
647     }
648     free( ppsz_names );
649     free( ppsz_longnames );
650     return menu;
651 }
652 /**
653  * Help/About Menu
654 **/
655 QMenu *QVLCMenu::HelpMenu( QMenu *current )
656 {
657     QMenu *menu = new QMenu( current );
658     addDPStaticEntry( menu, qtr( "&Help..." ) ,
659         ":/help", SLOT( helpDialog() ), "F1" );
660 #ifdef UPDATE_CHECK
661     addDPStaticEntry( menu, qtr( "Check for &Updates..." ) , "",
662                       SLOT( updateDialog() ) );
663 #endif
664     menu->addSeparator();
665     addDPStaticEntry( menu, qtr( I_MENU_ABOUT ), ":/info",
666             SLOT( aboutDialog() ), "Shift+F1" );
667     return menu;
668 }
669
670 /*****************************************************************************
671  * Popup menus - Right Click menus                                           *
672  *****************************************************************************/
673 #define POPUP_BOILERPLATE \
674     unsigned int i_last_separator = 0; \
675     vector<vlc_object_t *> objects; \
676     vector<const char *> varnames; \
677     input_thread_t *p_input = THEMIM->getInput();
678
679 #define CREATE_POPUP \
680     Populate( p_intf, menu, varnames, objects ); \
681     p_intf->p_sys->p_popup_menu = menu; \
682     menu->popup( QCursor::pos() ); \
683     p_intf->p_sys->p_popup_menu = NULL; \
684     i_last_separator = 0;
685
686 void QVLCMenu::PopupMenuControlEntries( QMenu *menu,
687                                         intf_thread_t *p_intf,
688                                         input_thread_t *p_input )
689 {
690     if( p_input )
691     {
692         vlc_value_t val;
693         var_Get( p_input, "state", &val );
694         if( val.i_int == PLAYING_S )
695             addMIMStaticEntry( p_intf, menu, qtr( "Pause" ),
696                     ":/pause", SLOT( togglePlayPause() ) );
697         else
698             addMIMStaticEntry( p_intf, menu, qtr( "Play" ),
699                     ":/play", SLOT( togglePlayPause() ) );
700     }
701     else if( THEPL->items.i_size )
702         addMIMStaticEntry( p_intf, menu, qtr( "Play" ),
703                 ":/play", SLOT( togglePlayPause() ) );
704     else
705         addDPStaticEntry( menu, qtr( "Play" ),
706                 ":/play", SLOT( openDialog() ) );
707
708     addMIMStaticEntry( p_intf, menu, qtr( "Stop" ),
709             ":/stop", SLOT( stop() ) );
710     addMIMStaticEntry( p_intf, menu, qtr( "Previous" ),
711             ":/previous", SLOT( prev() ) );
712     addMIMStaticEntry( p_intf, menu, qtr( "Next" ),
713             ":/next", SLOT( next() ) );
714 }
715
716 void QVLCMenu::PopupMenuStaticEntries( QMenu *menu )
717 {
718     QMenu *openmenu = new QMenu( qtr( "Open Media" ), menu );
719     addDPStaticEntry( openmenu, qtr( "&Open File..." ),
720         ":/file-asym", SLOT( openFileDialog() ) );
721     addDPStaticEntry( openmenu, qtr( I_OPEN_FOLDER ),
722         ":/folder-grey", SLOT( PLOpenDir() ) );
723     addDPStaticEntry( openmenu, qtr( "Open &Disc..." ),
724         ":/disc", SLOT( openDiscDialog() ) );
725     addDPStaticEntry( openmenu, qtr( "Open &Network..." ),
726         ":/network", SLOT( openNetDialog() ) );
727     addDPStaticEntry( openmenu, qtr( "Open &Capture Device..." ),
728         ":/capture-card", SLOT( openCaptureDialog() ) );
729     menu->addMenu( openmenu );
730
731     menu->addSeparator();
732 #if 0
733     QMenu *helpmenu = HelpMenu( menu );
734     helpmenu->setTitle( qtr( "Help" ) );
735     menu->addMenu( helpmenu );
736 #endif
737
738     addDPStaticEntry( menu, qtr( "Quit" ), ":/quit",
739                       SLOT( quit() ), "Ctrl+Q" );
740 }
741
742 /* Video Tracks and Subtitles tracks */
743 void QVLCMenu::VideoPopupMenu( intf_thread_t *p_intf )
744 {
745     POPUP_BOILERPLATE;
746     if( p_input )
747     {
748         vlc_object_hold( p_input );
749         vout_thread_t *p_vout = THEMIM->getVout();
750         if( p_vout )
751         {
752             VideoAutoMenuBuilder( p_vout, p_input, objects, varnames );
753             vlc_object_release( p_vout );
754         }
755         vlc_object_release( p_input );
756     }
757     QMenu *menu = new QMenu();
758     CREATE_POPUP;
759 }
760
761 /* Audio Tracks */
762 void QVLCMenu::AudioPopupMenu( intf_thread_t *p_intf )
763 {
764     POPUP_BOILERPLATE;
765     if( p_input )
766     {
767         vlc_object_hold( p_input );
768         aout_instance_t *p_aout = THEMIM->getAout();
769         AudioAutoMenuBuilder( p_aout, p_input, objects, varnames );
770         if( p_aout )
771             vlc_object_release( p_aout );
772         vlc_object_release( p_input );
773     }
774     QMenu *menu = new QMenu();
775     CREATE_POPUP;
776 }
777
778 /* Navigation stuff, and general menus ( open ) */
779 void QVLCMenu::MiscPopupMenu( intf_thread_t *p_intf )
780 {
781     POPUP_BOILERPLATE;
782
783     if( p_input )
784     {
785         vlc_object_hold( p_input );
786         varnames.push_back( "audio-es" );
787         InputAutoMenuBuilder( p_input, objects, varnames );
788         PUSH_SEPARATOR;
789     }
790
791     QMenu *menu = new QMenu();
792     Populate( p_intf, menu, varnames, objects );
793
794     menu->addSeparator();
795     PopupMenuControlEntries( menu, p_intf, p_input );
796
797     menu->addSeparator();
798     PopupMenuStaticEntries( menu );
799
800     p_intf->p_sys->p_popup_menu = menu;
801     menu->popup( QCursor::pos() );
802     p_intf->p_sys->p_popup_menu = NULL;
803 }
804
805 /* Main Menu that sticks everything together  */
806 void QVLCMenu::PopupMenu( intf_thread_t *p_intf, bool show )
807 {
808     MainInterface *mi = p_intf->p_sys->p_mi;
809     if( show )
810     {
811         /* Delete and recreate a popup if there is one */
812         if( p_intf->p_sys->p_popup_menu )
813             delete p_intf->p_sys->p_popup_menu;
814
815         QMenu *menu = new QMenu();
816         QMenu *submenu;
817         QAction *action;
818         bool b_isFullscreen = false;
819
820         POPUP_BOILERPLATE;
821
822         PopupMenuControlEntries( menu, p_intf, p_input );
823         menu->addSeparator();
824
825         if( p_input )
826         {
827             vout_thread_t *p_vout = THEMIM->getVout();
828
829             /* Add a fullscreen switch button */
830             if( p_vout )
831             {
832                 vlc_value_t val;
833                 var_Get( p_vout, "fullscreen", &val );
834                 b_isFullscreen = !( !val.b_bool );
835                 if( b_isFullscreen )
836                     CreateAndConnect( menu, "fullscreen",
837                             qtr( "Leave Fullscreen" ),"" , ITEM_NORMAL,
838                             VLC_OBJECT(p_vout), val, VLC_VAR_BOOL,
839                             b_isFullscreen );
840                 vlc_object_release( p_vout );
841             }
842
843             menu->addSeparator();
844
845             vlc_object_hold( p_input );
846             InputAutoMenuBuilder( p_input, objects, varnames );
847             vlc_object_release( p_input );
848
849             submenu = new QMenu( menu );
850             action = menu->addMenu( AudioMenu( p_intf, submenu ) );
851             action->setText( qtr( "&Audio" ) );
852             if( action->menu()->isEmpty() )
853                 action->setEnabled( false );
854
855             submenu = new QMenu( menu );
856             action = menu->addMenu( VideoMenu( p_intf, submenu ) );
857             action->setText( qtr( "&Video" ) );
858             if( action->menu()->isEmpty() )
859                 action->setEnabled( false );
860
861             submenu = new QMenu( menu );
862             action = menu->addMenu( NavigMenu( p_intf, submenu ) );
863             action->setText( qtr( "&Playback" ) );
864             if( action->menu()->isEmpty() )
865                 action->setEnabled( false );
866         }
867
868         menu->addSeparator();
869
870         /* Add some special entries for windowed mode: Interface Menu */
871         if( !b_isFullscreen )
872         {
873             submenu = new QMenu( qtr( "Interface" ), menu );
874             if( mi )
875             {
876                 submenu->addAction( QIcon( ":/playlist" ),
877                          qtr( "Show Playlist" ), mi, SLOT( togglePlaylist() ) );
878                 action = submenu->addAction( QIcon( "" ),
879                      qtr( "Minimal View" ), mi, SLOT( toggleMinimalView() ) );
880                 action->setCheckable( true );
881                 action->setChecked( !( mi->getControlsVisibilityStatus() &
882                             CONTROLS_VISIBLE ) );
883                 action = submenu->addAction( QIcon( "" ),
884                         qtr( "Toggle Fullscreen Interface" ),
885                         mi, SLOT( toggleFullScreen() ) );
886                 action->setCheckable( true );
887                 action->setChecked( mi->isFullScreen() );
888             }
889             else /* We are using the skins interface.
890                     If not, this entry will not show. */
891             {
892
893                 QMenu *tools = ToolsMenu( submenu );
894                 submenu->addSeparator();
895                 objects.clear();
896                 varnames.clear();
897                 vlc_object_t *p_object = ( vlc_object_t* )
898                      vlc_object_find_name( p_intf, "skins2", FIND_PARENT );
899                 if( p_object )
900                 {
901                     objects.push_back( p_object );
902                     varnames.push_back( "intf-skins" );
903                     Populate( p_intf, submenu, varnames, objects );
904                     vlc_object_release( p_object );
905                 }
906                 else
907                 {
908                     msg_Dbg( p_intf, "could not find parent interface" );
909                 }
910             }
911             menu->addMenu( submenu );
912         }
913
914         PopupMenuStaticEntries( menu );
915
916         p_intf->p_sys->p_popup_menu = menu;
917         p_intf->p_sys->p_popup_menu->popup( QCursor::pos() );
918     }
919     else
920     {
921         // destroy popup if there is one
922         delete p_intf->p_sys->p_popup_menu;
923         p_intf->p_sys->p_popup_menu = NULL;
924     }
925 }
926
927 #undef ACT_ADD
928
929 /************************************************************************
930  * Systray Menu                                                         *
931  ************************************************************************/
932
933 void QVLCMenu::updateSystrayMenu( MainInterface *mi,
934                                   intf_thread_t *p_intf,
935                                   bool b_force_visible )
936 {
937     POPUP_BOILERPLATE;
938
939     /* Get the systray menu and clean it */
940     QMenu *sysMenu = mi->getSysTrayMenu();
941     sysMenu->clear();
942
943     /* Hide / Show VLC and cone */
944     if( mi->isVisible() || b_force_visible )
945     {
946         sysMenu->addAction( QIcon( ":/vlc16.png" ),
947                             qtr( "Hide VLC media player in taskbar" ), mi,
948                             SLOT( toggleUpdateSystrayMenu() ) );
949     }
950     else
951     {
952         sysMenu->addAction( QIcon( ":/vlc16.png" ),
953                             qtr( "Show VLC media player" ), mi,
954                             SLOT( toggleUpdateSystrayMenu() ) );
955     }
956
957     sysMenu->addSeparator();
958     PopupMenuControlEntries( sysMenu, p_intf, p_input );
959
960     sysMenu->addSeparator();
961     addDPStaticEntry( sysMenu, qtr( "&Open Media" ),
962             ":/file-wide", SLOT( openFileDialog() ) );
963     addDPStaticEntry( sysMenu, qtr( "&Quit" ) ,
964             ":/quit", SLOT( quit() ) );
965
966     /* Set the menu */
967     mi->getSysTray()->setContextMenu( sysMenu );
968 }
969
970 #undef PUSH_VAR
971 #undef PUSH_SEPARATOR
972
973 /*************************************************************************
974  * Builders for automenus
975  *************************************************************************/
976 QMenu * QVLCMenu::Populate( intf_thread_t *p_intf,
977                             QMenu *current,
978                             vector< const char *> & varnames,
979                             vector<vlc_object_t *> & objects )
980 {
981     QMenu *menu = current;
982     if( !menu ) menu = new QMenu();
983
984     currentGroup = NULL;
985
986     vlc_object_t *p_object;
987
988     for( int i = 0; i < ( int )objects.size() ; i++ )
989     {
990         if( !varnames[i] || !*varnames[i] )
991         {
992             menu->addSeparator();
993             continue;
994         }
995         p_object = objects[i];
996
997         UpdateItem( p_intf, menu, varnames[i], p_object, true );
998     }
999     return menu;
1000 }
1001
1002 /*****************************************************************************
1003  * Private methods.
1004  *****************************************************************************/
1005
1006 static bool IsMenuEmpty( const char *psz_var,
1007                          vlc_object_t *p_object,
1008                          bool b_root = true )
1009 {
1010     vlc_value_t val, val_list;
1011     int i_type, i_result, i;
1012
1013     /* Check the type of the object variable */
1014     i_type = var_Type( p_object, psz_var );
1015
1016     /* Check if we want to display the variable */
1017     if( !( i_type & VLC_VAR_HASCHOICE ) ) return false;
1018
1019     var_Change( p_object, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL );
1020     if( val.i_int == 0 ) return true;
1021
1022     if( ( i_type & VLC_VAR_TYPE ) != VLC_VAR_VARIABLE )
1023     {
1024         if( val.i_int == 1 && b_root ) return true;
1025         else return false;
1026     }
1027
1028     /* Check children variables in case of VLC_VAR_VARIABLE */
1029     if( var_Change( p_object, psz_var, VLC_VAR_GETLIST, &val_list, NULL ) < 0 )
1030     {
1031         return true;
1032     }
1033
1034     for( i = 0, i_result = true; i < val_list.p_list->i_count; i++ )
1035     {
1036         if( !IsMenuEmpty( val_list.p_list->p_values[i].psz_string,
1037                     p_object, false ) )
1038         {
1039             i_result = false;
1040             break;
1041         }
1042     }
1043
1044     /* clean up everything */
1045     var_Change( p_object, psz_var, VLC_VAR_FREELIST, &val_list, NULL );
1046
1047     return i_result;
1048 }
1049
1050 #define TEXT_OR_VAR qfu ( text.psz_string ? text.psz_string : psz_var )
1051
1052 void QVLCMenu::UpdateItem( intf_thread_t *p_intf, QMenu *menu,
1053         const char *psz_var, vlc_object_t *p_object, bool b_submenu )
1054 {
1055     vlc_value_t val, text;
1056     int i_type;
1057
1058     QAction *action = FindActionWithVar( menu, psz_var );
1059     if( action )
1060         DeleteNonStaticEntries( action->menu() );
1061
1062     if( !p_object )
1063     {
1064         if( action )
1065             action->setEnabled( false );
1066         return;
1067     }
1068
1069     /* Check the type of the object variable */
1070     /* What is the following HACK needed for? */
1071     if( !strcmp( psz_var, "audio-es" )
1072      || !strcmp( psz_var, "video-es" )
1073      || !strcmp( psz_var, "postproc-q" ) )
1074         i_type = VLC_VAR_INTEGER | VLC_VAR_HASCHOICE;
1075     else
1076         i_type = var_Type( p_object, psz_var );
1077
1078     switch( i_type & VLC_VAR_TYPE )
1079     {
1080         case VLC_VAR_VOID:
1081         case VLC_VAR_BOOL:
1082         case VLC_VAR_VARIABLE:
1083         case VLC_VAR_STRING:
1084         case VLC_VAR_INTEGER:
1085         case VLC_VAR_FLOAT:
1086             break;
1087         default:
1088             /* Variable doesn't exist or isn't handled */
1089             if( action )
1090                 action->setEnabled( false );
1091             return;
1092     }
1093
1094     /* Make sure we want to display the variable */
1095     if( menu->isEmpty() && IsMenuEmpty( psz_var, p_object ) )
1096     {
1097         if( action )
1098             action->setEnabled( false );
1099         return;
1100     }
1101
1102     /* Get the descriptive name of the variable */
1103     int i_ret = var_Change( p_object, psz_var, VLC_VAR_GETTEXT, &text, NULL );
1104     if( i_ret != VLC_SUCCESS )
1105     {
1106         text.psz_string = NULL;
1107     }
1108
1109     if( !action )
1110     {
1111         action = new QAction( TEXT_OR_VAR, menu );
1112         menu->addAction( action );
1113         action->setData( psz_var );
1114     }
1115
1116     /* Some specific stuff */
1117     bool forceDisabled = false;
1118     if( !strcmp( psz_var, "spu-es" ) )
1119     {
1120         vout_thread_t *p_vout = THEMIM->getVout();
1121         forceDisabled = ( p_vout == NULL );
1122         if( p_vout )
1123             vlc_object_release( p_vout );
1124     }
1125
1126     if( i_type & VLC_VAR_HASCHOICE )
1127     {
1128         /* Append choices menu */
1129         if( b_submenu )
1130         {
1131             QMenu *submenu;
1132             submenu = action->menu();
1133             if( !submenu )
1134             {
1135                 submenu = new QMenu( menu );
1136                 action->setMenu( submenu );
1137             }
1138
1139             action->setEnabled(
1140                CreateChoicesMenu( submenu, psz_var, p_object, true ) == 0 );
1141             if( forceDisabled )
1142                 action->setEnabled( false );
1143         }
1144         else
1145             action->setEnabled(
1146                 CreateChoicesMenu( menu, psz_var, p_object, true ) == 0 );
1147         FREENULL( text.psz_string );
1148         return;
1149     }
1150
1151     switch( i_type & VLC_VAR_TYPE )
1152     {
1153         case VLC_VAR_VOID:
1154             var_Get( p_object, psz_var, &val );
1155             CreateAndConnect( menu, psz_var, TEXT_OR_VAR, "", ITEM_NORMAL,
1156                     p_object, val, i_type );
1157             break;
1158
1159         case VLC_VAR_BOOL:
1160             var_Get( p_object, psz_var, &val );
1161             val.b_bool = !val.b_bool;
1162             CreateAndConnect( menu, psz_var, TEXT_OR_VAR, "", ITEM_CHECK,
1163                     p_object, val, i_type, !val.b_bool );
1164             break;
1165     }
1166     FREENULL( text.psz_string );
1167 }
1168
1169
1170 int QVLCMenu::CreateChoicesMenu( QMenu *submenu, const char *psz_var,
1171         vlc_object_t *p_object, bool b_root )
1172 {
1173     vlc_value_t val, val_list, text_list;
1174     int i_type, i;
1175
1176     /* Check the type of the object variable */
1177     i_type = var_Type( p_object, psz_var );
1178
1179     /* Make sure we want to display the variable */
1180     if( submenu->isEmpty() && IsMenuEmpty( psz_var, p_object, b_root ) )
1181         return VLC_EGENERIC;
1182
1183     switch( i_type & VLC_VAR_TYPE )
1184     {
1185         case VLC_VAR_VOID:
1186         case VLC_VAR_BOOL:
1187         case VLC_VAR_VARIABLE:
1188         case VLC_VAR_STRING:
1189         case VLC_VAR_INTEGER:
1190         case VLC_VAR_FLOAT:
1191             break;
1192         default:
1193             /* Variable doesn't exist or isn't handled */
1194             return VLC_EGENERIC;
1195     }
1196
1197     if( var_Change( p_object, psz_var, VLC_VAR_GETLIST,
1198                     &val_list, &text_list ) < 0 )
1199     {
1200         return VLC_EGENERIC;
1201     }
1202
1203 #define CURVAL val_list.p_list->p_values[i]
1204 #define CURTEXT text_list.p_list->p_values[i].psz_string
1205
1206     for( i = 0; i < val_list.p_list->i_count; i++ )
1207     {
1208         vlc_value_t another_val;
1209         QString menutext;
1210         QMenu *subsubmenu = new QMenu( submenu );
1211
1212         switch( i_type & VLC_VAR_TYPE )
1213         {
1214             case VLC_VAR_VARIABLE:
1215                 CreateChoicesMenu( subsubmenu, CURVAL.psz_string, p_object, false );
1216                 subsubmenu->setTitle( qfu( CURTEXT ? CURTEXT :CURVAL.psz_string ) );
1217                 submenu->addMenu( subsubmenu );
1218                 break;
1219
1220             case VLC_VAR_STRING:
1221                 var_Get( p_object, psz_var, &val );
1222                 another_val.psz_string = strdup( CURVAL.psz_string );
1223                 menutext = qfu( CURTEXT ? CURTEXT : another_val.psz_string );
1224                 CreateAndConnect( submenu, psz_var, menutext, "", ITEM_RADIO,
1225                         p_object, another_val, i_type,
1226                         val.psz_string && !strcmp( val.psz_string, CURVAL.psz_string ) );
1227
1228                 free( val.psz_string );
1229                 break;
1230
1231             case VLC_VAR_INTEGER:
1232                 var_Get( p_object, psz_var, &val );
1233                 if( CURTEXT ) menutext = qfu( CURTEXT );
1234                 else menutext.sprintf( "%d", CURVAL.i_int );
1235                 CreateAndConnect( submenu, psz_var, menutext, "", ITEM_RADIO,
1236                         p_object, CURVAL, i_type,
1237                         CURVAL.i_int == val.i_int );
1238                 break;
1239
1240             case VLC_VAR_FLOAT:
1241                 var_Get( p_object, psz_var, &val );
1242                 if( CURTEXT ) menutext = qfu( CURTEXT );
1243                 else menutext.sprintf( "%.2f", CURVAL.f_float );
1244                 CreateAndConnect( submenu, psz_var, menutext, "", ITEM_RADIO,
1245                         p_object, CURVAL, i_type,
1246                         CURVAL.f_float == val.f_float );
1247                 break;
1248
1249             default:
1250                 break;
1251         }
1252     }
1253     currentGroup = NULL;
1254
1255     /* clean up everything */
1256     var_Change( p_object, psz_var, VLC_VAR_FREELIST, &val_list, &text_list );
1257
1258 #undef CURVAL
1259 #undef CURTEXT
1260     return submenu->isEmpty() ? VLC_EGENERIC : VLC_SUCCESS;
1261 }
1262
1263 void QVLCMenu::CreateAndConnect( QMenu *menu, const char *psz_var,
1264         QString text, QString help,
1265         int i_item_type, vlc_object_t *p_obj,
1266         vlc_value_t val, int i_val_type,
1267         bool checked )
1268 {
1269     QAction *action = FindActionWithVar( menu, psz_var );
1270     if( !action )
1271     {
1272         action = new QAction( text, menu );
1273         menu->addAction( action );
1274     }
1275
1276     action->setToolTip( help );
1277     action->setEnabled( p_obj != NULL );
1278
1279     if( i_item_type == ITEM_CHECK )
1280     {
1281         action->setCheckable( true );
1282     }
1283     else if( i_item_type == ITEM_RADIO )
1284     {
1285         action->setCheckable( true );
1286         if( !currentGroup )
1287             currentGroup = new QActionGroup( menu );
1288         currentGroup->addAction( action );
1289     }
1290
1291     action->setChecked( checked );
1292
1293     MenuItemData *itemData = new MenuItemData( THEDP->menusMapper, p_obj, i_val_type,
1294             val, psz_var );
1295     CONNECT( action, triggered(), THEDP->menusMapper, map() );
1296     THEDP->menusMapper->setMapping( action, itemData );
1297     menu->addAction( action );
1298 }
1299
1300 void QVLCMenu::DoAction( QObject *data )
1301 {
1302     MenuItemData *itemData = qobject_cast<MenuItemData *>( data );
1303     vlc_object_t *p_object = itemData->p_obj;
1304     if( p_object == NULL ) return;
1305
1306     var_Set( p_object, itemData->psz_var, itemData->val );
1307 }
1308
1309 void QVLCMenu::updateRecents( intf_thread_t *p_intf )
1310 {
1311     if (recentsMenu)
1312     {
1313         QAction* action;
1314         RecentsMRL* rmrl = RecentsMRL::getInstance( p_intf );
1315         QList<QString> l = rmrl->recents();
1316
1317         recentsMenu->clear();
1318         if( !l.size() )
1319         {
1320             action = recentsMenu->addAction( qtr(" - Empty - ") );
1321             action->setEnabled( false );
1322         }
1323         else
1324         {
1325             for( int i = 0; i < l.size(); ++i )
1326             {
1327                 action = recentsMenu->addAction(
1328                         QString( "&%1: " ).arg( i + 1 ) + l.at( i ),
1329                         rmrl->signalMapper,
1330                         SLOT( map() ) );
1331                 rmrl->signalMapper->setMapping( action, l.at( i ) );
1332             }
1333
1334             recentsMenu->addSeparator();
1335             recentsMenu->addAction( qtr("&Clear"), rmrl, SLOT( clear() ) );
1336         }
1337     }
1338 }