vlc/vlc-1.1 | branch: master | Rémi Denis-Courmont <[email protected]> | 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 <[email protected]> > 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 _______________________________________________ vlc-commits mailing list [email protected] http://mailman.videolan.org/listinfo/vlc-commits
