]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/open_panels.cpp
Qt: NetOpenPanel: add drop-down list
[vlc] / modules / gui / qt4 / components / open_panels.cpp
index 61c397ffe75236d161d0b44c8de0a6d6ca0761de..ae75fc6b2e362fa19cab554387be2be37b2bb876 100644 (file)
@@ -36,6 +36,7 @@
 #include "dialogs_provider.hpp" /* Open Subtitle file */
 #include "util/qt_dirs.hpp"
 #include <vlc_intf_strings.h>
+#include <vlc_modules.h>
 
 #include <QFileDialog>
 #include <QDialogButtonBox>
@@ -271,7 +272,11 @@ void FileOpenPanel::updateMRL()
                 fileList << ui.fileListWidg->item( i )->text();
         }
     else
+    {
         fileList = dialogBox->selectedFiles();
+        for( int i = 0; i < fileList.count(); i++ )
+            fileList[i] = toNativeSeparators( fileList[i] );
+    }
 
     /* Options */
     if( ui.subCheckBox->isChecked() &&  !ui.subInput->text().isEmpty() ) {
@@ -325,9 +330,7 @@ DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     psz_cddadiscpath = var_InheritString( p_intf, "cd-audio" );
 
     /* State to avoid overwritting the users changes with the configuration */
-    b_firstdvd = true;
-    b_firstvcd = true;
-    b_firstcdda = true;
+    m_discType = None;
 
     ui.browseDiscButton->setToolTip( qtr( I_DEVICE_TOOLTIP ));
     ui.deviceCombo->setToolTip( qtr(I_DEVICE_TOOLTIP) );
@@ -387,9 +390,7 @@ void DiscOpenPanel::clear()
     ui.chapterSpin->setValue( 0 );
     ui.subtitlesSpin->setValue( -1 );
     ui.audioSpin->setValue( -1 );
-    b_firstcdda = true;
-    b_firstdvd = true;
-    b_firstvcd = true;
+    m_discType = None;
 }
 
 #ifdef WIN32
@@ -406,10 +407,10 @@ void DiscOpenPanel::updateButtons()
 {
     if ( ui.dvdRadioButton->isChecked() )
     {
-        if( b_firstdvd )
+        if( m_discType != Dvd )
         {
             setDrive( psz_dvddiscpath );
-            b_firstdvd = false;
+            m_discType = Dvd;
         }
         ui.titleLabel->setText( qtr("Title") );
         ui.chapterLabel->show();
@@ -419,10 +420,10 @@ void DiscOpenPanel::updateButtons()
     }
     else if ( ui.vcdRadioButton->isChecked() )
     {
-        if( b_firstvcd )
+        if( m_discType != Vcd )
         {
             setDrive( psz_vcddiscpath );
-            b_firstvcd = false;
+            m_discType = Vcd;
         }
         ui.titleLabel->setText( qtr("Entry") );
         ui.chapterLabel->hide();
@@ -432,10 +433,10 @@ void DiscOpenPanel::updateButtons()
     }
     else /* CDDA */
     {
-        if( b_firstcdda )
+        if( m_discType != Cdda )
         {
             setDrive( psz_cddadiscpath );
-            b_firstcdda = false;
+            m_discType = Cdda;
         }
         ui.titleLabel->setText( qtr("Track") );
         ui.chapterLabel->hide();
@@ -538,19 +539,22 @@ NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     ui.setupUi( this );
 
     /* CONNECTs */
-    CONNECT( ui.urlText, textChanged( const QString& ), this, updateMRL());
+    CONNECT( ui.urlComboBox->lineEdit(), textChanged( const QString& ), this, updateMRL());
+    CONNECT( ui.urlComboBox, currentIndexChanged( const QString& ), this, updateMRL());
 
     if( var_InheritBool( p_intf, "qt-recentplay" ) )
     {
         mrlList = new QStringListModel(
                 getSettings()->value( "Open/netMRL" ).toStringList() );
-        QCompleter *completer = new QCompleter( mrlList, this );
-        ui.urlText->setCompleter( completer );
-
-        CONNECT( ui.urlText, editingFinished(), this, updateCompleter() );
+        ui.urlComboBox->setModel( mrlList );
+        ui.urlComboBox->clearEditText();
+        CONNECT( ui.urlComboBox->lineEdit(), editingFinished(), this, updateModel() );
     }
     else
         mrlList = NULL;
+
+    ui.urlComboBox->setValidator( new UrlValidator( this ) );
+    ui.urlComboBox->setFocus();
 }
 
 NetOpenPanel::~NetOpenPanel()
@@ -598,7 +602,7 @@ void NetOpenPanel::updateMRL()
         { "udp",   "udp"   },
     };
 
