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