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