]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/open_panels.cpp
Qt4: do not allow spaces in network URLs (fix #3870)
[vlc] / modules / gui / qt4 / components / open_panels.cpp
index 0a023c1c897fc1be3fbdbcdd43e012b3ea87b16b..b257900bfbe6631efb08e274808041ece92a94dc 100644 (file)
@@ -551,6 +551,8 @@ NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     }
     else
         mrlList = NULL;
+
+    ui.urlText->setValidator( new UrlValidator( this ) );
 }
 
 NetOpenPanel::~NetOpenPanel()
@@ -624,6 +626,20 @@ void NetOpenPanel::updateCompleter()
     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 )                     *
  **************************************************************************/