Commit 995af4eb authored by Jean-Baptiste Kempf's avatar 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.
parent 6accad54
...@@ -40,7 +40,6 @@ class QTreeView; ...@@ -40,7 +40,6 @@ class QTreeView;
class PLModel; class PLModel;
class QPushButton; class QPushButton;
class QKeyEvent; class QKeyEvent;
class ClickLineEdit;
class PLPanel: public QWidget class PLPanel: public QWidget
{ {
...@@ -75,7 +74,6 @@ protected: ...@@ -75,7 +74,6 @@ protected:
private: private:
QTreeView *view; QTreeView *view;
QPushButton *repeatButton, *randomButton, *addButton, *gotoPlayingButton; QPushButton *repeatButton, *randomButton, *addButton, *gotoPlayingButton;
ClickLineEdit *searchLine;
int currentRootId; int currentRootId;
QSignalMapper *ContextUpdateMapper; QSignalMapper *ContextUpdateMapper;
public slots: public slots:
...@@ -89,7 +87,6 @@ private slots: ...@@ -89,7 +87,6 @@ private slots:
void gotoPlayingItem(); void gotoPlayingItem();
void doPopup( QModelIndex index, QPoint point ); void doPopup( QModelIndex index, QPoint point );
void search( QString search ); void search( QString search );
void clearFilter();
void setCurrentRootId( int ); void setCurrentRootId( int );
void popupAdd(); void popupAdd();
void popupSelectColumn( QPoint ); void popupSelectColumn( QPoint );
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "qt4.hpp" #include "qt4.hpp"
#include "dialogs_provider.hpp" #include "dialogs_provider.hpp"
#include "components/playlist/playlist_model.hpp" #include "components/playlist/playlist_model.hpp"
#include "components/playlist/panels.hpp" #include "components/playlist/panels.hpp"
#include "util/customwidgets.hpp" #include "util/customwidgets.hpp"
...@@ -45,7 +46,6 @@ ...@@ -45,7 +46,6 @@
#include <QSpacerItem> #include <QSpacerItem>
#include <QMenu> #include <QMenu>
#include <QSignalMapper> #include <QSignalMapper>
#include <assert.h> #include <assert.h>
#include "sorting.h" #include "sorting.h"
...@@ -164,15 +164,10 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, ...@@ -164,15 +164,10 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
QLabel *filter = new QLabel( qtr(I_PL_SEARCH) + " " ); QLabel *filter = new QLabel( qtr(I_PL_SEARCH) + " " );
buttons->addWidget( filter ); buttons->addWidget( filter );
searchLine = new ClickLineEdit( qtr(I_PL_FILTER), 0 ); SearchLineEdit *search = new SearchLineEdit( this );
searchLine->setMinimumWidth( 80 ); buttons->addWidget( search );
CONNECT( searchLine, textChanged(QString), this, search(QString)); filter->setBuddy( search );
buttons->addWidget( searchLine ); filter->setBuddy( searchLine ); CONNECT( search, textChanged( QString ), this, search( QString ) );
QPushButton *clear = new QPushButton;
clear->setMaximumWidth( 30 );
BUTTON_SET_ACT_I( clear, "", clear, qtr( "Clear" ), clearFilter() );
buttons->addWidget( clear );
/* Finish the layout */ /* Finish the layout */
layout->addWidget( view ); layout->addWidget( view );
...@@ -291,12 +286,6 @@ void StandardPLPanel::popupSelectColumn( QPoint pos ) ...@@ -291,12 +286,6 @@ void StandardPLPanel::popupSelectColumn( QPoint pos )
selectColMenu.exec( QCursor::pos() ); selectColMenu.exec( QCursor::pos() );
} }
/* ClearFilter LineEdit */
void StandardPLPanel::clearFilter()
{
searchLine->setText( "" );
}
/* Search in the playlist */ /* Search in the playlist */
void StandardPLPanel::search( QString searchText ) void StandardPLPanel::search( QString searchText )
{ {
......
...@@ -23,17 +23,24 @@ ...@@ -23,17 +23,24 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
#endif #endif
#include "customwidgets.hpp" #include "customwidgets.hpp"
#include "qt4.hpp" /*needed for qtr and CONNECT, but not necessary */
#include <QPainter> #include <QPainter>
#include <QLineEdit> #include <QLineEdit>
#include <QColorGroup> #include <QColorGroup>
#include <QRect> #include <QRect>
#include <QKeyEvent> #include <QKeyEvent>
#include <QWheelEvent> #include <QWheelEvent>
#include <QToolButton>
#include <QHBoxLayout>
#include <vlc_intf_strings.h>
#include <vlc_keys.h> #include <vlc_keys.h>
...@@ -97,6 +104,48 @@ void ClickLineEdit::focusOutEvent( QFocusEvent *ev ) ...@@ -97,6 +104,48 @@ void ClickLineEdit::focusOutEvent( QFocusEvent *ev )
QLineEdit::focusOutEvent( 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 * Hotkeys converters
***************************************************************************/ ***************************************************************************/
......
...@@ -56,6 +56,23 @@ private: ...@@ -56,6 +56,23 @@ private:
bool mDrawClickMsg; 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 * Custom views
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment