]> git.sesse.net Git - vlc/commitdiff
Qt4 - Use a main instance of Sout for VLM. Clean DP since all dialogs (except Bookmar...
authorJean-Baptiste Kempf <jb@videolan.org>
Sat, 22 Dec 2007 08:12:02 +0000 (08:12 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Sat, 22 Dec 2007 08:12:02 +0000 (08:12 +0000)
modules/gui/qt4/dialogs/mediainfo.cpp
modules/gui/qt4/dialogs/open.cpp
modules/gui/qt4/dialogs/sout.cpp
modules/gui/qt4/dialogs/sout.hpp
modules/gui/qt4/dialogs/vlm.cpp
modules/gui/qt4/dialogs/vlm.hpp
modules/gui/qt4/dialogs_provider.cpp
modules/gui/qt4/dialogs_provider.hpp

index c5b597c6b4d0952aa68c4055f9c0ec018f95b498..caa586d67f87473c34f46672d30b9eef30170230 100644 (file)
@@ -156,14 +156,14 @@ void MediaInfoDialog::update( input_thread_t *p_input )
     vlc_object_release( p_input );
 }
 
-void MediaInfoDialog::updateOnTimeOut() 
+void MediaInfoDialog::updateOnTimeOut()
 {
-    /* Timer runs at 150 ms, dont' update more than 2 times per second */ 
-    i_runs++; 
-    if( i_runs % 4 != 0 ) return; 
+    /* Timer runs at 150 ms, dont' update more than 2 times per second */
+    i_runs++;
+    if( i_runs % 4 != 0 ) return;
 
-    /* Get Input and clear if non-existant */ 
-    input_thread_t *p_input = THEMIM->getInput(); 
+    /* Get Input and clear if non-existant */
+    input_thread_t *p_input = THEMIM->getInput();
 
     if( p_input && !p_input->b_dead )
     {
index 0983c83455e2ba06c52d56211e7e181cad39667f..4f4f762d70ef92924ac016f516077d0ae69bd6c5 100644 (file)
@@ -339,7 +339,7 @@ void OpenDialog::stream( bool b_transcode_only )
 {
     mrl = ui.advancedLineInput->text();
     toggleVisible();
-    THEDP->streamingDialog( mrl, b_transcode_only );
+    THEDP->streamingDialog( this, mrl, b_transcode_only );
 }
 
 /* Update the MRL */
index bfc619c44019fa2e66901a09b1e1a32d35c420d3..db546a233d1263453b4a61cbd73550c95d9416d8 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * sout.cpp : Stream output dialog ( old-style )
  ****************************************************************************
- * Copyright ( C ) 2006 the VideoLAN team
+ * Copyright (C) 2006 the VideoLAN team
  * Copyright (C) 2007 Société des arts technologiques
  * Copyright (C) 2007 Savoir-faire Linux
  *
@@ -135,11 +135,6 @@ SoutDialog::SoutDialog( QWidget *parent, intf_thread_t *_p_intf,
     if( b_transcode_only ) toggleSout();
 }
 
-QString SoutDialog::getMrl()
-{
-    return mrl;
-}
-
 void SoutDialog::fileBrowse()
 {
     ui.tabWidget->setTabEnabled( 0,false );
index 110310245abfc1f8782c2e392ada011ea5d4c06b..371f5f4420b227c1c976fd1eb79a70b19654bb10 100644 (file)
@@ -39,13 +39,33 @@ class SoutDialog : public QVLCDialog
 {
     Q_OBJECT;
 public:
+    static SoutDialog * getInstance( QWidget *parent,
+                                     intf_thread_t *p_intf,
+                                     bool transcode_only )
+    {
+        if( !instance )
+            instance = new SoutDialog( parent, p_intf, transcode_only );
+        else
+        {
+            instance->setParent( parent );
+            if( transcode_only != instance->b_transcode_only )
+            {
+                instance->toggleSout();
+                instance->b_transcode_only = transcode_only;
+            }
+        }
+        return instance;
+    };
+
+    virtual ~SoutDialog();
+
+    QString getMrl(){ return mrl; }
+
+private:
     SoutDialog( QWidget* parent, intf_thread_t *,
                 bool _transcode_only = false );
-    virtual ~SoutDialog() {}
+    static SoutDialog *instance;
 
-    QString getMrl();
-    //sout_gui_descr_t *sout;
-private:
     Ui::Sout ui;
     QPushButton *okButton;
     QString mrl;
index d3f092aae2d14f8486de2dfdbcc6f509501185e7..571cfa132f99a6b289009e73ff3d9f30011b41cc 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "dialogs/vlm.hpp"
 #include "dialogs/open.hpp"
+#include "dialogs/sout.hpp"
 
 #include <QString>
 #include <QComboBox>
@@ -49,13 +50,13 @@ static const char *psz_type[] = { "Broadcast", "Schedule", "VOD" };
 VLMDialog *VLMDialog::instance = NULL;
 
 VLMDialog::VLMDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
-{   
+{
     p_vlm = vlm_New( p_intf );
 
     if( !p_vlm )
     {
         msg_Warn( p_intf, "Couldn't build VLM object ");
-        return;   
+        return;
     }
     vlmWrapper = new VLMWrapper( p_vlm );
 
@@ -138,6 +139,7 @@ VLMDialog::VLMDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
     BUTTONACT( ui.clearButton, clearWidgets() );
     BUTTONACT( ui.saveButton, saveModifications() );
     BUTTONACT( ui.inputButton, selectInput() );
+    BUTTONACT( ui.outputButton, selectOutput() );
 }
 
 VLMDialog::~VLMDialog()
@@ -198,7 +200,7 @@ void VLMDialog::addVLMItem()
         typeShortName = "Bcast";
         vlmAwidget = new VLMBroadcast( name, inputText, outputText,
                                   b_checked, b_looped, this );
-        VLMWrapper::AddBroadcast( name, inputText, outputText, b_checked, b_looped ); 
+        VLMWrapper::AddBroadcast( name, inputText, outputText, b_checked, b_looped );
     break;
     case QVLM_VOD:
         typeShortName = "VOD";
@@ -248,6 +250,13 @@ void VLMDialog::selectInput()
     ui.inputLedit->setText( o->getMRL() );
 }
 
+void VLMDialog::selectOutput()
+{
+    SoutDialog *s = SoutDialog::getInstance( this, p_intf, false );
+    if( s->exec() == QDialog::Accepted )
+        ui.outputLedit->setText( s->getMrl() );
+}
+
 /* Object Modification */
 void VLMDialog::removeVLMItem( VLMAWidget *vlmObj )
 {
@@ -385,7 +394,7 @@ void VLMAWidget::toggleEnabled( bool b_enable )
 }
 
 /****************
- * VLMBroadcast 
+ * VLMBroadcast
  ****************/
 VLMBroadcast::VLMBroadcast( QString _name, QString _input, QString _output,
                             bool _enabled, bool _looped, VLMDialog *_parent)
@@ -411,7 +420,7 @@ VLMBroadcast::VLMBroadcast( QString _name, QString _input, QString _output,
     BUTTONACT( playButton, togglePlayPause() );
     BUTTONACT( stopButton, stop() );
     BUTTONACT( loopButton, toggleLoop() );
-    
+
     update();
 }
 
@@ -455,7 +464,7 @@ void VLMBroadcast::stop()
  * VLMSchedule
  ****************/
 VLMSchedule::VLMSchedule( QString name, QString input, QString output,
-                            bool enabled, VLMDialog *parent) 
+                            bool enabled, VLMDialog *parent)
             : VLMAWidget( name, input, output, enabled, parent, QVLM_Schedule )
 {
     nameLabel->setText( "Schedule: " + name );
@@ -477,7 +486,7 @@ VLMVod::VLMVod( QString name, QString input, QString output,
     mux = _mux;
     muxLabel = new QLabel;
     objLayout->addWidget( muxLabel, 1, 0 );
-    
+
     update();
 }
 
@@ -518,7 +527,7 @@ void VLMWrapper::EditBroadcast( const QString name, const QString input,
 {
     vlm_message_t *message;
     QString command;
-    
+
     command = "setup \"" + name + "\" inputdel all";
     vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
     vlm_MessageDelete( message );
@@ -551,7 +560,7 @@ void VLMWrapper::EnableItem( const QString name, bool b_enable )
     QString command = "setup \"" + name + ( b_enable ? " enable" : " disable" );
 }
 
-void VLMWrapper::ControlBroadcast( const QString name, int BroadcastStatus, 
+void VLMWrapper::ControlBroadcast( const QString name, int BroadcastStatus,
                                    unsigned int seek )
 {
     vlm_message_t *message;
@@ -588,7 +597,7 @@ void VLMWrapper::AddVod( const QString name, const QString input,
 }
 
 void VLMWrapper::EditVod( const QString name, const QString input,
-                          const QString output, 
+                          const QString output,
                           bool b_enabled,
                           const QString mux )
 {
index a4aad977d07fbe2cd8df91d2429f41f160b27b11..f0ff4bfa4af75564f77a312d3dc26b218beab404 100644 (file)
@@ -85,7 +85,7 @@ private:
 
     QVBoxLayout *vlmItemLayout;
     QWidget *vlmItemWidget;
-  
+
     QComboBox *mediatype;
     QDateTimeEdit *time, *date, *repeatTime;
     QSpinBox *scherepeatnumber, *repeatDays;
@@ -100,6 +100,7 @@ private slots:
     void showScheduleWidget( int );
     void selectVLMItem( int );
     void selectInput();
+    void selectOutput();
 };
 
 class VLMWrapper
@@ -131,7 +132,7 @@ private:
     static vlm_t *p_vlm;
 };
 
-class VLMAWidget : public QGroupBox 
+class VLMAWidget : public QGroupBox
 {
     Q_OBJECT
     friend class VLMDialog;
@@ -193,7 +194,7 @@ public:
     VLMSchedule( QString name, QString input, QString output, bool _enable, VLMDialog *parent );
     void update();
 private:
-    
+
 };
 
 #endif
index 07e9cff34dc67f3c93cfbc9626def3900cadf36b..d52c12850bc2d9b3fc5cd53101913986c1ee7682 100644 (file)
@@ -133,6 +133,7 @@ void DialogsProvider::customEvent( QEvent *event )
             updateDialog(); break;
 #endif
         case INTF_DIALOG_EXIT:
+            quit(); break;
         default:
            msg_Warn( p_intf, "unimplemented dialog" );
         }
@@ -414,10 +415,11 @@ void DialogsProvider::saveAPlaylist()
  * Sout emulation
  ****************************************************************************/
 
-void DialogsProvider::streamingDialog( QString mrl, bool b_transcode_only )
+void DialogsProvider::streamingDialog( QWidget *parent, QString mrl,
+                                       bool b_transcode_only )
 {
-    SoutDialog *s = new SoutDialog( p_intf->p_sys->p_mi, p_intf,
-                                                    b_transcode_only );
+    SoutDialog *s = SoutDialog::getInstance( parent, p_intf, b_transcode_only );
+
     if( s->exec() == QDialog::Accepted )
     {
         msg_Err( p_intf, "Sout mrl %s", qta( s->getMrl() ) );
@@ -430,7 +432,6 @@ void DialogsProvider::streamingDialog( QString mrl, bool b_transcode_only )
                          PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END,
                         -1, &psz_option, 1, VLC_TRUE, VLC_FALSE );
     }
-    delete s;
 }
 
 void DialogsProvider::openThenStreamingDialogs()
@@ -444,29 +445,6 @@ void DialogsProvider::openThenTranscodingDialogs()
     OpenDialog::getInstance( p_intf->p_sys->p_mi , p_intf, OPEN_AND_SAVE )
                                 ->showTab( 0 );
 }
-/*
-void DialogsProvider::streamingDialog()
-{
-    OpenDialog *o = new OpenDialog( p_intf->p_sys->p_mi, p_intf, true );
-    if ( o->exec() == QDialog::Accepted )
-    {
-        SoutDialog *s = new SoutDialog( p_intf->p_sys->p_mi, p_intf );
-        if( s->exec() == QDialog::Accepted )
-        {
-            msg_Err(p_intf, "mrl %s\n", qta(s->mrl));
-            /* Just do it
-            int i_len = strlen( qtu(s->mrl) ) + 10;
-            char *psz_option = (char*)malloc(i_len);
-            snprintf( psz_option, i_len - 1, ":sout=%s", qtu(s->mrl));
-
-            playlist_AddExt( THEPL, qtu( o->mrl ), "Streaming",
-                             PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END,
-                             -1, &psz_option, 1, VLC_TRUE, VLC_FALSE );
-        }
-        delete s;
-    }
-    delete o;
-}*/
 
 
 /****************************************************************************
index 9b66638739a82cadc2322d75537c4d9de21f7004..15ab94bdbfcb3ddc6acd92d60652a3d7d36b5c09 100644 (file)
@@ -95,6 +95,8 @@ class QVLCMenu;
 class DialogsProvider : public QObject
 {
     Q_OBJECT;
+    friend class QVLCMenu;
+
 public:
     static DialogsProvider *getInstance()
     {
@@ -121,11 +123,11 @@ public:
                                 EXT_FILTER_PLAYLIST,
                                 QString path = QString() );
 protected:
-    friend class QVLCMenu;
     QSignalMapper *menusMapper;
     QSignalMapper *menusUpdateMapper;
     QSignalMapper *SDMapper;
     void customEvent( QEvent *);
+
 private:
     DialogsProvider( intf_thread_t *);
     intf_thread_t *p_intf;
@@ -170,7 +172,8 @@ public slots:
     void PLAppendDir();
     void MLAppendDir();
 
-    void streamingDialog( QString mrl = "", bool b_stream = true );
+    void streamingDialog( QWidget *parent, QString mrl = "",
+            bool b_stream = true );
     void openThenStreamingDialogs();
     void openThenTranscodingDialogs();