1 /***************************************************************************** 2 * searchlineedit.hpp: Custom widgets 3 **************************************************************************** 4 * Copyright (C) 2006 the VideoLAN team 5 * Copyright (C) 2004 Daniel Molkentin <molkentin@kde.org> 6 * $Id: fde9c16b0c5fa2af22b259e58c77e971fc2b45ef $ 7 * 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 11 * 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. 16 * 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. 21 * 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 *****************************************************************************/ 26 27 #ifndef VLC_QT_SEARCHLINEEDIT_HPP_ 28 #define VLC_QT_SEARCHLINEEDIT_HPP_ 29 30 #ifdef __APPLE__ 31 #include "../qt.hpp" 32 #else 33 #include "qt.hpp" 34 #endif 35 #include <QLineEdit> 36 37 class ClickLineEdit : public QLineEdit 38 { 39 Q_OBJECT 40 public: ClickLineEdit(const QString & msg,QWidget * parent)41 ClickLineEdit( const QString &msg, QWidget *parent ) : QLineEdit( parent ) 42 { 43 QLineEdit::setPlaceholderText ( msg ); 44 } 45 }; 46 47 class QFramelessButton; 48 class SearchLineEdit : public QLineEdit 49 { 50 Q_OBJECT 51 public: 52 SearchLineEdit( QWidget *parent = NULL ); 53 54 private: 55 void resizeEvent ( QResizeEvent * event ); 56 void focusInEvent( QFocusEvent *event ); 57 void focusOutEvent( QFocusEvent *event ); 58 void paintEvent( QPaintEvent *event ); 59 void setMessageVisible( bool on ); 60 QFramelessButton *clearButton; 61 bool message; 62 63 public slots: 64 void clear(); 65 66 private slots: 67 void updateText( const QString& ); 68 void searchEditingFinished(); 69 70 signals: 71 void searchDelayedChanged( const QString& ); 72 }; 73 74 #endif 75 76