]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/open.cpp
Qt4 - Sprefs: cosmetic and string change.
[vlc] / modules / gui / qt4 / components / open.cpp
index a19d51abc53793ebc53021ccea4a57f21b4cc9e9..c55c6e97f172f83d0b08a36616a25c8bb8f8d3bd 100644 (file)
@@ -31,7 +31,7 @@
 #include "components/open.hpp"
 #include "dialogs/open.hpp"
 #include "dialogs_provider.hpp"
-#include "util/customwidgets.hpp"
+#include "components/preferences_widgets.hpp"
 
 #include <QFileDialog>
 #include <QDialogButtonBox>
@@ -95,10 +95,8 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
 #if HAS_QT43
     lineFileEdit = dialogBox->findChildren<QLineEdit*>()[0];
 #else
-    // FIXME
     lineFileEdit = dialogBox->findChildren<QLineEdit*>()[1];
 #endif
-
     /* Make a list of QLabel inside the QFileDialog to access the good ones */
     QList<QLabel *> listLabel = dialogBox->findChildren<QLabel*>();
 
@@ -135,23 +133,14 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     BUTTONACT( ui.subCheckBox, toggleSubtitleFrame());
 
     CONNECT( lineFileEdit, textChanged( QString ), this, updateMRL() );
-
     CONNECT( ui.subInput, textChanged( QString ), this, updateMRL() );
-    CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this,
-                                                            updateMRL() );
-    CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this,
-                                                            updateMRL() );
-}
-
-FileOpenPanel::~FileOpenPanel()
-{}
-
-QStringList FileOpenPanel::browse( QString help )
-{
-    return THEDP->showSimpleOpen( help );
+    CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this, updateMRL() );
+    CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this, updateMRL() );
 }
 
+FileOpenPanel::~FileOpenPanel(){}
 
+/* Show a fileBrowser to select a subtitle */
 void FileOpenPanel::browseFileSub()
 {
     // FIXME Handle selection of more than one subtitles file
@@ -163,6 +152,7 @@ void FileOpenPanel::browseFileSub()
     updateMRL();
 }
 
+/* Update the current MRL */
 void FileOpenPanel::updateMRL()
 {
     QString mrl = "";
@@ -184,11 +174,10 @@ void FileOpenPanel::updateMRL()
     emit methodChanged( "file-caching" );
 }
 
-
 /* Function called by Open Dialog when clicke on Play/Enqueue */
 void FileOpenPanel::accept()
 {
-    //FIXME set the completer
+    //TODO set the completer
     const char *psz_filepath = config_GetPsz( p_intf, "qt-filedialog-path" );
     if( ( NULL == psz_filepath )
       || strcmp( psz_filepath, qtu( dialogBox->directory().absolutePath() )) )
@@ -198,7 +187,6 @@ void FileOpenPanel::accept()
                        qtu( dialogBox->directory().absolutePath() ) );
     }
     delete psz_filepath;
-
 }
 
 void FileOpenBox::accept()
@@ -229,7 +217,15 @@ DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
 {
     ui.setupUi( this );
 
-    char *psz_discpath = config_GetPsz( p_intf, "qt-discdialog-path" );
+    /* Get the default configuration path for the devices */
+    psz_dvddiscpath = config_GetPsz( p_intf, "dvd" );
+    psz_vcddiscpath = config_GetPsz( p_intf, "vcd" );
+    psz_cddadiscpath = config_GetPsz( p_intf, "cd-audio" );
+
+    /* State to avoid overwritting the users changes with the configuration */
+    b_firstdvd = true;
+    b_firstvcd = true;
+    b_firstcdda = true;
 
 #if WIN32 /* Disc drives probing for Windows */
     char szDrives[512];
@@ -248,15 +244,11 @@ DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
         }
         SetErrorMode(oldMode);
     }
-
-    int index = ui.deviceCombo->findText( qfu( psz_discpath ) );
-    if( index != -1 ) ui.deviceCombo->setCurrentIndex( index );
-
-#endif /* Disc Probing under Windows */
-
-    ui.deviceCombo->setEditText( qfu( psz_discpath ) );
-
-    delete psz_discpath;
+#else /* Use a Completer under Linux */
+    QCompleter *discCompleter = new QCompleter( this );
+    discCompleter->setModel( new QDirModel( discCompleter ) );
+    ui.deviceCombo->setCompleter( discCompleter );
+#endif
 
     /* CONNECTs */
     BUTTONACT( ui.dvdRadioButton, updateButtons() );
