]> git.sesse.net Git - vlc/blob - modules/gui/qt4/util/customwidgets.hpp
64d08dda335b06e6fd31c6c4d3ad4aad65dda367
[vlc] / modules / gui / qt4 / util / customwidgets.hpp
1 /*****************************************************************************
2  * customwidgets.h: Custom widgets
3  ****************************************************************************
4  * Copyright (C) 2006 the VideoLAN team
5  * Copyright (C) 2004 Daniel Molkentin <molkentin@kde.org>
6  * $Id$
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 _CUSTOMWIDGETS_H_
28 #define _CUSTOMWIDGETS_H_
29
30 #include <QLineEdit>
31 #include <QPushButton>
32 #include <QLabel>
33 #include <QStackedWidget>
34
35 /**
36   This class provides a QLineEdit which contains a greyed-out hinting
37   text as long as the user didn't enter any text
38
39   @short LineEdit with customizable "Click here" text
40   @author Daniel Molkentin
41 */
42 class ClickLineEdit : public QLineEdit
43 {
44     Q_OBJECT
45     Q_PROPERTY( QString clickMessage READ clickMessage WRITE setClickMessage )
46 public:
47     ClickLineEdit( const QString &msg, QWidget *parent );
48     void setClickMessage( const QString &msg );
49     const QString& clickMessage() const { return mClickMessage; }
50     virtual void setText( const QString& txt );
51 protected:
52     virtual void paintEvent( QPaintEvent *e );
53     virtual void dropEvent( QDropEvent *ev );
54     virtual void focusInEvent( QFocusEvent *ev );
55     virtual void focusOutEvent( QFocusEvent *ev );
56 private:
57     QString mClickMessage;
58     bool mDrawClickMsg;
59 };
60
61 class QVLCFramelessButton : public QPushButton
62 {
63     Q_OBJECT
64 public:
65     QVLCFramelessButton( QWidget *parent = NULL );
66     QSize sizeHint() const;
67 protected:
68     virtual void paintEvent( QPaintEvent * event );
69 };
70
71 class SearchLineEdit : public QLineEdit
72 {
73     Q_OBJECT
74 public:
75     SearchLineEdit( QWidget *parent = NULL );
76
77 private:
78     void resizeEvent ( QResizeEvent * event );
79     void focusInEvent( QFocusEvent *event );
80     void focusOutEvent( QFocusEvent *event );
81     void paintEvent( QPaintEvent *event );
82     void setMessageVisible( bool on );
83     QVLCFramelessButton   *clearButton;
84     bool message;
85
86 public slots:
87     void clear();
88
89 private slots:
90     void updateText( const QString& );
91 };
92
93 class QVLCElidingLabel : public QLabel
94 {
95 public:
96     QVLCElidingLabel( const QString &s = QString(),
97                       Qt::TextElideMode mode = Qt::ElideRight,
98                       QWidget * parent = NULL );
99     void setElideMode( Qt::TextElideMode );
100 private:
101     void paintEvent( QPaintEvent * event );
102     Qt::TextElideMode elideMode;
103 };
104
105 class QVLCStackedWidget : public QStackedWidget
106 {
107 public:
108     QVLCStackedWidget( QWidget *parent ) : QStackedWidget( parent ) { }
109     QSize minimumSizeHint () const
110     {
111         return currentWidget() ? currentWidget()->minimumSizeHint() : QSize();
112     }
113 };
114
115 /* VLC Key/Wheel hotkeys interactions */
116
117 class QKeyEvent;
118 class QWheelEvent;
119 class QInputEvent;
120
121 int qtKeyModifiersToVLC( QInputEvent* e );
122 int qtEventToVLCKey( QKeyEvent *e );
123 int qtWheelEventToVLCKey( QWheelEvent *e );
124 QString VLCKeyToString( int val );
125
126 #endif
127