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;
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 );
......
......@@ -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 )
{
......
......@@ -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
***************************************************************************/
......
......@@ -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
......
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