@@ -270,21 +262,46 @@ DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     CONNECT( ui.chapterSpin, valueChanged( int ), this, updateMRL());
     CONNECT( ui.audioSpin, valueChanged( int ), this, updateMRL());
     CONNECT( ui.subtitlesSpin, valueChanged( int ), this, updateMRL());
+
+    /* Run once the updateButtons function in order to fill correctly the comboBoxes */    
+    updateButtons();
 }
 
 DiscOpenPanel::~DiscOpenPanel()
-{}
+{
+    delete psz_dvddiscpath;
+    delete psz_vcddiscpath;
+    delete psz_cddadiscpath;
+}
 
 void DiscOpenPanel::clear()
 {
     ui.titleSpin->setValue( 0 );
     ui.chapterSpin->setValue( 0 );
+    b_firstcdda = true;
+    b_firstdvd = true;
+    b_firstvcd = true;
 }
 
+#ifdef WIN32
+    #define setDrive( psz_name ) {\
+    int index = ui.deviceCombo->findText( qfu( psz_name ) ); \
+    if( index != -1 ) ui.deviceCombo->setCurrentIndex( index );}
+#else
+    #define setDrive( psz_name ) {\
+    ui.deviceCombo->setEditText( qfu( psz_name ) ); }
+#endif
+
+/* update the buttons according the type of device */
 void DiscOpenPanel::updateButtons()
 {
     if ( ui.dvdRadioButton->isChecked() )
     {
+        if( b_firstdvd )
+        {
+            setDrive( psz_dvddiscpath );
+            b_firstdvd = false;
+        }
         ui.titleLabel->setText( qtr("Title") );
         ui.chapterLabel->show();
         ui.chapterSpin->show();
@@ -292,13 +309,23 @@ void DiscOpenPanel::updateButtons()
     }
     else if ( ui.vcdRadioButton->isChecked() )
     {
+        if( b_firstvcd )
+        {
+            setDrive( psz_vcddiscpath );
+            b_firstvcd = false;
+        }
         ui.titleLabel->setText( qtr("Entry") );
         ui.chapterLabel->hide();
         ui.chapterSpin->hide();
         ui.diskOptionBox_2->show();
     }
-    else
+    else /* CDDA */
     {
+        if( b_firstcdda )
+        {
+            setDrive( psz_cddadiscpath );
+            b_firstcdda = false;
+        }
         ui.titleLabel->setText( qtr("Track") );
         ui.chapterLabel->hide();
         ui.chapterSpin->hide();
@@ -308,7 +335,7 @@ void DiscOpenPanel::updateButtons()
     updateMRL();
 }
 
-
+/* Update the current MRL */
 void DiscOpenPanel::updateMRL()
 {
     QString mrl = "";
@@ -372,11 +399,7 @@ void DiscOpenPanel::browseDevice()
 }
 
 void DiscOpenPanel::accept()
-{
-    /* set dialog box current directory as last known path */
-    config_PutPsz( p_intf, "qt-discdialog-path",
-                       qtu( ui.deviceCombo->currentText() ) );
-}
+{}
 
 /**************************************************************************
  * Open Network streams and URL pages                                     *
@@ -390,7 +413,7 @@ NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     CONNECT( ui.protocolCombo, currentIndexChanged( int ),
              this, updateProtocol( int ) );
     CONNECT( ui.portSpin, valueChanged( int ), this, updateMRL() );
-    CONNECT( ui.addressText, textChanged( QString ), this, updateAddress());
+    CONNECT( ui.addressText, textChanged( QString ), this, updateMRL());
     CONNECT( ui.timeShift, clicked(), this, updateMRL());
     CONNECT( ui.ipv6, clicked(), this, updateMRL());
 
@@ -409,6 +432,7 @@ NetOpenPanel::~NetOpenPanel()
 void NetOpenPanel::clear()
 {}
 
+/* update the widgets according the type of protocol */
 void NetOpenPanel::updateProtocol( int idx ) {
     QString addr = ui.addressText->text();
     QString proto = ui.protocolCombo->itemData( idx ).toString();
@@ -427,10 +451,6 @@ void NetOpenPanel::updateProtocol( int idx ) {
     updateMRL();
 }
 
-void NetOpenPanel::updateAddress() {
-    updateMRL();
-}
-
 void NetOpenPanel::updateMRL() {
     QString mrl = "";
     QString addr = ui.addressText->text();