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 _CUSTOMWIDGETS_H_
28 #define _CUSTOMWIDGETS_H_
35 This class provides a QLineEdit which contains a greyed-out hinting
36 text as long as the user didn't enter any text
38 @short LineEdit with customizable "Click here" text
39 @author Daniel Molkentin
41 class ClickLineEdit : public QLineEdit
44 Q_PROPERTY( QString clickMessage READ clickMessage WRITE setClickMessage )
46 ClickLineEdit( const QString &msg, QWidget *parent );
47 virtual ~ClickLineEdit() {};
48 void setClickMessage( const QString &msg );
49 QString clickMessage() const { return mClickMessage; }
50 virtual void setText( const QString& txt );
52 virtual void paintEvent( QPaintEvent *e );
53 virtual void dropEvent( QDropEvent *ev );
54 virtual void focusInEvent( QFocusEvent *ev );
55 virtual void focusOutEvent( QFocusEvent *ev );
57 QString mClickMessage;
62 class SearchLineEdit : public QFrame
66 SearchLineEdit( QWidget *parent );
69 ClickLineEdit *searchLine;
70 QToolButton *clearButton;
73 void updateText( const QString& );
76 void textChanged( const QString& );
79 class QVLCIconLabel : public QLabel
83 QVLCIconLabel( const QIcon&, QWidget *parent = 0 );
84 void setIcon( const QIcon& );
88 virtual void enterEvent( QEvent * );
89 virtual void leaveEvent( QEvent * );
90 virtual void mouseReleaseEvent( QMouseEvent * );
92 inline QSize pixmapSize( QIcon::Mode = QIcon::Normal, QIcon::State = QIcon::Off );
96 /*****************************************************************
98 *****************************************************************/
99 #include <QMouseEvent>
103 #include <QModelIndex>
106 Special QTreeView that can emit rightClicked()
108 class QVLCTreeView : public QTreeView
112 void mouseReleaseEvent( QMouseEvent* e )
114 if( e->button() & Qt::RightButton )
115 return; /* Do NOT forward to QTreeView!! */
116 QTreeView::mouseReleaseEvent( e );
119 void mousePressEvent( QMouseEvent* e )
121 if( e->button() & Qt::RightButton )
123 QModelIndex index = indexAt( QPoint( e->x(), e->y() ) );
124 if( index.isValid() )
125 setSelection( visualRect( index ), QItemSelectionModel::ClearAndSelect );
126 emit rightClicked( index, QCursor::pos() );
129 if( e->button() & Qt::LeftButton )
131 if( !indexAt( QPoint( e->x(), e->y() ) ).isValid() )
134 QTreeView::mousePressEvent( e );
138 void rightClicked( QModelIndex, QPoint );
141 /* VLC Key/Wheel hotkeys interactions */
146 int qtKeyModifiersToVLC( QInputEvent* e );
147 int qtEventToVLCKey( QKeyEvent *e );
148 int qtWheelEventToVLCKey( QWheelEvent *e );
149 QString VLCKeyToString( int val );