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