]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/dialogs_provider.cpp
vlc_epg: add parental rating from ts streams.
[vlc] / modules / gui / qt4 / dialogs_provider.cpp
index b40d1cca60f3eac71f29b625f29a4ef0c89540ba..2a15d5b33a8b584099cc48ef583d439b2bd798bf 100644 (file)
@@ -91,22 +91,22 @@ DialogsProvider::~DialogsProvider()
     PlaylistDialog::killInstance();
     MediaInfoDialog::killInstance();
     MessagesDialog::killInstance();
-    ExtendedDialog::killInstance();
     BookmarksDialog::killInstance();
     HelpDialog::killInstance();
 #ifdef UPDATE_CHECK
     UpdateDialog::killInstance();
 #endif
     PluginDialog::killInstance();
+    EpgDialog::killInstance();
 
     delete menusMapper;
     delete menusUpdateMapper;
     delete SDMapper;
 
-    QVLCMenu::PopupMenu( p_intf, false );
-    QVLCMenu::AudioPopupMenu( p_intf, false );
-    QVLCMenu::VideoPopupMenu( p_intf, false );
-    QVLCMenu::MiscPopupMenu( p_intf, false );
+    VLCMenuBar::PopupMenu( p_intf, false );
+    VLCMenuBar::AudioPopupMenu( p_intf, false );
+    VLCMenuBar::VideoPopupMenu( p_intf, false );
+    VLCMenuBar::MiscPopupMenu( p_intf, false );
 }
 
 void DialogsProvider::quit()
