]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs_provider.cpp
Qt: Fix opening of folders under Win32
[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) ), NULL );
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         return;
502
503     const char *scheme = "directory";
504     if( dir.endsWith( "/VIDEO_TS", Qt::CaseInsensitive ) )
505         scheme = "dvd";
506
507     char *uri = make_URI( qtu( toNativeSeparators( dir ) ), scheme );
508     if( unlikely(uri == NULL) )
509         return;
510
511     RecentsMRL::getInstance( p_intf )->addRecent( qfu(uri) );
512
513     input_item_t *p_input = input_item_New( THEPL, uri, NULL );
514     free( uri );
515     if( unlikely( p_input == NULL ) )
516         return;
517
518     /* FIXME: playlist_AddInput() can fail */
519     playlist_AddInput( THEPL, p_input,
520                       go ? ( PLAYLIST_APPEND | PLAYLIST_GO ) : PLAYLIST_APPEND,
521                        PLAYLIST_END, pl, pl_Unlocked );
522     if( !go )
523         input_Read( THEPL, p_input );
524     vlc_gc_decref( p_input );
525 }
526
527 void DialogsProvider::PLOpenDir()
528 {
529     openDirectory( p_intf, true, true );
530 }
531
532 void DialogsProvider::PLAppendDir()
533 {
534     openDirectory( p_intf, true, false );
535 }
536
537 void DialogsProvider::MLAppendDir()
538 {
539     openDirectory( p_intf, false , false );
540 }
541
542 /****************
543  * Playlist     *
544  ****************/
545 void DialogsProvider::openAPlaylist()
546 {
547     QStringList files = showSimpleOpen( qtr( "Open playlist..." ),
548                                         EXT_FILTER_PLAYLIST );
549     foreach( const QString &file, files )
550     {
551         playlist_Import( THEPL, qtu( toNativeSeparators( file ) ) );
552     }
553 }
554
555 void DialogsProvider::saveAPlaylist()
556 {
557     static const struct
558     {
559         char filter[24];
560         char module[12];
561     } types[] = {
562         { N_("XSPF playlist (*.xspf)"), "export-xspf", },
563         { N_("M3U8 playlist (*.m3u)"), "export-m3u8", },
564         { N_("M3U playlist (*.m3u)"), "export-m3u", },
565         { N_("HTML playlist (*.html)"), "export-html", },
566     };
567     QString filters, selected;
568
569     for( size_t i = 0; i < sizeof (types) / sizeof (types[0]); i++ )
570     {
571         if( !filters.isEmpty() )
572             filters += ";;";
573         filters += qfu( vlc_gettext( types[i].filter ) );
574     }
575
576     QString file = QFileDialog::getSaveFileName( NULL,
577                                   qtr( "Save playlist as..." ),
578                                   p_intf->p_sys->filepath, filters, &selected );
579     if( file.isEmpty() )
580         return;
581
582     for( size_t i = 0; i < sizeof (types) / sizeof (types[0]); i++)
583         if( selected == qfu( vlc_gettext( types[i].filter ) ) )
584         {
585             playlist_Export( THEPL, qtu( toNativeSeparators( file ) ),
586                              THEPL->p_playing, types[i].module );
587             break;
588         }
589 }
590
591 /****************************************************************************
592  * Sout emulation
593  ****************************************************************************/
594
595 void DialogsProvider::streamingDialog( QWidget *parent,
596                                        const QString& mrl,
597                                        bool b_transcode_only,
598                                        QStringList options )
599 {
600     QString soutoption;
601
602     /* Stream */
603     if( !b_transcode_only )
604     {
605         SoutDialog *s = new SoutDialog( parent, p_intf, mrl );
606         if( s->exec() == QDialog::Accepted )
607         {
608             soutoption = s->getMrl();
609             delete s;
610         }
611         else
612         {
613             delete s; return;
614         }
615     } else {
616     /* Convert */
617         ConvertDialog *s = new ConvertDialog( parent, p_intf, mrl );
618         if( s->exec() == QDialog::Accepted )
619         {
620             soutoption = s->getMrl();
621             delete s;
622         }
623         else
624         {
625             delete s; return;
626         }
627     }
628
629     /* Get SoutMRL */
630     if( !soutoption.isEmpty() )
631     {
632         options += soutoption.split( " :");
633
634         /* Create Input */
635         input_item_t *p_input;
636         p_input = input_item_New( p_intf, qtu( mrl ), _("Streaming") );
637
638         /* Add normal Options */
639         for( int j = 0; j < options.size(); j++ )
640         {
641             QString qs = colon_unescape( options[j] );
642             if( !qs.isEmpty() )
643             {
644                 input_item_AddOption( p_input, qtu( qs ),
645                         VLC_INPUT_OPTION_TRUSTED );
646                 msg_Dbg( p_intf, "Adding option: %s", qtu( qs ) );
647             }
648         }
649
650         /* Switch between enqueuing and starting the item */
651         /* FIXME: playlist_AddInput() can fail */
652         playlist_AddInput( THEPL, p_input,
653                 PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END, true, pl_Unlocked );
654         vlc_gc_decref( p_input );
655
656         RecentsMRL::getInstance( p_intf )->addRecent( mrl );
657     }
658 }
659
660 void DialogsProvider::openAndStreamingDialogs()
661 {
662     OpenDialog::getInstance( p_intf->p_sys->p_mi, p_intf, false, OPEN_AND_STREAM )
663                                 ->showTab( OPEN_FILE_TAB );
664 }
665
666 void DialogsProvider::openAndTranscodingDialogs()
667 {
668     OpenDialog::getInstance( p_intf->p_sys->p_mi , p_intf, false, OPEN_AND_SAVE )
669                                 ->showTab( OPEN_FILE_TAB );
670 }
671
672 void DialogsProvider::loadSubtitlesFile()
673 {
674     input_thread_t *p_input = THEMIM->getInput();
675     if( !p_input ) return;
676
677     input_item_t *p_item = input_GetItem( p_input );
678     if( !p_item ) return;
679
680     char *path = input_item_GetURI( p_item );
681     if( !path ) path = strdup( "" );
682
683     char *sep = strrchr( path, DIR_SEP_CHAR );
684     if( sep ) *sep = '\0';
685
686     QStringList qsl = showSimpleOpen( qtr( "Open subtitles..." ),
687                                       EXT_FILTER_SUBTITLE,
688                                       qfu( path ) );
689     free( path );
690     foreach( const QString &qsFile, qsl )
691     {
692         if( input_AddSubtitle( p_input, qtu( toNativeSeparators( qsFile ) ),
693                     true ) )
694             msg_Warn( p_intf, "unable to load subtitles from '%s'",
695                       qtu( qsFile ) );
696     }
697 }
698
699
700 /****************************************************************************
701  * Menus
702  ****************************************************************************/
703
704 void DialogsProvider::menuAction( QObject *data )
705 {
706     QVLCMenu::DoAction( data );
707 }
708
709 void DialogsProvider::menuUpdateAction( QObject *data )
710 {
711     MenuFunc *func = qobject_cast<MenuFunc *>(data);
712     assert( func );
713     func->doFunc( p_intf );
714 }
715
716 void DialogsProvider::SDMenuAction( const QString& data )
717 {
718     char *psz_sd = strdup( qtu( data ) );
719     if( !playlist_IsServicesDiscoveryLoaded( THEPL, psz_sd ) )
720         playlist_ServicesDiscoveryAdd( THEPL, psz_sd );
721     else
722         playlist_ServicesDiscoveryRemove( THEPL, psz_sd );
723     free( psz_sd );
724 }
725
726 /**
727  * Play the MRL contained in the Recently played menu.
728  **/
729 void DialogsProvider::playMRL( const QString &mrl )
730 {
731     char* psz_uri = make_URI( qtu(mrl), NULL );
732     playlist_Add( THEPL, psz_uri, NULL,
733            PLAYLIST_APPEND | PLAYLIST_GO , PLAYLIST_END, true, false );
734     free( psz_uri );
735
736     RecentsMRL::getInstance( p_intf )->addRecent( mrl );
737 }