From: Jean-Baptiste Kempf Date: Mon, 5 Jan 2009 19:08:13 +0000 (+0100) Subject: Qt: the red box when searching in the playlist is confusing. X-Git-Tag: 1.0.0-pre1~1526 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=995af4eb81d0fce1dcffa3b1dc30715f1619c0d2;p=vlc Qt: the red box when searching in the playlist is confusing. Therefore, create a new SearchBox that has a button appearing when typing something. --- diff --git a/modules/gui/qt4/components/playlist/panels.hpp b/modules/gui/qt4/components/playlist/panels.hpp index 78eaa5db43..671b09289a 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 19215f90d1..e5ba2e6d13 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 #include #include - #include #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 50f5fe2fef..4a711b8e9c 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 #include #include #include #include #include +#include +#include +#include + #include @@ -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 4d6fff1617..431e857a1f 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