[vlc-devel] commit: Qt: the red box when searching in the playlist is confusing. ( Jean-Baptiste Kempf )

git version control git at videolan.org
Mon Jan 5 20:24:33 CET 2009


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Mon Jan  5 20:08:13 2009 +0100| [995af4eb81d0fce1dcffa3b1dc30715f1619c0d2] | committer: Jean-Baptiste Kempf 

Qt: the red box when searching in the playlist is confusing.

Therefore, create a new SearchBox that has a button appearing when typing something.

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

 modules/gui/qt4/components/playlist/panels.hpp     |    3 -
 .../gui/qt4/components/playlist/standardpanel.cpp  |   21 ++------
 modules/gui/qt4/util/customwidgets.cpp             |   49 ++++++++++++++++++++
 modules/gui/qt4/util/customwidgets.hpp             |   17 +++++++
 4 files changed, 71 insertions(+), 19 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/panels.hpp b/modules/gui/qt4/components/playlist/panels.hpp
index 78eaa5d..671b092 100644
--- a/modules/gui/qt4/components/playlist/panels.hpp
+++ b/modules/gui/qt4/components/playlist/panels.hpp
@@ -40,7 +40,6 @@ class QTreeView;
 class PLModel;
 class QPushButton;
 class QKeyEvent;
-class ClickLineEdit;
 
 class PLPanel: public QWidget
 {
@@ -75,7 +74,6 @@ protected:
 private:
     QTreeView *view;
     QPushButton *repeatButton, *randomButton, *addButton, *gotoPlayingButton;
-    ClickLineEdit *searchLine;
     int currentRootId;
     QSignalMapper *ContextUpdateMapper;
 public slots:
@@ -89,7 +87,6 @@ private slots:
     void gotoPlayingItem();
     void doPopup( QModelIndex index, QPoint point );
     void search( QString search );
-    void clearFilter();
     void setCurrentRootId( int );
     void popupAdd();
     void popupSelectColumn( QPoint );
diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index 19215f9..e5ba2e6 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -27,6 +27,7 @@
 
 #include "qt4.hpp"
 #include "dialogs_provider.hpp"
+
 #include "components/playlist/playlist_model.hpp"
 #include "components/playlist/panels.hpp"
 #include "util/customwidgets.hpp"
@@ -45,7 +46,6 @@
 #include <QSpacerItem>
 #include <QMenu>
 #include <QSignalMapper>
-
 #include <assert.h>
 
 #include "sorting.h"
@@ -164,15 +164,10 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
     QLabel *filter = new QLabel( qtr(I_PL_SEARCH) + " " );
     buttons->addWidget( filter );
 
-    searchLine = new  ClickLineEdit( qtr(I_PL_FILTER), 0 );
-    searchLine->setMinimumWidth( 80 );
-    CONNECT( searchLine, textChanged(QString), this, search(QString));
-    buttons->addWidget( searchLine ); filter->setBuddy( searchLine );
-
-    QPushButton *clear = new QPushButton;
-    clear->setMaximumWidth( 30 );
-    BUTTON_SET_ACT_I( clear, "", clear, qtr( "Clear" ), clearFilter() );
-    buttons->addWidget( clear );
+    SearchLineEdit *search = new SearchLineEdit( this );
+    buttons->addWidget( search );
+    filter->setBuddy( search );
+    CONNECT( search, textChanged( QString ), this, search( QString ) );
 
     /* Finish the layout */
     layout->addWidget( view );
@@ -291,12 +286,6 @@ void StandardPLPanel::popupSelectColumn( QPoint pos )
     selectColMenu.exec( QCursor::pos() );
 }
 
-/* ClearFilter LineEdit */
-void StandardPLPanel::clearFilter()
-{
-    searchLine->setText( "" );
-}
-
 /* Search in the playlist */
 void StandardPLPanel::search( QString searchText )
 {
diff --git a/modules/gui/qt4/util/customwidgets.cpp b/modules/gui/qt4/util/customwidgets.cpp
index 50f5fe2..4a711b8 100644
--- a/modules/gui/qt4/util/customwidgets.cpp
+++ b/modules/gui/qt4/util/customwidgets.cpp
@@ -23,17 +23,24 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
+
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
 
 #include "customwidgets.hpp"
+#include "qt4.hpp" /*needed for qtr and CONNECT, but not necessary */
+
 #include <QPainter>
 #include <QLineEdit>
 #include <QColorGroup>
 #include <QRect>
 #include <QKeyEvent>
 #include <QWheelEvent>
+#include <QToolButton>
+#include <QHBoxLayout>
+#include <vlc_intf_strings.h>
+
 
 #include <vlc_keys.h>
 
@@ -97,6 +104,48 @@ void ClickLineEdit::focusOutEvent( QFocusEvent *ev )
     QLineEdit::focusOutEvent( ev );
 }
 
+SearchLineEdit::SearchLineEdit( QWidget *parent ) : QFrame( parent )
+{
+    setFrameStyle( QFrame::StyledPanel | QFrame::Sunken );
+    setLineWidth( 1 );
+
+    QHBoxLayout *frameLayout = new QHBoxLayout( this );
+    frameLayout->setMargin( 0 );
+    frameLayout->setSpacing( 0 );
+
+    QPalette palette;
+    QBrush brush( QColor(255, 255, 255, 255) );
+    brush.setStyle(Qt::SolidPattern);
+    palette.setBrush(QPalette::Active, QPalette::Window, brush); //Qt::white
+
+    setPalette(palette);
+    setAutoFillBackground(true);
+
+    searchLine = new  ClickLineEdit( qtr(I_PL_FILTER), 0 );
+    searchLine->setFrame( false );
+    searchLine->setMinimumWidth( 80 );
+
+    CONNECT( searchLine, textChanged( const QString ),
+             this, updateText( const QString ) );
+    frameLayout->addWidget( searchLine );
+
+    clearButton = new QToolButton;
+    clearButton->setAutoRaise( true );
+    clearButton->setMaximumWidth( 30 );
+    clearButton->setIcon( QIcon( ":/clear" ) );
+    clearButton->setToolTip( qtr( "Clear" ) );
+    clearButton->hide();
+
+    CONNECT( clearButton, clicked(), searchLine, clear() );
+    frameLayout->addWidget( clearButton );
+}
+
+void SearchLineEdit::updateText( const QString text )
+{
+    clearButton->setVisible( !text.isEmpty() );
+    emit textChanged( text );
+}
+
 /***************************************************************************
  * Hotkeys converters
  ***************************************************************************/
diff --git a/modules/gui/qt4/util/customwidgets.hpp b/modules/gui/qt4/util/customwidgets.hpp
index 4d6fff1..431e857 100644
--- a/modules/gui/qt4/util/customwidgets.hpp
+++ b/modules/gui/qt4/util/customwidgets.hpp
@@ -56,6 +56,23 @@ private:
     bool mDrawClickMsg;
 };
 
+class QToolButton;
+class SearchLineEdit : public QFrame
+{
+    Q_OBJECT
+public:
+    SearchLineEdit( QWidget *parent );
+
+private:
+    ClickLineEdit *searchLine;
+    QToolButton   *clearButton;
+
+private slots:
+    void updateText( const QString );
+
+signals:
+    void textChanged( const QString );
+};
 
 /*****************************************************************
  * Custom views




More information about the vlc-devel mailing list