@@ -117,7 +117,7 @@ void DialogsProvider::quit()
 
 void DialogsProvider::customEvent( QEvent *event )
 {
-    if( event->type() == (int)DialogEvent_Type )
+    if( event->type() == DialogEvent::DialogEvent_Type )
     {
         DialogEvent *de = static_cast<DialogEvent*>(event);
         switch( de->i_dialog )
@@ -153,13 +153,13 @@ void DialogsProvider::customEvent( QEvent *event )
            vlmDialog(); break;
 #endif
         case INTF_DIALOG_POPUPMENU:
-           QVLCMenu::PopupMenu( p_intf, (de->i_arg != 0) ); break;
+           VLCMenuBar::PopupMenu( p_intf, (de->i_arg != 0) ); break;
         case INTF_DIALOG_AUDIOPOPUPMENU:
-           QVLCMenu::AudioPopupMenu( p_intf, (de->i_arg != 0) ); break;
+           VLCMenuBar::AudioPopupMenu( p_intf, (de->i_arg != 0) ); break;
         case INTF_DIALOG_VIDEOPOPUPMENU:
-           QVLCMenu::VideoPopupMenu( p_intf, (de->i_arg != 0) ); break;
+           VLCMenuBar::VideoPopupMenu( p_intf, (de->i_arg != 0) ); break;
         case INTF_DIALOG_MISCPOPUPMENU:
-           QVLCMenu::MiscPopupMenu( p_intf, (de->i_arg != 0) ); break;
+           VLCMenuBar::MiscPopupMenu( p_intf, (de->i_arg != 0) ); break;
         case INTF_DIALOG_WIZARD:
         case INTF_DIALOG_STREAMWIZARD:
             openAndStreamingDialogs(); break;
@@ -178,6 +178,9 @@ void DialogsProvider::customEvent( QEvent *event )
 /****************************************************************************
  * Individual simple dialogs
  ****************************************************************************/
+const QEvent::Type DialogEvent::DialogEvent_Type =
+        (QEvent::Type)QEvent::registerEventType();
+
 void DialogsProvider::playlistDialog()
 {
     PlaylistDialog::getInstance( p_intf )->toggleVisible();
@@ -191,20 +194,24 @@ void DialogsProvider::prefsDialog()
 
 void DialogsProvider::extendedDialog()
 {
-    if( !ExtendedDialog::getInstance( p_intf )->isVisible() || /* Hidden */
-        ExtendedDialog::getInstance( p_intf )->currentTab() != 0 )  /* wrong tab */
-        ExtendedDialog::getInstance( p_intf )->showTab( 0 );
+    ExtendedDialog *extDialog = ExtendedDialog::getInstance(p_intf );
+
+    if( !extDialog->isVisible() || /* Hidden */
+        extDialog->currentTab() != 0 )  /* wrong tab */
+        extDialog->showTab( 0 );
     else
-        ExtendedDialog::getInstance( p_intf )->hide();
+        extDialog->hide();
 }
 
 void DialogsProvider::synchroDialog()
 {
-    if( !ExtendedDialog::getInstance( p_intf )->isVisible() || /* Hidden */
-        ExtendedDialog::getInstance( p_intf )->currentTab() != 2 )  /* wrong tab */
-        ExtendedDialog::getInstance( p_intf )->showTab( 2 );
+    ExtendedDialog *extDialog = ExtendedDialog::getInstance(p_intf );
+
+    if( !extDialog->isVisible() || /* Hidden */
+        extDialog->currentTab() != 2 )  /* wrong tab */
+        extDialog->showTab( 2 );
     else
-        ExtendedDialog::getInstance( p_intf )->hide();
+        extDialog->hide();
 }
 
 void DialogsProvider::messagesDialog()
@@ -243,12 +250,12 @@ void DialogsProvider::aboutDialog()
 
 void DialogsProvider::mediaInfoDialog()
 {
-    MediaInfoDialog::getInstance( p_intf )->showTab( 0 );
+    MediaInfoDialog::getInstance( p_intf )->showTab( MediaInfoDialog::META_PANEL );
 }
 
 void DialogsProvider::mediaCodecDialog()
 {
-    MediaInfoDialog::getInstance( p_intf )->showTab( 2 );
+    MediaInfoDialog::getInstance( p_intf )->showTab( MediaInfoDialog::INFO_PANEL );
 }
 
 void DialogsProvider::bookmarksDialog()
@@ -398,21 +405,21 @@ QStringList DialogsProvider::showSimpleOpen( const QString& help,
 {
     QString fileTypes = "";
     if( filters & EXT_FILTER_MEDIA ) {
-        ADD_FILTER_MEDIA( fileTypes );
+        ADD_EXT_FILTER( fileTypes, EXTENSIONS_MEDIA );
     }
     if( filters & EXT_FILTER_VIDEO ) {
-        ADD_FILTER_VIDEO( fileTypes );
+        ADD_EXT_FILTER( fileTypes, EXTENSIONS_VIDEO );
     }
     if( filters & EXT_FILTER_AUDIO ) {
-        ADD_FILTER_AUDIO( fileTypes );
+        ADD_EXT_FILTER( fileTypes, EXTENSIONS_AUDIO );
     }
     if( filters & EXT_FILTER_PLAYLIST ) {
-        ADD_FILTER_PLAYLIST( fileTypes );
+        ADD_EXT_FILTER( fileTypes, EXTENSIONS_PLAYLIST );
     }
     if( filters & EXT_FILTER_SUBTITLE ) {
-        ADD_FILTER_SUBTITLE( fileTypes );
+        ADD_EXT_FILTER( fileTypes, EXTENSIONS_SUBTITLE );
     }
-    ADD_FILTER_ALL( fileTypes );
+    ADD_EXT_FILTER( fileTypes, EXTENSIONS_ALL );
     fileTypes.replace( ";*", " *");
 
     QStringList files = QFileDialog::getOpenFileNames( NULL,
@@ -468,21 +475,27 @@ void DialogsProvider::simpleMLAppendDialog()
  **/
 void DialogsProvider::openUrlDialog()
 {
-    OpenUrlDialog *oud = new OpenUrlDialog( p_intf );
-    if( oud->exec() == QDialog::Accepted )
+    OpenUrlDialog oud( p_intf );
+    if( oud.exec() != QDialog::Accepted )
+        return;
+
+    QString url = oud.url();
+    if( url.isEmpty() )
+        return;
+
+    if( !url.contains( qfu( "://" ) ) )
     {
-        QString url = oud->url();
-        if( !url.isEmpty() )
-        {
-            playlist_Add( THEPL, qtu( url ),
-                          NULL, !oud->shouldEnqueue() ?
-                                  ( PLAYLIST_APPEND | PLAYLIST_GO )
-                                : ( PLAYLIST_APPEND | PLAYLIST_PREPARSE ),
-                          PLAYLIST_END, true, false );
-            RecentsMRL::getInstance( p_intf )->addRecent( url );
-        }
+        char *uri = vlc_path2uri( qtu( url ), NULL );
+        if( uri == NULL )
+            return;
+        url = qfu(uri);
+        free( uri );
     }
-    delete oud;
+    playlist_Add( THEPL, qtu(url), NULL,
+                  !oud.shouldEnqueue() ? ( PLAYLIST_APPEND | PLAYLIST_GO )
+                                     : ( PLAYLIST_APPEND | PLAYLIST_PREPARSE ),
+                  PLAYLIST_END, true, false );
+    RecentsMRL::getInstance( p_intf )->addRecent( url );
 }
 
 /* Directory */
@@ -498,11 +511,18 @@ static void openDirectory( intf_thread_t *p_intf, bool pl, bool go )
     if( dir.isEmpty() )
         return;
 
+    p_intf->p_sys->filepath = dir;
+
     const char *scheme = "directory";
     if( dir.endsWith( "/VIDEO_TS", Qt::CaseInsensitive ) )
         scheme = "dvd";
+    else if( dir.endsWith( "/BDMV", Qt::CaseInsensitive ) )
+    {
+        scheme = "bluray";
+        dir.remove( "BDMV" );
+    }
 
-    char *uri = make_URI( qtu( toNativeSeparators( dir ) ), scheme );
+    char *uri = vlc_path2uri( qtu( toNativeSeparators( dir ) ), scheme );
     if( unlikely(uri == NULL) )
         return;
 
@@ -576,20 +596,48 @@ void DialogsProvider::saveAPlaylist()
 
     QString selected;
     QString file = QFileDialog::getSaveFileName( NULL,
-                                  qtr( "Save playlist as..." ),
-                                  p_intf->p_sys->filepath, filters.join( ";;" ),
-                                  &selected );
+                                                 qtr( "Save playlist as..." ),
+                                                 p_intf->p_sys->filepath, filters.join( ";;" ),
+                                                 &selected );
+    const char *psz_selected_module = NULL;
+    const char *psz_last_playlist_ext = NULL;
+
     if( file.isEmpty() )
         return;
 
+    /* First test if the file extension is set, and different to selected filter */
     for( size_t i = 0; i < sizeof (types) / sizeof (types[0]); i++)
-        if( selected == qfu( vlc_gettext( types[i].filter_name ) ) + " (*." + qfu( types[i].filter_patterns ) + ")" )
+    {
+        if ( file.endsWith( QString( "." ) + qfu( types[i].filter_patterns ) ) )
         {
-            playlist_Export( THEPL, qtu( toNativeSeparators( file ) ),
-                             THEPL->p_playing, types[i].module );
-            getSettings()->setValue( "last-playlist-ext", types[i].filter_patterns );
+            psz_selected_module = types[i].module;
+            psz_last_playlist_ext = types[i].filter_patterns;
             break;
         }
+    }
+
+    /* otherwise apply the selected extension */
+    if ( !psz_last_playlist_ext )
+    {
+        for( size_t i = 0; i < sizeof (types) / sizeof (types[0]); i++)
+        {
+            if ( selected.startsWith( qfu( vlc_gettext( types[i].filter_name ) ) ) )
+            {
+                psz_selected_module = types[i].module;
+                psz_last_playlist_ext = types[i].filter_patterns;
+                /* Fix file extension */
+                file = file.append( QString( "." ) + qfu( psz_last_playlist_ext ) );
+                break;
+            }
+        }
+    }
+
+    if ( psz_selected_module )
+    {
+        playlist_Export( THEPL, qtu( toNativeSeparators( file ) ),
+                         THEPL->p_playing, psz_selected_module );
+        getSettings()->setValue( "last-playlist-ext", psz_last_playlist_ext );
+    }
 }
 
 /****************************************************************************
@@ -607,6 +655,7 @@ void DialogsProvider::streamingDialog( QWidget *parent,
     if( !b_transcode_only )
     {
         SoutDialog *s = new SoutDialog( parent, p_intf, mrl );
+        s->setAttribute( Qt::WA_QuitOnClose, false ); // See #4883
         if( s->exec() == QDialog::Accepted )
         {
             soutoption = s->getMrl();
@@ -619,6 +668,7 @@ void DialogsProvider::streamingDialog( QWidget *parent,
     } else {
     /* Convert */
         ConvertDialog *s = new ConvertDialog( parent, p_intf, mrl );
+        s->setAttribute( Qt::WA_QuitOnClose, false ); // See #4883
         if( s->exec() == QDialog::Accepted )
         {
             soutoption = s->getMrl();
@@ -714,7 +764,7 @@ void DialogsProvider::loadSubtitlesFile()
 
 void DialogsProvider::menuAction( QObject *data )
 {
-    QVLCMenu::DoAction( data );
+    VLCMenuBar::DoAction( data );
 }
 
 void DialogsProvider::menuUpdateAction( QObject *data )
@@ -738,6 +788,6 @@ void DialogsProvider::SDMenuAction( const QString& data )
 void DialogsProvider::playMRL( const QString &mrl )
 {
     playlist_Add( THEPL, qtu(mrl), NULL,
-           PLAYLIST_APPEND | PLAYLIST_GO , PLAYLIST_END, true, false );
+                  PLAYLIST_APPEND | PLAYLIST_GO , PLAYLIST_END, true, false );
     RecentsMRL::getInstance( p_intf )->addRecent( mrl );
 }