[vlc-commits] commit: Qt: use Qt4.7 clickLineEdit, if possible (Jean-Baptiste Kempf )

git at videolan.org git at videolan.org
Tue Nov 30 21:47:07 CET 2010


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Tue Nov 30 21:12:39 2010 +0100| [9123d53be8c58099e916393ba34ed1d3cf33f88b] | committer: Jean-Baptiste Kempf 

Qt: use Qt4.7 clickLineEdit, if possible

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

 modules/gui/qt4/qt4.hpp                 |    1 +
 modules/gui/qt4/util/searchlineedit.cpp |    6 +++---
 modules/gui/qt4/util/searchlineedit.hpp |   18 ++++++++++++++++--
 3 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/modules/gui/qt4/qt4.hpp b/modules/gui/qt4/qt4.hpp
index 6bb7bb7..21f0a56 100644
--- a/modules/gui/qt4/qt4.hpp
+++ b/modules/gui/qt4/qt4.hpp
@@ -45,6 +45,7 @@
 #endif
 
 #define HAS_QT45 ( QT_VERSION >= 0x040500 )
+#define HAS_QT47 ( QT_VERSION >= 0x040700 )
 
 enum {
     DialogEventType = 0,
diff --git a/modules/gui/qt4/util/searchlineedit.cpp b/modules/gui/qt4/util/searchlineedit.cpp
index a042468..68130b7 100644
--- a/modules/gui/qt4/util/searchlineedit.cpp
+++ b/modules/gui/qt4/util/searchlineedit.cpp
@@ -40,6 +40,8 @@
 
 #include <vlc_intf_strings.h>
 
+#if QT_VERSION < 0x040700
+
 ClickLineEdit::ClickLineEdit( const QString &msg, QWidget *parent) : QLineEdit( parent )
 {
     mDrawClickMsg = true;
@@ -99,9 +101,7 @@ void ClickLineEdit::focusOutEvent( QFocusEvent *ev )
     }
     QLineEdit::focusOutEvent( ev );
 }
-
-
-
+#endif
 
 SearchLineEdit::SearchLineEdit( QWidget *parent ) : QLineEdit( parent )
 {
diff --git a/modules/gui/qt4/util/searchlineedit.hpp b/modules/gui/qt4/util/searchlineedit.hpp
index b9773ca..f149e06 100644
--- a/modules/gui/qt4/util/searchlineedit.hpp
+++ b/modules/gui/qt4/util/searchlineedit.hpp
@@ -29,6 +29,19 @@
 
 #include <QLineEdit>
 
+#include <qt4.hpp>
+
+#if HAS_QT47
+class ClickLineEdit : public QLineEdit
+{
+    Q_OBJECT
+public:
+    ClickLineEdit( const QString &msg, QWidget *parent ) : QLineEdit( parent )
+    {
+        QLineEdit::setPlaceholderText ( msg );
+    }
+};
+#else
 /**
   This class provides a QLineEdit which contains a greyed-out hinting
   text as long as the user didn't enter any text
@@ -39,11 +52,11 @@
 class ClickLineEdit : public QLineEdit
 {
     Q_OBJECT
-    Q_PROPERTY( QString clickMessage READ clickMessage WRITE setPlaceholderText )
+    Q_PROPERTY( QString clickMessage READ placeholderText WRITE setPlaceholderText )
 public:
     ClickLineEdit( const QString &msg, QWidget *parent );
     void setPlaceholderText( const QString &msg );
-    const QString& clickMessage() const { return mClickMessage; }
+    const QString& placeholderText() const { return mClickMessage; }
     virtual void setText( const QString& txt );
 protected:
     virtual void paintEvent( QPaintEvent *e );
@@ -54,6 +67,7 @@ private:
     QString mClickMessage;
     bool mDrawClickMsg;
 };
+#endif
 
 class QVLCFramelessButton;
 class SearchLineEdit : public QLineEdit



More information about the vlc-commits mailing list