]> git.sesse.net Git - vlc/blob - modules/gui/qt4/util/customwidgets.hpp
Qt: selector cosmetic polish
[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
33 /**
34   This class provides a QLineEdit which contains a greyed-out hinting
35   text as long as the user didn't enter any text
36
37   @short LineEdit with customizable "Click here" text
38   @author Daniel Molkentin
39 */
40 class ClickLineEdit : public QLineEdit
41 {
42     Q_OBJECT
43     Q_PROPERTY( QString clickMessage READ clickMessage WRITE setClickMessage )
44 public:
45     ClickLineEdit( const QString &msg, QWidget *parent );
46     virtual ~ClickLineEdit() {};
47     void setClickMessage( const QString &msg );
48     QString clickMessage() const { return mClickMessage; }
49     virtual void setText( const QString& txt );
50 protected:
51     virtual void paintEvent( QPaintEvent *e );
52     virtual void dropEvent( QDropEvent *ev );
53     virtual void focusInEvent( QFocusEvent *ev );
54     virtual void focusOutEvent( QFocusEvent *ev );
55 private:
56     QString mClickMessage;
57     bool mDrawClickMsg;
58 };
59
60 class QVLCFramelessButton : public QPushButton
61 {
62     Q_OBJECT;
63 public:
64     QVLCFramelessButton( QWidget *parent = NULL );
65     QSize sizeHint() const;
66 protected:
67     virtual void paintEvent( QPaintEvent * event );
68 };
69
70 class QLabel;
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     QLabel *msg;
87
88 public slots:
89     void clear();
90
91 private slots:
92     void updateText( const QString& );
93 };
94
95 /* VLC Key/Wheel hotkeys interactions */
96
97 class QKeyEvent;
98 class QWheelEvent;
99 class QInputEvent;
100
101 int qtKeyModifiersToVLC( QInputEvent* e );
102 int qtEventToVLCKey( QKeyEvent *e );
103 int qtWheelEventToVLCKey( QWheelEvent *e );
104 QString VLCKeyToString( int val );
105
106 #endif
107