[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 7 22:57:41 CEST 2010
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Jul 7 23:56:33 2010 +0300| [f8d5652706916e4b7471a6d40f0d1c23854a79a4] | committer: Rémi Denis-Courmont
Qt4: do not allow spaces in network URLs (fix #3870)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f8d5652706916e4b7471a6d40f0d1c23854a79a4
---
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 0a023c1..b257900 100644
--- a/modules/gui/qt4/components/open_panels.cpp
+++ b/modules/gui/qt4/components/open_panels.cpp
@@ -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 ) *
**************************************************************************/
diff --git a/modules/gui/qt4/components/open_panels.hpp b/modules/gui/qt4/components/open_panels.hpp
index 2999b5b..723fe45 100644
--- a/modules/gui/qt4/components/open_panels.hpp
+++ b/modules/gui/qt4/components/open_panels.hpp
@@ -149,6 +149,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