]> git.sesse.net Git - vlc/commitdiff
* Made open and sout QDialogs
authorClément Stenac <zorglub@videolan.org>
Sun, 3 Dec 2006 20:33:02 +0000 (20:33 +0000)
committerClément Stenac <zorglub@videolan.org>
Sun, 3 Dec 2006 20:33:02 +0000 (20:33 +0000)
* Added a minimal streaming feature

modules/gui/qt4/dialogs/open.cpp
modules/gui/qt4/dialogs/open.hpp
modules/gui/qt4/dialogs/sout.cpp
modules/gui/qt4/dialogs/sout.hpp
modules/gui/qt4/dialogs_provider.cpp
modules/gui/qt4/util/qvlcframe.hpp

index 4dc589db833d04bd30155c89faaf6644e8b22428..e9a532a14254194a6f9e8d48ff6146bb1bfb454d 100644 (file)
 
 OpenDialog *OpenDialog::instance = NULL;
 
-OpenDialog::OpenDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
+OpenDialog::OpenDialog( QWidget *parent, intf_thread_t *_p_intf, bool modal ) :
+                                                QVLCDialog( parent, _p_intf )
 {
     setWindowTitle( qtr("Open" ) );
+    setModal( modal );
     ui.setupUi( this );
     fileOpenPanel = new FileOpenPanel(this , p_intf );
     diskOpenPanel = new DiskOpenPanel(this , p_intf );
@@ -96,27 +98,30 @@ void OpenDialog::cancel()
 {
     fileOpenPanel->clear();
     this->toggleVisible();
+    if( isModal() )
+        reject();
 }
 
 void OpenDialog::ok()
 {
-    QString mrl = ui.advancedLineInput->text();
+    this->toggleVisible();
+    mrl = ui.advancedLineInput->text();
     QStringList tempMRL = mrl.split(" ");
-    for( size_t i = 0 ; i< tempMRL.size(); i++ )
+    if( !isModal() )
     {
-         const char * psz_utf8 = qtu( tempMRL[i] );
-         /* Play the first one, parse and enqueue the other ones */
-         playlist_Add( THEPL, psz_utf8, NULL,
-                       PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO) |
-                       ( i ? PLAYLIST_PREPARSE : 0 ),
-                       PLAYLIST_END, VLC_TRUE );
-      }
-
-    this->toggleVisible();
-}
+        for( size_t i = 0 ; i< tempMRL.size(); i++ )
+        {
+             const char * psz_utf8 = qtu( tempMRL[i] );
+             /* Play the first one, parse and enqueue the other ones */
+             playlist_Add( THEPL, psz_utf8, NULL,
+                           PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO) |
+                           ( i ? PLAYLIST_PREPARSE : 0 ),
+                           PLAYLIST_END, VLC_TRUE );
+         }
 
-void OpenDialog::changedTab()
-{
+    }
+    else
+        accept();
 }
 
 void OpenDialog::toggleAdvancedPanel()
@@ -139,7 +144,7 @@ void OpenDialog::toggleAdvancedPanel()
 }
 
 void OpenDialog::updateMRL() {
-    QString mrl = mainMRL;
+    mrl = mainMRL;
     if( ui.slaveCheckbox->isChecked() ) {
         mrl += " :input-slave=" + ui.slaveText->text();
     }
index ace6224dd6d02fffdd8bda65ecfd7d6362a81b5c..824b4dc625672d840ead33fe5898a682107ddace 100644 (file)
 #include <QBoxLayout>
 #include <QString>
 
-class OpenDialog : public QVLCFrame
+class OpenDialog : public QVLCDialog
 {
     Q_OBJECT;
 public:
-    static OpenDialog * getInstance( intf_thread_t *p_intf )
+    static OpenDialog * getInstance( QWidget *parent, intf_thread_t *p_intf )
     {
         if( !instance)
-            instance = new OpenDialog( p_intf);
+            instance = new OpenDialog( parent, p_intf, false );
         return instance;
     }
+    OpenDialog( QWidget *parent, intf_thread_t *, bool modal );
     virtual ~OpenDialog();
 
     void showTab( int );
 
+    QString mrl;
     QString mainMRL;
 private:
-    OpenDialog( intf_thread_t * );
     static OpenDialog *instance;
     input_thread_t *p_input;
     QString mrlSub;
@@ -65,7 +66,6 @@ private:
 private slots:
     void cancel();
     void ok();
-    void changedTab();
     void toggleAdvancedPanel();
     void updateMRL(QString);
     void updateMRL();
index 5d1227d610b5686982ffb362a9367156b8bad133..aa0b0bcdcadaaafb8ca93179dee29b2a89df807e 100644 (file)
 
 #include <QFileDialog>
 
-SoutDialog::SoutDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
+SoutDialog::SoutDialog( QWidget *parent, intf_thread_t *_p_intf ) :
+                                                QVLCDialog( parent,  _p_intf )
 {
     //setWindowTitle( qtr( "Stream output") );
-
+    setModal( true );
     /* UI stuff */
     ui.setupUi( this );
 #define ADD_VCODEC( name, fcc) ui.vCodec->addItem( name, QVariant( fcc ) );
@@ -88,6 +89,9 @@ SoutDialog::SoutDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
     CB( soutAll ); CS( ttl ); CT( sapName ); CT( sapGroup );
 
     CONNECT( ui.fileSelectButton, clicked(), this, fileBrowse() );
+
+    BUTTONACT( ui.okButton, ok());
+    BUTTONACT( ui.cancelButton, cancel());
 }
 
 void SoutDialog::fileBrowse()
@@ -99,9 +103,13 @@ void SoutDialog::fileBrowse()
 
 void SoutDialog::ok()
 {
+    mrl = ui.mrlEdit->text();
+    accept();
 }
 void SoutDialog::cancel()
 {
+    mrl = ui.mrlEdit->text();
+    reject();
 }
 
 void SoutDialog::updateMRL()
@@ -169,6 +177,7 @@ end:
     sout_chain_t* p_chain = streaming_ChainNew();
     streaming_GuiDescToChain( VLC_OBJECT(p_intf), p_chain, &pd );
     char *psz_mrl = streaming_ChainToPsz( p_chain );
+
     ui.mrlEdit->setText( qfu( strdup(psz_mrl) ) );
     free( pd.psz_acodec ); free( pd.psz_vcodec ); free( pd.psz_scodec );
     free( pd.psz_file );free( pd.psz_http ); free( pd.psz_mms );
index 94b06e38a408aeb37f861c3661f5aa6b54fd1986..f6fa510cf6b73136132ec37b7d09c41a4391bfd5 100644 (file)
@@ -31,11 +31,14 @@ class QCheckBox;
 class QGridLayout;
 class QTextEdit;
 
-class SoutDialog : public QVLCFrame
+class SoutDialog : public QVLCDialog
 {
     Q_OBJECT;
 public:
-    SoutDialog( intf_thread_t * );
+    SoutDialog( QWidget* parent, intf_thread_t * );
+    virtual ~SoutDialog() {}
+
+    QString mrl;
 private:
     Ui::Sout ui;
 public slots:
index e241315f4630498150c093bb822cf4775ab1b6d2..21b39b3d8f4951172b7ba64dc03dfc151730efa3 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "qt4.hpp"
 #include "dialogs_provider.hpp"
+#include "main_interface.hpp"
 #include "menus.hpp"
 #include <vlc_intf_strings.h>
 
@@ -119,7 +120,7 @@ void DialogsProvider::MLAppendDialog()
 }
 void DialogsProvider::openDialog( int i_tab )
 {
-    OpenDialog::getInstance( p_intf )->showTab( i_tab );
+    OpenDialog::getInstance( p_intf->p_sys->p_mi  , p_intf )->showTab( i_tab );
 }
 
 void DialogsProvider::doInteraction( intf_dialog_args_t *p_arg )
@@ -167,7 +168,25 @@ void DialogsProvider::MediaInfoDialog()
 
 void DialogsProvider::streamingDialog()
 {
-    (new SoutDialog( p_intf ))->show();
+    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 );
+        }
+        delete s;
+    }
+    delete o;
 }
 
 void DialogsProvider::prefsDialog()
