1 /*****************************************************************************
2 * customwidgets.h: Custom widgets
3 ****************************************************************************
4 * Copyright (C) 2006 the VideoLAN team
5 * Copyright (C) 2004 Daniel Molkentin <molkentin@kde.org>
8 * Authors: Clément Stenac <zorglub@videolan.org>
9 * The "ClickLineEdit" control is based on code by Daniel Molkentin
10 * <molkentin@kde.org> for libkdepim
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 *****************************************************************************/
27 #ifndef _SEARCHLINEEDIT_H_
28 #define _SEARCHLINEEDIT_H_
38 class ClickLineEdit : public QLineEdit
42 ClickLineEdit( const QString &msg, QWidget *parent ) : QLineEdit( parent )
44 QLineEdit::setPlaceholderText ( msg );
49 This class provides a QLineEdit which contains a greyed-out hinting
50 text as long as the user didn't enter any text
52 @short LineEdit with customizable "Click here" text
53 @author Daniel Molkentin
55 class ClickLineEdit : public QLineEdit
58 Q_PROPERTY( QString clickMessage READ placeholderText WRITE setPlaceholderText )
60 ClickLineEdit( const QString &msg, QWidget *parent );
61 void setPlaceholderText( const QString &msg );
62 const QString& placeholderText() const { return mClickMessage; }
63 virtual void setText( const QString& txt );
65 virtual void paintEvent( QPaintEvent *e );
66 virtual void dropEvent( QDropEvent *ev );
67 virtual void focusInEvent( QFocusEvent *ev );
68 virtual void focusOutEvent( QFocusEvent *ev );
70 QString mClickMessage;
76 class QFramelessButton;
77 class SearchLineEdit : public QLineEdit
81 SearchLineEdit( QWidget *parent = NULL );
84 void resizeEvent ( QResizeEvent * event );
85 void focusInEvent( QFocusEvent *event );
86 void focusOutEvent( QFocusEvent *event );
87 void paintEvent( QPaintEvent *event );
88 void setMessageVisible( bool on );
89 QFramelessButton *clearButton;
96 void updateText( const QString& );
97 void searchEditingFinished();
100 void searchDelayedChanged( const QString& );
104 /* On Mac, we try to use the native NSSearchField */
105 #include <QMacCocoaViewContainer>
107 class SearchLineEdit : public QMacCocoaViewContainer
112 SearchLineEdit(QWidget *parent = 0);
113 virtual ~SearchLineEdit() {}
115 virtual QSize sizeHint() const { return QSize(150, 40); }
121 void searchDelayedChanged( const QString& );
122 void textEdited( const QString& );