]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/dialogs_provider.cpp
qt4: fix memleak.
[vlc] / modules / gui / qt4 / dialogs_provider.cpp
index 99da2f3b72e2a0bf1a92959d18b879c03e785486..fb9dd8b11d4fc667abd38d0d2b7f0b9eff49fa94 100644 (file)
@@ -52,7 +52,6 @@
 #include "dialogs/podcast_configuration.hpp"
 #include "dialogs/toolbar.hpp"
 #include "dialogs/plugins.hpp"
-#include "dialogs/interaction.hpp"
 
 #include <QEvent>
 #include <QApplication>
@@ -140,8 +139,6 @@ void DialogsProvider::customEvent( QEvent *event )
         case INTF_DIALOG_VLM:
            vlmDialog(); break;
 #endif
-        case INTF_DIALOG_INTERACTION:
-           doInteraction( de->p_arg ); break;
         case INTF_DIALOG_POPUPMENU:
            QVLCMenu::PopupMenu( p_intf, (de->i_arg != 0) ); break;
         case INTF_DIALOG_AUDIOPOPUPMENU:
@@ -175,7 +172,8 @@ void DialogsProvider::playlistDialog()
 
 void DialogsProvider::prefsDialog()
 {
-    PrefsDialog::getInstance( p_intf )->toggleVisible();
+    PrefsDialog *p = new PrefsDialog( (QWidget *)p_intf->p_sys->p_mi, p_intf );
+    p->toggleVisible();
 }
 
 void DialogsProvider::extendedDialog()
@@ -569,31 +567,71 @@ void DialogsProvider::saveAPlaylist()
  * Sout emulation
  ****************************************************************************/
 
-void DialogsProvider::streamingDialog( QWidget *parent, QString mrl,
-                                       bool b_transcode_only )
+void DialogsProvider::streamingDialog( QWidget *parent,
+                                       QString mrl,
+                                       bool b_transcode_only,
+                                       QStringList options )
 {
-    const char *psz_option;
+    char *psz_soutoption;
+
+    /* Stream */
     if( !b_transcode_only )
     {
-        SoutDialog *s = SoutDialog::getInstance( parent, p_intf );
+        SoutDialog *s = new SoutDialog( parent, p_intf, mrl );
         if( s->exec() == QDialog::Accepted )
-            psz_option = qtu( s->getMrl() );
-    }else {
-        ConvertDialog *s = new ConvertDialog( parent, p_intf );
+        {
+            psz_soutoption = strdup( qtu( s->getMrl() ) );
+            delete s;
+        }
+        else
+        {
+            delete s; return;
+        }
+    } else {
+    /* Convert */
+        ConvertDialog *s = new ConvertDialog( parent, p_intf, mrl );
         if( s->exec() == QDialog::Accepted )
-            psz_option = qtu( s->getMrl() );
+        {
+            psz_soutoption = strdup( qtu( s->getMrl() ) );
+            delete s;
+        }
+        else
+        {
+            delete s; return;
+        }
     }
 
-
-    if( !EMPTY_STR( psz_option ) )
+    /* Get SoutMRL */
+    if( !EMPTY_STR( psz_soutoption ) )
     {
+        /* Create Input */
+        input_item_t *p_input;
+        p_input = input_item_New( p_intf, qtu( mrl ), _("Streaming") );
+
+        /* Add normal Options */
+        for( int j = 0; j < options.size(); j++ )
+        {
+            QString qs = colon_unescape( options[j] );
+            if( !qs.isEmpty() )
+            {
+                input_item_AddOption( p_input, qtu( qs ),
+                        VLC_INPUT_OPTION_TRUSTED );
+            }
+        }
+
+        /* Add SoutMRL */
+        msg_Dbg( p_intf, "Streaming MRL is: %s", psz_soutoption );
+        input_item_AddOption( p_input, psz_soutoption, VLC_INPUT_OPTION_TRUSTED );
+
+        /* Switch between enqueuing and starting the item */
+        /* FIXME: playlist_AddInput() can fail */
+        playlist_AddInput( THEPL, p_input,
+                PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END, true, pl_Unlocked );
+        vlc_gc_decref( p_input );
 
-        msg_Dbg( p_intf, "Sout mrl %s", psz_option );
-        playlist_AddExt( THEPL, qtu( mrl ), _("Streaming"),
-                         PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END,
-                        -1, 1, &psz_option, VLC_INPUT_OPTION_TRUSTED, true, pl_Unlocked );
         RecentsMRL::getInstance( p_intf )->addRecent( mrl );
     }
+    free( psz_soutoption );
 }
 
 void DialogsProvider::openAndStreamingDialogs()
@@ -672,52 +710,3 @@ void DialogsProvider::playMRL( const QString &mrl )
 
     RecentsMRL::getInstance( p_intf )->addRecent( mrl );
 }
-
-/*************************************
- * Interactions
- *************************************/
-void DialogsProvider::doInteraction( intf_dialog_args_t *p_arg )
-{
-    InteractionDialog *qdialog;
-    interaction_dialog_t *p_dialog = p_arg->p_dialog;
-    switch( p_dialog->i_action )
-    {
-    case INTERACT_NEW:
-        qdialog = new InteractionDialog( p_intf, p_dialog );
-        p_dialog->p_private = (void*)qdialog;
-        if( !(p_dialog->i_status == ANSWERED_DIALOG) )
-            qdialog->show();
-        break;
-    case INTERACT_UPDATE:
-        qdialog = (InteractionDialog*)(p_dialog->p_private);
-        if( qdialog )
-            qdialog->update();
-        else
-        {
-            /* The INTERACT_NEW message was forgotten
-               so we must create the dialog and update it*/
-            qdialog = new InteractionDialog( p_intf, p_dialog );
-            p_dialog->p_private = (void*)qdialog;
-            if( !(p_dialog->i_status == ANSWERED_DIALOG) )
-                qdialog->show();
-            if( qdialog )
-                qdialog->update();
-        }
-        break;
-    case INTERACT_HIDE:
-        msg_Dbg( p_intf, "Hide the Interaction Dialog" );
-        qdialog = (InteractionDialog*)(p_dialog->p_private);
-        if( qdialog )
-            qdialog->hide();
-        p_dialog->i_status = HIDDEN_DIALOG;
-        break;
-    case INTERACT_DESTROY:
-        msg_Dbg( p_intf, "Destroy the Interaction Dialog" );
-        qdialog = (InteractionDialog*)(p_dialog->p_private);
-        if( !p_dialog->i_flags & DIALOG_NONBLOCKING_ERROR )
-            delete qdialog;
-        p_dialog->i_status = DESTROYED_DIALOG;
-        break;
-    }
-}
-