]> git.sesse.net Git - vlc/commitdiff
Qt4 - Open and Streaming Dialogs.
authorJean-Baptiste Kempf <jb@videolan.org>
Thu, 5 Apr 2007 01:13:05 +0000 (01:13 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Thu, 5 Apr 2007 01:13:05 +0000 (01:13 +0000)
This commit should show the correct dialogs in the correct order. It keeps the previous behaviour of the "Streaming" from the "Media" menu.
/!\ The intelligence is surely not accurate and stream() may need to be redirected to playOrEnqueue as open() and enqueue() do in order to be correctly parsed before... Need a bit more knowledge on playlist to be sure.

modules/gui/qt4/dialogs/open.cpp
modules/gui/qt4/dialogs/open.hpp
modules/gui/qt4/dialogs_provider.cpp
modules/gui/qt4/dialogs_provider.hpp
modules/gui/qt4/menus.cpp
modules/gui/qt4/ui/open.ui
modules/gui/qt4/ui/open_file.ui

index 248ebfb6fbe853fc3a8daa51725f3083d1089505..dbe30ebd7a30f940af91d5ed96ef758e3c8b9b17 100644 (file)
 
 OpenDialog *OpenDialog::instance = NULL;
 
-OpenDialog::OpenDialog( QWidget *parent, intf_thread_t *_p_intf, bool modal ) :
-                                                QVLCDialog( parent, _p_intf )
+OpenDialog::OpenDialog( QWidget *parent, intf_thread_t *_p_intf, bool modal,
+                        bool _stream_after ) :  QVLCDialog( parent, _p_intf )
 {
     setModal( modal );
+    b_stream_after = _stream_after;
+
     ui.setupUi( this );
     setWindowTitle( qtr("Open" ) );
     resize( 500, 300);
@@ -56,14 +58,8 @@ OpenDialog::OpenDialog( QWidget *parent, intf_thread_t *_p_intf, bool modal ) :
     ui.Tab->addTab( captureOpenPanel, qtr( "Capture &Device" ) );
 
     ui.advancedFrame->hide();
-
     QMenu * openButtonMenu = new QMenu( "Open" );
-    openButtonMenu->addAction( qtr("&Enqueue"), this, SLOT( enqueue() ),
-                                QKeySequence( "Alt+E") );
-    openButtonMenu->addAction( qtr("&Stream"), this, SLOT( stream() ) ,
-                                QKeySequence( "Alt+T" ) );
 
-    ui.playButton->setMenu( openButtonMenu );
     /* Force MRL update on tab change */
     CONNECT( ui.Tab, currentChanged(int), this, signalCurrent());
 
@@ -73,7 +69,6 @@ OpenDialog::OpenDialog( QWidget *parent, intf_thread_t *_p_intf, bool modal ) :
     CONNECT( captureOpenPanel, mrlUpdated( QString ), this,
             updateMRL(QString) );
 
-
     CONNECT( fileOpenPanel, methodChanged( QString ),
              this, newMethod(QString) );
     CONNECT( netOpenPanel, methodChanged( QString ),
@@ -84,7 +79,19 @@ OpenDialog::OpenDialog( QWidget *parent, intf_thread_t *_p_intf, bool modal ) :
     CONNECT( ui.slaveText, textChanged(QString), this, updateMRL());
     CONNECT( ui.cacheSpinBox, valueChanged(int), this, updateMRL());
 
+    openButtonMenu->addAction( qtr("&Enqueue"), this, SLOT( enqueue() ),
+                                    QKeySequence( "Alt+E") );
+    openButtonMenu->addAction( qtr("&Play"), this, SLOT( play() ),
+                                    QKeySequence( "Alt+P" ) );
+    openButtonMenu->addAction( qtr("&Stream"), this, SLOT( stream() ) ,
+                                    QKeySequence( "Alt+S" ) );
+
+    ui.playButton->setMenu( openButtonMenu );
+
     BUTTONACT( ui.playButton, play());
+
+    if ( b_stream_after ) setAfter();
+
     BUTTONACT( ui.cancelButton, cancel());
     BUTTONACT( ui.advancedCheckBox , toggleAdvancedPanel() );
 
@@ -99,6 +106,20 @@ OpenDialog::~OpenDialog()
 {
 }
 
+void OpenDialog::setAfter()
+{
+    if (!b_stream_after )
+    {
+        ui.playButton->setText( qtr("&Play") );
+        BUTTONACT( ui.playButton, play() );
+    }
+    else
+    {
+        ui.playButton->setText( qtr("&Stream") );
+        BUTTONACT( ui.playButton, stream() );
+    }
+}
+
 void OpenDialog::showTab(int i_tab=0)
 {
     this->show();
@@ -111,6 +132,9 @@ void OpenDialog::signalCurrent() {
     }
 }
 
+/* Actions */
+
+/* If Cancel is pressed or escaped */
 void OpenDialog::cancel()
 {
     fileOpenPanel->clear();
@@ -119,10 +143,20 @@ void OpenDialog::cancel()
         reject();
 }
 
-void OpenDialog::close() 
+/* If EnterKey is pressed */
+void OpenDialog::close()
 {
-    play();
+    if ( !b_stream_after )
+    {
+        play();
+    }
+    else
+    {
+        stream();
+    }
 }
+
+/* Play button */
 void OpenDialog::play()
 {
     playOrEnqueue( false );
@@ -133,6 +167,13 @@ void OpenDialog::enqueue()
     playOrEnqueue( true );
 }
 
+void OpenDialog::stream()
+{
+    /* not finished FIXME */
+    THEDP->streamingDialog( mrl );
+}
+
+
 void OpenDialog::playOrEnqueue( bool b_enqueue = false )
 {
     this->toggleVisible();
@@ -175,11 +216,6 @@ void OpenDialog::playOrEnqueue( bool b_enqueue = false )
         accept();
 }
 
-void OpenDialog::stream()
-{
-//TODO. Policy not yet defined
-}
-
 void OpenDialog::toggleAdvancedPanel()
 {
     //FIXME does not work under Windows
index c4647f0a36d3a77357e42c029b6ffb9024799f7d..6a94a2da933fd13a6ac1db6e1af178ab77707e5e 100644 (file)
@@ -38,26 +38,34 @@ class OpenDialog : public QVLCDialog
 {
     Q_OBJECT;
 public:
-    static OpenDialog * getInstance( QWidget *parent, intf_thread_t *p_intf )
+    static OpenDialog * getInstance( QWidget *parent, intf_thread_t *p_intf,
+                                        bool _stream_after = false )
     {
         if( !instance)
-            instance = new OpenDialog( parent, p_intf, false );
+            instance = new OpenDialog( parent, p_intf, false, _stream_after );
+        else
+        {
+            instance->b_stream_after = _stream_after;
+            instance->setAfter();
+        }
         return instance;
     }
-    OpenDialog( QWidget *parent, intf_thread_t *, bool modal );
+    OpenDialog( QWidget *parent, intf_thread_t *, bool modal, 
+            bool stream_after = false);
     virtual ~OpenDialog();
 
     void showTab( int );
 
     QString mrl;
     QString mainMRL;
+
 public slots:
     void play();
     void stream();
+    void enqueue();
 private:
     static OpenDialog *instance;
     input_thread_t *p_input;
-    QString mrlSub;
 
     Ui::Open ui;
     FileOpenPanel *fileOpenPanel;
@@ -66,14 +74,17 @@ private:
     CaptureOpenPanel *captureOpenPanel;
 
     QString storedMethod;
+    QString mrlSub;
     int advHeight, mainHeight;
+    bool b_stream_after;
+    QStringList SeparateEntries( QString );
 
     void playOrEnqueue( bool );
-    QStringList SeparateEntries( QString );
+
 private slots:
+    void setAfter();
     void cancel();
     void close();
-    void enqueue();
     void toggleAdvancedPanel();
     void updateMRL( QString );
     void updateMRL();
index c0d8141410f383a64afd522c758a14c14a411508..da304ad4ea6d03e4fc95e97cf8b70ba152f80d51 100644 (file)
@@ -346,6 +346,29 @@ void DialogsProvider::MLAppendDir()
  * Sout emulation
  ****************************************************************************/
 
+void DialogsProvider::streamingDialog( QString mrl)
+{
+    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( mrl ), "Streaming",
+                         PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END,
+                        -1, &psz_option, 1, VLC_TRUE, VLC_FALSE );
+    }
+    delete s;
+}
+
+void DialogsProvider::openThenStreamingDialogs()
+{
+    OpenDialog::getInstance( p_intf->p_sys->p_mi , p_intf, true )->showTab( 0 );
+}
+/*
 void DialogsProvider::streamingDialog()
 {
     OpenDialog *o = new OpenDialog( p_intf->p_sys->p_mi, p_intf, true );
@@ -355,7 +378,7 @@ void DialogsProvider::streamingDialog()
         if( s->exec() == QDialog::Accepted )
         {
             msg_Err(p_intf, "mrl %s\n", qta(s->mrl));
-            /* Just do it */
+            /* 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));
@@ -367,7 +390,9 @@ void DialogsProvider::streamingDialog()
         delete s;
     }
     delete o;
-}
+}*/
+
+
 
 /****************************************************************************
  * Menus / Interaction
index 0b039fe8c7106352527466be18b6b4c6382d1409..b7b1918baa14cc2f00580f8a5eb604b5e2bba572 100644 (file)
@@ -137,7 +137,8 @@ public slots:
     void menuAction( QObject *);
     void menuUpdateAction( QObject *);
     void SDMenuAction( QString );
-    void streamingDialog();
+    void streamingDialog( QString mrl = "");
+    void openThenStreamingDialogs();
     void openPlaylist();
     void savePlaylist();
     void PLAppendDir();
index 1455516cc9bbb49a3811ed3a4b30904f941ec690..ec009adc94b54e8d66d10a336723537f51f2d4c8 100644 (file)
@@ -202,7 +202,7 @@ QMenu *QVLCMenu::FileMenu()
     DP_SADD( qtr("Open &Capture Device..." ), "", "", openCaptureDialog(),
             "Ctrl+C" );
     menu->addSeparator();
-    DP_SADD( qtr("&Streaming..."), "", "", streamingDialog(), "Ctrl+S" );
+    DP_SADD( qtr("&Streaming..."), "", "", openThenStreamingDialogs(), "Ctrl+S" );
     menu->addSeparator();
     DP_SADD( qtr("&Quit") , "", "", quit(), "Ctrl+Q");
     return menu;
index cb0d33dcc1d9543661df8d883613420eeb64731c..427d5107de18d214eb14c6a8a336d5866484fd17 100644 (file)
@@ -33,7 +33,7 @@
    <item>
     <widget class="QCheckBox" name="advancedCheckBox" >
      <property name="text" >
-      <string>&amp;Show more options</string>
+      <string>Show &amp;more options</string>
      </property>
     </widget>
    </item>
index 88e38279532c424f9ca75c3840ea65b7a6b0d7ba..17c80802b06103b8764a13ae234f1bd523b0424b 100644 (file)
@@ -94,7 +94,7 @@
    <item row="3" column="0" colspan="2" >
     <widget class="QCheckBox" name="subCheckBox" >
      <property name="text" >
-      <string>Use a subtitles file</string>
+      <string>Use a sub&amp;titles file</string>
      </property>
     </widget>
    </item>
          </size>
         </property>
         <property name="currentIndex" >
-         <number>0</number>
+         <number>-1</number>
         </property>
         <property name="insertPolicy" >
          <enum>QComboBox::NoInsert</enum>