Qt: plugins dialog as a toggle one.
[vlc.git] / modules / gui / qt4 / dialogs_provider.cpp
1 /*****************************************************************************
2  * dialogs_provider.cpp : Dialog Provider
3  *****************************************************************************
4  * Copyright (C) 2006-2009 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *          Jean-Baptiste Kempf <jb@videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #ifdef HAVE_CONFIG_H
26 # include "config.h"
27 #endif
28
29 #include <vlc_intf_strings.h>
30
31 #include "qt4.hpp"
32 #include "dialogs_provider.hpp"
33 #include "input_manager.hpp" /* Load Subtitles */
34 #include "menus.hpp"
35 #include "recents.hpp"
36 #include "util/qt_dirs.hpp"
37
38 /* The dialogs */
39 #include "dialogs/playlist.hpp"
40 #include "dialogs/bookmarks.hpp"
41 #include "dialogs/preferences.hpp"
42 #include "dialogs/mediainfo.hpp"
43 #include "dialogs/messages.hpp"
44 #include "dialogs/extended.hpp"
45 #include "dialogs/vlm.hpp"
46 #include "dialogs/sout.hpp"
47 #include "dialogs/convert.hpp"
48 #include "dialogs/open.hpp"
49 #include "dialogs/openurl.hpp"
50 #include "dialogs/help.hpp"
51 #include "dialogs/gototime.hpp"
52 #include "dialogs/podcast_configuration.hpp"
53 #include "dialogs/toolbar.hpp"
54 #include "dialogs/plugins.hpp"
55 #include "dialogs/external.hpp"
56
57 #include <QEvent>
58 #include <QApplication>
59 #include <QSignalMapper>
60 #include <QFileDialog>
61
62
63 DialogsProvider* DialogsProvider::instance = NULL;
64
65 DialogsProvider::DialogsProvider( intf_thread_t *_p_intf ) :
66                                   QObject( NULL ), p_intf( _p_intf )
67 {
68     b_isDying = false;
69
70     /* Various signal mappers for the menus */
71     menusMapper = new QSignalMapper();
72     CONNECT( menusMapper, mapped(QObject *), this, menuAction( QObject *) );
73
74     menusUpdateMapper = new QSignalMapper();
75     CONNECT( menusUpdateMapper, mapped(QObject *),
76              this, menuUpdateAction( QObject *) );
77
78     SDMapper = new QSignalMapper();
79     CONNECT( SDMapper, mapped (QString), this, SDMenuAction( QString ) );
80
81     DialogHandler *dialogHandler = new DialogHandler (p_intf, this );
82 }
83
84 DialogsProvider::~DialogsProvider()
85 {
86     PlaylistDialog::killInstance();
87     MediaInfoDialog::killInstance();
88     MessagesDialog::killInstance();
89     ExtendedDialog::killInstance();
90     BookmarksDialog::killInstance();
91     HelpDialog::killInstance();
92 #ifdef UPDATE_CHECK
93     UpdateDialog::killInstance();
94 #endif
95
96     delete menusMapper;
97     delete menusUpdateMapper;
98     delete SDMapper;
99 }
100
101 void DialogsProvider::quit()
102 {
103     b_isDying = true;
104     libvlc_Quit( p_intf->p_libvlc );
105 }
106
107 void DialogsProvider::customEvent( QEvent *event )
108 {
109     if( event->type() == (int)DialogEvent_Type )
110     {
111         DialogEvent *de = static_cast<DialogEvent*>(event);
112         switch( de->i_dialog )
113         {
114         case INTF_DIALOG_FILE_SIMPLE:
115         case INTF_DIALOG_FILE:
116             openDialog(); break;
117         case INTF_DIALOG_FILE_GENERIC:
118             openFileGenericDialog( de->p_arg ); break;
119         case INTF_DIALOG_DISC:
120             openDiscDialog(); break;
121         case INTF_DIALOG_NET:
122             openNetDialog(); break;
123         case INTF_DIALOG_SAT:
124         case INTF_DIALOG_CAPTURE:
125             openCaptureDialog(); break;
126         case INTF_DIALOG_DIRECTORY:
127             PLAppendDir(); break;
128         case INTF_DIALOG_PLAYLIST:
129             playlistDialog(); break;
130         case INTF_DIALOG_MESSAGES:
131             messagesDialog(); break;
132         case INTF_DIALOG_FILEINFO:
133            mediaInfoDialog(); break;
134         case INTF_DIALOG_PREFS:
135            prefsDialog(); break;
136         case INTF_DIALOG_BOOKMARKS:
137            bookmarksDialog(); break;
138         case INTF_DIALOG_EXTENDED:
139            extendedDialog(); break;
140 #ifdef ENABLE_VLM
141         case INTF_DIALOG_VLM:
142            vlmDialog(); break;
143 #endif
144         case INTF_DIALOG_POPUPMENU:
145            QVLCMenu::PopupMenu( p_intf, (de->i_arg != 0) ); break;
146         case INTF_DIALOG_AUDIOPOPUPMENU:
147            QVLCMenu::AudioPopupMenu( p_intf ); break;
148         case INTF_DIALOG_VIDEOPOPUPMENU:
149            QVLCMenu::VideoPopupMenu( p_intf ); break;
150         case INTF_DIALOG_MISCPOPUPMENU:
151            QVLCMenu::MiscPopupMenu( p_intf ); break;
152         case INTF_DIALOG_WIZARD:
153         case INTF_DIALOG_STREAMWIZARD:
154             openAndStreamingDialogs(); break;
155 #ifdef UPDATE_CHECK
156         case INTF_DIALOG_UPDATEVLC:
157             updateDialog(); break;
158 #endif
159         case INTF_DIALOG_EXIT:
160             quit(); break;
161         default:
162            msg_Warn( p_intf, "unimplemented dialog" );
163         }
164     }
165 }
166
167 /****************************************************************************
168  * Individual simple dialogs
169  ****************************************************************************/
170 void DialogsProvider::playlistDialog()
171 {
172     PlaylistDialog::getInstance( p_intf )->toggleVisible();
173 }
174
175 void DialogsProvider::prefsDialog()
176 {
177     PrefsDialog *p = new PrefsDialog( (QWidget *)p_intf->p_sys->p_mi, p_intf );
178     p->toggleVisible();
179 }
180
181 void DialogsProvider::extendedDialog()
182 {
183     if( !ExtendedDialog::getInstance( p_intf )->isVisible() || /* Hidden */
184         ExtendedDialog::getInstance( p_intf )->currentTab() != 0 )  /* wrong tab */
185         ExtendedDialog::getInstance( p_intf )->showTab( 0 );
186     else
187         ExtendedDialog::getInstance( p_intf )->hide();
188 }
189
190 void DialogsProvider::synchroDialog()
191 {
192     if( !ExtendedDialog::getInstance( p_intf )->isVisible() || /* Hidden */
193         ExtendedDialog::getInstance( p_intf )->currentTab() != 2 )  /* wrong tab */
194         ExtendedDialog::getInstance( p_intf )->showTab( 2 );
195     else
196         ExtendedDialog::getInstance( p_intf )->hide();
197 }
198
199 void DialogsProvider::messagesDialog()
200 {
201     MessagesDialog::getInstance( p_intf )->toggleVisible();
202 }
203
204 void DialogsProvider::gotoTimeDialog()
205 {
206     GotoTimeDialog::getInstance( p_intf )->toggleVisible();
207 }
208
209 #ifdef ENABLE_VLM
210 void DialogsProvider::vlmDialog()
211 {
212     VLMDialog::getInstance( p_intf )->toggleVisible();
213 }
214 #endif
215
216 void DialogsProvider::helpDialog()
217 {
218     HelpDialog::getInstance( p_intf )->toggleVisible();
219 }
220
221 #ifdef UPDATE_CHECK
222 void DialogsProvider::updateDialog()
223 {
224     UpdateDialog::getInstance( p_intf )->toggleVisible();
225 }
226 #endif
227
228 void DialogsProvider::aboutDialog()
229 {
230     AboutDialog::getInstance( p_intf )->toggleVisible();
231 }
232
233 void DialogsProvider::mediaInfoDialog()
234 {
235     MediaInfoDialog::getInstance( p_intf )->showTab( 0 );
236 }
237
238 void DialogsProvider::mediaCodecDialog()
239 {
240     MediaInfoDialog::getInstance( p_intf )->showTab( 2 );
241 }
242
243 void DialogsProvider::bookmarksDialog()
244 {
245     BookmarksDialog::getInstance( p_intf )->toggleVisible();
246 }
247
248 void DialogsProvider::podcastConfigureDialog()
249 {
250     PodcastConfigDialog::getInstance( p_intf )->toggleVisible();
251 }
252
253 void DialogsProvider::toolbarDialog()
254 {
255     ToolbarEditDialog *toolbarEditor = new ToolbarEditDialog( (QWidget *)p_intf->p_sys->p_mi, p_intf );
256     if( toolbarEditor->exec() == QDialog::Accepted )
257         emit toolBarConfUpdated();
258 }
259
260 void DialogsProvider::pluginDialog()
261 {
262     PluginDialog::getInstance( p_intf )->toggleVisible();
263 }
264
265 /* Generic open file */
266 void DialogsProvider::openFileGenericDialog( intf_dialog_args_t *p_arg )
267 {
268     if( p_arg == NULL )
269     {
270         msg_Warn( p_intf, "openFileGenericDialog() called with NULL arg" );
271         return;
272     }
273
274     /* Replace the extensions to a Qt format */
275     int i = 0;
276     QString extensions = qfu( p_arg->psz_extensions );
277     while ( ( i = extensions.indexOf( "|", i ) ) != -1 )
278     {
279         if( ( extensions.count( "|" ) % 2 ) == 0 )
280             extensions.replace( i, 1, ");;" );
281         else
282             extensions.replace( i, 1, "(" );
283     }
284     extensions.replace( ";*", " *" );
285     extensions.append( ")" );
286
287     /* Save */
288     if( p_arg->b_save )
289     {
290         QString file = QFileDialog::getSaveFileName( NULL, p_arg->psz_title,
291                                         p_intf->p_sys->filepath, extensions );
292         if( !file.isEmpty() )
293         {
294             p_arg->i_results = 1;
295             p_arg->psz_results = (char **)malloc( p_arg->i_results * sizeof( char * ) );
296             p_arg->psz_results[0] = strdup( qtu( toNativeSepNoSlash( file ) ) );
297         }
298         else
299             p_arg->i_results = 0;
300     }
301     else /* non-save mode */
302     {
303         QStringList files = QFileDialog::getOpenFileNames( NULL,
304                 p_arg->psz_title, p_intf->p_sys->filepath,
305                 extensions );
306         p_arg->i_results = files.count();
307         p_arg->psz_results = (char **)malloc( p_arg->i_results * sizeof( char * ) );
308         i = 0;
309         foreach( const QString &file, files )
310             p_arg->psz_results[i++] = strdup( qtu( toNativeSepNoSlash( file ) ) );
311         p_intf->p_sys->filepath = qfu( p_arg->psz_results[i] );
312     }
313
314     /* Callback */
315     if( p_arg->pf_callback )
316         p_arg->pf_callback( p_arg );
317
318     /* Clean afterwards */
319     if( p_arg->psz_results )
320     {
321         for( i = 0; i < p_arg->i_results; i++ )
322             free( p_arg->psz_results[i] );
323         free( p_arg->psz_results );
324     }
325     free( p_arg->psz_title );
326     free( p_arg->psz_extensions );
327     free( p_arg );
328 }
329 /****************************************************************************
330  * All the open/add stuff
331  * Open Dialog first - Simple Open then
332  ****************************************************************************/
333
334 void DialogsProvider::openDialog( int i_tab )
335 {
336     OpenDialog::getInstance( p_intf->p_sys->p_mi , p_intf )->showTab( i_tab );
337 }
338 void DialogsProvider::openDialog()
339 {
340     openDialog( OPEN_FILE_TAB );
341 }
342 void DialogsProvider::openFileDialog()
343 {
344     openDialog( OPEN_FILE_TAB );
345 }
346 void DialogsProvider::openDiscDialog()
347 {
348     openDialog( OPEN_DISC_TAB );
349 }
350 void DialogsProvider::openNetDialog()
351 {
352     openDialog( OPEN_NETWORK_TAB );
353 }
354 void DialogsProvider::openCaptureDialog()
355 {
356     openDialog( OPEN_CAPTURE_TAB );
357 }
358
359 /* Same as the open one, but force the enqueue */
360 void DialogsProvider::PLAppendDialog( int tab )
361 {
362     OpenDialog::getInstance( p_intf->p_sys->p_mi, p_intf, false,
363                              OPEN_AND_ENQUEUE )->showTab( tab );
364 }
365
366 void DialogsProvider::MLAppendDialog( int tab )
367 {
368     OpenDialog::getInstance( p_intf->p_sys->p_mi, p_intf, false,
369                             OPEN_AND_ENQUEUE, false, false )
370                                     ->showTab( tab );
371 }
372
373 /**
374  * Simple open
375  ***/
376 QStringList DialogsProvider::showSimpleOpen( QString help,
377                                              int filters,
378                                              QString path )
379 {
380     QString fileTypes = "";
381     if( filters & EXT_FILTER_MEDIA ) {
382         ADD_FILTER_MEDIA( fileTypes );
383     }
384     if( filters & EXT_FILTER_VIDEO ) {
385         ADD_FILTER_VIDEO( fileTypes );
386     }
387     if( filters & EXT_FILTER_AUDIO ) {
388         ADD_FILTER_AUDIO( fileTypes );
389     }
390     if( filters & EXT_FILTER_PLAYLIST ) {
391         ADD_FILTER_PLAYLIST( fileTypes );
392     }
393     if( filters & EXT_FILTER_SUBTITLE ) {
394         ADD_FILTER_SUBTITLE( fileTypes );
395     }
396     ADD_FILTER_ALL( fileTypes );
397     fileTypes.replace( ";*", " *");
398
399     QStringList files = QFileDialog::getOpenFileNames( NULL,
400         help.isEmpty() ? qtr(I_OP_SEL_FILES ) : help,
401         path.isEmpty() ? p_intf->p_sys->filepath : path,
402         fileTypes );
403
404     if( !files.isEmpty() ) savedirpathFromFile( files.last() );
405
406     return files;
407 }
408
409 /**
410  * Open a file,
411  * pl helps you to choose from playlist or media library,
412  * go to start or enqueue
413  **/
414 void DialogsProvider::addFromSimple( bool pl, bool go)
415 {
416     QStringList files = DialogsProvider::showSimpleOpen();
417     int i = 0;
418     files.sort();
419     foreach( const QString &file, files )
420     {
421         playlist_Add( THEPL, qtu( toNativeSeparators( file ) ), NULL,
422                       go ? ( PLAYLIST_APPEND | ( i ? 0 : PLAYLIST_GO ) |
423                                                ( i ? PLAYLIST_PREPARSE : 0 ) )
424                          : ( PLAYLIST_APPEND | PLAYLIST_PREPARSE ),
425                       PLAYLIST_END,
426                       pl ? true : false, false );
427         RecentsMRL::getInstance( p_intf )->addRecent(
428                 toNativeSeparators( file ) );
429         i++;
430     }
431 }
432
433 void DialogsProvider::simpleOpenDialog()
434 {
435     addFromSimple( true, true ); /* Playlist and Go */
436 }
437
438 void DialogsProvider::simplePLAppendDialog()
439 {
440     addFromSimple( true, false );
441 }
442
443 void DialogsProvider::simpleMLAppendDialog()
444 {
445     addFromSimple( false, false );
446 }
447
448 /* Url & Clipboard */
449 /**
450  * Open a MRL.
451  * If the clipboard contains URLs, the first is automatically 'preselected'.
452  **/
453 void DialogsProvider::openUrlDialog()
454 {
455     OpenUrlDialog *oud = OpenUrlDialog::getInstance( p_intf->p_sys->p_mi,
456                                                      p_intf );
457     if( oud->exec() == QDialog::Accepted )
458     {
459         QString url = oud->url();
460         if( !url.isEmpty() )
461         {
462             playlist_Add( THEPL, qtu( url ),
463                           NULL, !oud->shouldEnqueue() ?
464                                   ( PLAYLIST_APPEND | PLAYLIST_GO )
465                                 : ( PLAYLIST_APPEND | PLAYLIST_PREPARSE ),
466                           PLAYLIST_END, true, false );
467             RecentsMRL::getInstance( p_intf )->addRecent( url );
468         }
469     }
470 }
471
472 /* Directory */
473 /**
474  * Open a directory,
475  * pl helps you to choose from playlist or media library,
476  * go to start or enqueue
477  **/
478 static void openDirectory( intf_thread_t *p_intf, bool pl, bool go )
479 {
480     QString dir = QFileDialog::getExistingDirectory( NULL, qtr("Open Directory"), p_intf->p_sys->filepath );
481
482     if (!dir.isEmpty() )
483     {
484         QString mrl = dir.endsWith( "VIDEO_TS", Qt::CaseInsensitive ) ?
485             "dvd://" : "directory://" + toNativeSeparators( dir );
486         input_item_t *p_input = input_item_New( THEPL, qtu( mrl ), NULL );
487
488         /* FIXME: playlist_AddInput() can fail */
489         playlist_AddInput( THEPL, p_input,
490                        go ? ( PLAYLIST_APPEND | PLAYLIST_GO ) : PLAYLIST_APPEND,
491                        PLAYLIST_END, pl, pl_Unlocked );
492         RecentsMRL::getInstance( p_intf )->addRecent( mrl );
493         if( !go )
494             input_Read( THEPL, p_input, true );
495         vlc_gc_decref( p_input );
496     }
497 }
498
499 void DialogsProvider::PLOpenDir()
500 {
501     openDirectory( p_intf, true, true );
502 }
503
504 void DialogsProvider::PLAppendDir()
505 {
506     openDirectory( p_intf, true, false );
507 }
508
509 void DialogsProvider::MLAppendDir()
510 {
511     openDirectory( p_intf, false , false );
512 }
513
514 /****************
515  * Playlist     *
516  ****************/
517 void DialogsProvider::openAPlaylist()
518 {
519     QStringList files = showSimpleOpen( qtr( "Open playlist..." ),
520                                         EXT_FILTER_PLAYLIST );
521     foreach( const QString &file, files )
522     {
523         playlist_Import( THEPL, qtu( toNativeSeparators( file ) ) );
524     }
525 }
526
527 void DialogsProvider::saveAPlaylist()
528 {
529     QString file = QFileDialog::getSaveFileName( NULL,
530                                   qtr( "Save playlist as..." ),
531                                   p_intf->p_sys->filepath,
532                                   qtr( "XSPF playlist (*.xspf);; " ) +
533                                   qtr( "M3U playlist (*.m3u);; " ) +
534                                   qtr( "HTML playlist (*.html)" ) );
535
536     if( !file.isEmpty() )
537     {
538         static const char psz_xspf[] = "export-xspf",
539                           psz_m3u[] = "export-m3u",
540                           psz_html[] = "export-html";
541         const char *psz_module;
542
543         if( file.contains( ".xsp" ) )
544             psz_module = psz_xspf;
545         else if( file.contains( ".m3u" ) )
546             psz_module = psz_m3u;
547         else if( file.contains(".html" ) )
548             psz_module = psz_html;
549         else
550         {
551             msg_Warn( p_intf, "Impossible to recognise the file type. "
552                     "Defaulting to XSPF" );
553             psz_module = psz_xspf;
554             file.append( ".xpsf" );
555         }
556
557         playlist_Export( THEPL, qtu( toNativeSeparators( file ) ),
558                 THEPL->p_local_category, psz_module);
559     }
560 }
561
562 /****************************************************************************
563  * Sout emulation
564  ****************************************************************************/
565
566 void DialogsProvider::streamingDialog( QWidget *parent,
567                                        QString mrl,
568                                        bool b_transcode_only,
569                                        QStringList options )
570 {
571     char *psz_soutoption;
572
573     /* Stream */
574     if( !b_transcode_only )
575     {
576         SoutDialog *s = new SoutDialog( parent, p_intf, mrl );
577         if( s->exec() == QDialog::Accepted )
578         {
579             psz_soutoption = strdup( qtu( s->getMrl() ) );
580             delete s;
581         }
582         else
583         {
584             delete s; return;
585         }
586     } else {
587     /* Convert */
588         ConvertDialog *s = new ConvertDialog( parent, p_intf, mrl );
589         if( s->exec() == QDialog::Accepted )
590         {
591             psz_soutoption = strdup( qtu( s->getMrl() ) );
592             delete s;
593         }
594         else
595         {
596             delete s; return;
597         }
598     }
599
600     /* Get SoutMRL */
601     if( !EMPTY_STR( psz_soutoption ) )
602     {
603         options += QString( psz_soutoption ).split( " :");
604
605         /* Create Input */
606         input_item_t *p_input;
607         p_input = input_item_New( p_intf, qtu( mrl ), _("Streaming") );
608
609         /* Add normal Options */
610         for( int j = 0; j < options.size(); j++ )
611         {
612             QString qs = colon_unescape( options[j] );
613             if( !qs.isEmpty() )
614             {
615                 input_item_AddOption( p_input, qtu( qs ),
616                         VLC_INPUT_OPTION_TRUSTED );
617                 msg_Dbg( p_intf, "Adding option: %s", qtu( qs ) );
618             }
619         }
620
621         /* Switch between enqueuing and starting the item */
622         /* FIXME: playlist_AddInput() can fail */
623         playlist_AddInput( THEPL, p_input,
624                 PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END, true, pl_Unlocked );
625         vlc_gc_decref( p_input );
626
627         RecentsMRL::getInstance( p_intf )->addRecent( mrl );
628     }
629     free( psz_soutoption );
630 }
631
632 void DialogsProvider::openAndStreamingDialogs()
633 {
634     OpenDialog::getInstance( p_intf->p_sys->p_mi, p_intf, false, OPEN_AND_STREAM )
635                                 ->showTab( OPEN_FILE_TAB );
636 }
637
638 void DialogsProvider::openAndTranscodingDialogs()
639 {
640     OpenDialog::getInstance( p_intf->p_sys->p_mi , p_intf, false, OPEN_AND_SAVE )
641                                 ->showTab( OPEN_FILE_TAB );
642 }
643
644 void DialogsProvider::loadSubtitlesFile()
645 {
646     input_thread_t *p_input = THEMIM->getInput();
647     if( !p_input ) return;
648
649     input_item_t *p_item = input_GetItem( p_input );
650     if( !p_item ) return;
651
652     char *path = input_item_GetURI( p_item );
653     if( !path ) path = strdup( "" );
654
655     char *sep = strrchr( path, DIR_SEP_CHAR );
656     if( sep ) *sep = '\0';
657
658     QStringList qsl = showSimpleOpen( qtr( "Open subtitles..." ),
659                                       EXT_FILTER_SUBTITLE,
660                                       path );
661     free( path );
662     foreach( const QString &qsFile, qsl )
663     {
664         if( input_AddSubtitle( p_input, qtu( toNativeSeparators( qsFile ) ),
665                     true ) )
666             msg_Warn( p_intf, "unable to load subtitles from '%s'",
667                       qtu( qsFile ) );
668     }
669 }
670
671
672 /****************************************************************************
673  * Menus
674  ****************************************************************************/
675
676 void DialogsProvider::menuAction( QObject *data )
677 {
678     QVLCMenu::DoAction( data );
679 }
680
681 void DialogsProvider::menuUpdateAction( QObject *data )
682 {
683     MenuFunc *func = qobject_cast<MenuFunc *>(data);
684     assert( func );
685     func->doFunc( p_intf );
686 }
687
688 void DialogsProvider::SDMenuAction( QString data )
689 {
690     char *psz_sd = strdup( qtu( data ) );
691     if( !playlist_IsServicesDiscoveryLoaded( THEPL, psz_sd ) )
692         playlist_ServicesDiscoveryAdd( THEPL, psz_sd );
693     else
694         playlist_ServicesDiscoveryRemove( THEPL, psz_sd );
695     free( psz_sd );
696 }
697
698 /**
699  * Play the MRL contained in the Recently played menu.
700  **/
701 void DialogsProvider::playMRL( const QString &mrl )
702 {
703     playlist_Add( THEPL, qtu( mrl ) , NULL,
704            PLAYLIST_APPEND | PLAYLIST_GO , PLAYLIST_END, true, false );
705
706     RecentsMRL::getInstance( p_intf )->addRecent( mrl );
707 }