index 8d004ef5ae55c280fdf6be93c76ee1ab631a92fd..f0f489291aed773a88d350ff373af72898c411fb 100644 (file)
@@ -24,6 +24,7 @@
 #define _QVLCFRAME_H_
 
 #include <QWidget>
+#include <QDialog>
 #include <QSpacerItem>
 #include <QHBoxLayout>
 #include <QApplication>
 class QVLCFrame : public QWidget
 {
 public:
-    static void fixStyle( QWidget *w)
-    {
-         QStyle *style = qApp->style();
-#if 0
-        // Plastique is too dark.
-        /// theming ? getting KDE data ? ?
-        if( qobject_cast<QPlastiqueStyle *>(style) )
-        {
-            QPalette plt( w->palette() );
-            plt.setColor( QPalette::Active, QPalette::Highlight, Qt::gray );
-            QColor vlg = (Qt::lightGray);
-            vlg = vlg.toHsv();
-            vlg.setHsv( vlg.hue(), vlg.saturation(), 235  );
-            plt.setColor( QPalette::Active, QPalette::Window, vlg );
-            plt.setColor( QPalette::Inactive, QPalette::Window, vlg );
-            plt.setColor( QPalette::Inactive, QPalette::Button, vlg );
-            plt.setColor( QPalette::Active, QPalette::Button, vlg );
-            plt.setColor( QPalette::Active, QPalette::Text, Qt::yellow );
-            w->setPalette( plt );
-        }
-#endif
-    }
     static QHBoxLayout* doButtons( QWidget *w, QBoxLayout *l,
                                QPushButton **defaul, char *psz_default,
                                QPushButton **alt, char *psz_alt,
@@ -98,9 +77,7 @@ public:
     };
 
     QVLCFrame( intf_thread_t *_p_intf ) : QWidget( NULL ), p_intf( _p_intf )
-    {
-        fixStyle( this );
-    };
+    {    };
     virtual ~QVLCFrame()   {};
 
     void toggleVisible()
@@ -129,13 +106,28 @@ protected:
     }
 };
 
-class QVLCMW : public QMainWindow
+class QVLCDialog : public QDialog
 {
 public:
-    QVLCMW( intf_thread_t *_p_intf ) : QMainWindow( NULL ), p_intf( _p_intf )
+    QVLCDialog( QWidget* parent, intf_thread_t *_p_intf ) :
+                                    QDialog( parent ), p_intf( _p_intf )
+    {}
+    virtual ~QVLCDialog() {};
+    void toggleVisible()
     {
-        QVLCFrame::fixStyle( this );
+        if( isVisible() ) hide();
+        else show();
     }
+
+protected:
+    intf_thread_t *p_intf;
+};
+
+class QVLCMW : public QMainWindow
+{
+public:
+    QVLCMW( intf_thread_t *_p_intf ) : QMainWindow( NULL ), p_intf( _p_intf )
+    {    }
     virtual ~QVLCMW() {};
     void toggleVisible()
     {