-    QString url = ui.urlText->text();
+    QString url = ui.urlComboBox->lineEdit()->text();
     if( !url.contains( "://") )
         return; /* nothing to do this far */
 
@@ -615,15 +619,29 @@ void NetOpenPanel::updateMRL()
     emit mrlUpdated( qsl, "" );
 }
 
-void NetOpenPanel::updateCompleter()
+void NetOpenPanel::updateModel()
 {
     assert( mrlList );
     QStringList tempL = mrlList->stringList();
-    if( !tempL.contains( ui.urlText->text() ) )
-        tempL.append( ui.urlText->text() );
+    if( !tempL.contains( ui.urlComboBox->lineEdit()->text() ) )
+        tempL.append( ui.urlComboBox->lineEdit()->text() );
     mrlList->setStringList( tempL );
 }
 
+void UrlValidator::fixup( QString& str ) const
+{
+    str = str.trimmed();
+}
+
+QValidator::State UrlValidator::validate( QString& str, int& pos ) const
+{
+    if( str.contains( ' ' ) )
+        return QValidator::Invalid;
+    if( !str.contains( "://" ) )
+        return QValidator::Intermediate;
+    return QValidator::Acceptable;
+}
+
 /**************************************************************************
  * Open Capture device ( DVB, PVR, V4L, and similar )                     *
  **************************************************************************/
@@ -714,12 +732,14 @@ void CaptureOpenPanel::initialize()
     bdac = new QRadioButton( "DVB-C" );
     bdat = new QRadioButton( "DVB-T" );
     bdaa = new QRadioButton( "ATSC" );
+    bdaq = new QRadioButton( "Clear QAM" );
 
     bdaDevLayout->addWidget( bdaTypeLabel, 0, 0 );
     bdaDevLayout->addWidget( bdas, 0, 1 );
     bdaDevLayout->addWidget( bdac, 0, 2 );
     bdaDevLayout->addWidget( bdat, 0, 3 );
     bdaDevLayout->addWidget( bdaa, 0, 4 );
+    bdaDevLayout->addWidget( bdaq, 0, 5 );
 
     /* bda Props */
     QLabel *bdaFreqLabel =
@@ -762,10 +782,12 @@ void CaptureOpenPanel::initialize()
     BUTTONACT( bdat, updateButtons() );
     BUTTONACT( bdac, updateButtons() );
     BUTTONACT( bdaa, updateButtons() );
+    BUTTONACT( bdaq, updateButtons() );
     BUTTONACT( bdas, updateMRL() );
     BUTTONACT( bdat, updateMRL() );
     BUTTONACT( bdac, updateMRL() );
     BUTTONACT( bdaa, updateMRL() );
+    BUTTONACT( bdaq, updateMRL() );
     }
 
 #else /* WIN32 */
@@ -893,7 +915,7 @@ void CaptureOpenPanel::initialize()
     jackPropLayout->addWidget( jackPace, 2, 1 );
 
     /* Auto Connect */
-    jackConnect = new QCheckBox( qtr( "Auto connnection" ));
+    jackConnect = new QCheckBox( qtr( "Auto connection" ));
     jackPropLayout->addWidget( jackConnect, 2, 2 );
 
     /* Jack CONNECTs */
@@ -1104,6 +1126,7 @@ void CaptureOpenPanel::updateMRL()
         else if(  bdat->isChecked() ) mrl = "dvb-t://";
         else if(  bdac->isChecked() ) mrl = "dvb-c://";
         else if(  bdaa->isChecked() ) mrl = "atsc://";
+        else if(  bdaq->isChecked() ) mrl = "cqam://";
         else return;
         mrl += "frequency=" + QString::number( bdaFreq->value() );
         if( bdac->isChecked() || bdat->isChecked() || bdaa->isChecked() )
@@ -1227,6 +1250,13 @@ void CaptureOpenPanel::updateButtons()
             bdaBandBox->show();
             bdaBandLabel->show();
         }
+        else if( bdaq->isChecked() )
+        {
+            bdaSrate->hide();
+            bdaSrateLabel->hide();
+            bdaBandBox->hide();
+            bdaBandLabel->hide();
+        }
         break;
 #else
     case DVB_DEVICE: