]> git.sesse.net Git - vlc/commitdiff
Qt4 - Open: clean again, and fix the clear() bug.
authorJean-Baptiste Kempf <jb@videolan.org>
Fri, 9 Nov 2007 02:30:53 +0000 (02:30 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Fri, 9 Nov 2007 02:30:53 +0000 (02:30 +0000)
modules/gui/qt4/dialogs/open.cpp
modules/gui/qt4/dialogs/open.hpp
modules/gui/qt4/dialogs_provider.hpp

index 75467c344cbabc6d87f110487cf171a744aa1d55..b960d35c4ace478964419be5efa36caf9f2ada9b 100644 (file)
@@ -112,13 +112,13 @@ 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) );
+                                                 this, newCachingMethod(QString) );
     CONNECT( netOpenPanel, methodChanged( QString ),
-                                                 this, newMethod(QString) );
+                                                 this, newCachingMethod(QString) );
     CONNECT( discOpenPanel, methodChanged( QString ),
-                                                 this, newMethod(QString) );
+                                                 this, newCachingMethod(QString) );
     CONNECT( captureOpenPanel, methodChanged( QString ),
-                                                 this, newMethod(QString) );
+                                                 this, newCachingMethod(QString) );
 
     /* Advanced frame Connects */
     CONNECT( ui.slaveText, textChanged(QString), this, updateMRL());
@@ -135,7 +135,7 @@ OpenDialog::OpenDialog( QWidget *parent, intf_thread_t *_p_intf, bool modal,
 
     /* Initialize caching */
     storedMethod = "";
-    newMethod("file-caching");
+    newCachingMethod("file-caching");
 
     mainHeight = advHeight = 0;
 }
@@ -179,6 +179,31 @@ void OpenDialog::signalCurrent() {
         (dynamic_cast<OpenPanel *>( ui.Tab->currentWidget() ))->updateMRL();
 }
 
+void OpenDialog::toggleAdvancedPanel()
+{
+    //FIXME does not work under Windows
+    if( ui.advancedFrame->isVisible() ) {
+        ui.advancedFrame->hide();
+#ifndef WIN32
+        setMinimumHeight(1);
+        resize( width(), mainHeight );
+#endif
+    } else {
+#ifndef WIN32
+        if( mainHeight == 0 )
+            mainHeight = height();
+#endif
+
+        ui.advancedFrame->show();
+#ifndef WIN32
+        if( advHeight == 0 ) {
+            advHeight = height() - mainHeight;
+        }
+        resize( width(), mainHeight + advHeight );
+#endif
+    }
+}
+
 /***********
  * Actions *
  ***********/
@@ -186,8 +211,9 @@ void OpenDialog::signalCurrent() {
 /* If Cancel is pressed or escaped */
 void OpenDialog::cancel()
 {
-    fileOpenPanel->clear();
-    this->toggleVisible();
+    for( int i = 0; i <= OPEN_TAB_MAX; i++ ) 
+        dynamic_cast<OpenPanel*>(ui.Tab->widget( i ))->clear();
+    toggleVisible();
     if( isModal() ) reject();
 }
 
@@ -230,7 +256,7 @@ void OpenDialog::stream( bool b_transcode_only )
 
 void OpenDialog::finish( bool b_enqueue = false )
 {
-    this->toggleVisible();
+    toggleVisible();
     mrl = ui.advancedLineInput->text();
 
     if( !isModal() )
@@ -240,18 +266,17 @@ void OpenDialog::finish( bool b_enqueue = false )
         {
             bool b_start = !i && !b_enqueue;
             input_item_t *p_input;
-            const char *psz_utf8 = qtu( tempMRL[i] );
 
-            p_input = input_ItemNew( p_intf, psz_utf8, NULL );
+            p_input = input_ItemNew( p_intf, qtu( tempMRL[i] ), NULL );
 
             /* Insert options */
             while( i + 1 < tempMRL.size() && tempMRL[i + 1].startsWith( ":" ) )
             {
                 i++;
-                psz_utf8 = qtu( tempMRL[i] );
-                input_ItemAddOption( p_input, psz_utf8 );
+                input_ItemAddOption( p_input, qtu( tempMRL[i] ) );
             }
 
+            /* Switch between enqueuing and starting the item */
             if( b_start )
             {
                 playlist_AddInput( THEPL, p_input,
@@ -261,7 +286,7 @@ void OpenDialog::finish( bool b_enqueue = false )
             else
             {
                 playlist_AddInput( THEPL, p_input,
-                                   PLAYLIST_APPEND|PLAYLIST_PREPARSE,
+                                   PLAYLIST_APPEND | PLAYLIST_PREPARSE,
                                    PLAYLIST_END, VLC_TRUE, VLC_FALSE );
             }
         }
@@ -270,29 +295,12 @@ void OpenDialog::finish( bool b_enqueue = false )
         accept();
 }
 
-void OpenDialog::toggleAdvancedPanel()
-{
-    //FIXME does not work under Windows
-    if( ui.advancedFrame->isVisible() ) {
-        ui.advancedFrame->hide();
-#ifndef WIN32
-        setMinimumHeight(1);
-        resize( width(), mainHeight );
-#endif
-    } else {
-#ifndef WIN32
-        if( mainHeight == 0 )
-            mainHeight = height();
-#endif
 
-        ui.advancedFrame->show();
-#ifndef WIN32
-        if( advHeight == 0 ) {
-            advHeight = height() - mainHeight;
-        }
-        resize( width(), mainHeight + advHeight );
-#endif
-    }
+/* Update the MRL */
+void OpenDialog::updateMRL( QString tempMRL )
+{
+    mainMRL = tempMRL;
+    updateMRL();
 }
 
 void OpenDialog::updateMRL() {
@@ -312,18 +320,12 @@ void OpenDialog::updateMRL() {
     ui.advancedLineInput->setText(mrl);
 }
 
-void OpenDialog::updateMRL(QString tempMRL)
-{
-    mainMRL = tempMRL;
-    updateMRL();
-}
-
-void OpenDialog::newMethod(QString method)
+void OpenDialog::newCachingMethod( QString method )
 {
     if( method != storedMethod ) {
         storedMethod = method;
-        int i_value = config_GetInt( p_intf, qta(storedMethod) );
-        ui.cacheSpinBox->setValue(i_value);
+        int i_value = config_GetInt( p_intf, qta( storedMethod ) );
+        ui.cacheSpinBox->setValue( i_value );
     }
 }
 
index 3afe845a209ba7ca2cdb2fd7f8037218746cc67c..3e083c5a0ebf16a00134eb18d91b05a0fdb4450e 100644 (file)
@@ -92,7 +92,7 @@ private slots:
     void toggleAdvancedPanel();
     void updateMRL( QString );
     void updateMRL();
-    void newMethod(QString);
+    void newCachingMethod( QString );
     void signalCurrent();
 };
 
index 47f4645334e11bb1e268c644359c9552ec67c7aa..662fbea066faff260082661aaf1e8c3e2939a9a5 100644 (file)
@@ -74,7 +74,8 @@ enum {
     OPEN_FILE_TAB,
     OPEN_DISC_TAB,
     OPEN_NETWORK_TAB,
-    OPEN_CAPTURE_TAB
+    OPEN_CAPTURE_TAB,
+    OPEN_TAB_MAX
 };
 
 enum {