[vlc-commits] commit: Qt4: do not allow spaces in network URLs (fix #3870) ( Rémi Denis-Courmont )

git at videolan.org git at videolan.org
Wed Jul 21 19:23:21 CEST 2010


vlc/vlc-1.1 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Jul  7 23:56:33 2010 +0300| [c0a12564a3a2d4a5744eb3cd2f8de964badbedc4] | committer: Rémi Duraffort 

Qt4: do not allow spaces in network URLs (fix #3870)
(cherry picked from commit f8d5652706916e4b7471a6d40f0d1c23854a79a4)

Signed-off-by: Rémi Duraffort <ivoire at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.1.git/?a=commit;h=c0a12564a3a2d4a5744eb3cd2f8de964badbedc4
---

 modules/gui/qt4/components/open_panels.cpp |   16 ++++++++++++++++
 modules/gui/qt4/components/open_panels.hpp |    9 +++++++++
 2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/modules/gui/qt4/components/open_panels.cpp b/modules/gui/qt4/components/open_panels.cpp
index 2769853..a19b11f 100644
--- a/modules/gui/qt4/components/open_panels.cpp
+++ b/modules/gui/qt4/components/open_panels.cpp
@@ -513,6 +513,8 @@ NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     }
     else
         mrlList = NULL;
+
+    ui.urlText->setValidator( new UrlValidator( this ) );
 }
 
 NetOpenPanel::~NetOpenPanel()
@@ -586,6 +588,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 )                     *
  **************************************************************************/
diff --git a/modules/gui/qt4/components/open_panels.hpp b/modules/gui/qt4/components/open_panels.hpp
index 4d2d05b..03ee5f4 100644
--- a/modules/gui/qt4/components/open_panels.hpp
+++ b/modules/gui/qt4/components/open_panels.hpp
@@ -144,6 +144,15 @@ private slots:
     void updateCompleter();
 };
 
+class UrlValidator : public QValidator
+{
+   Q_OBJECT
+public:
+   UrlValidator( QObject *parent ) : QValidator( parent ) { }
+   void fixup( QString& ) const;
+   QValidator::State validate( QString&, int& ) const;
+};
+
 class DiscOpenPanel: public OpenPanel
 {
     Q_OBJECT



More information about the vlc-commits mailing list