]> git.sesse.net Git - vlc/blob - modules/gui/qt4/util/customwidgets.hpp
Qt4 - MouseWheel support - patch by Sergey Volk.
[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: qvlcframe.hpp 16283 2006-08-17 18:16:09Z zorglub $
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 #ifndef _CUSTOMWIDGETS_H_
27 #define _CUSTOMWIDGETS_H_
28
29 #include <QLineEdit>
30
31 /**
32   This class provides a QLineEdit which contains a greyed-out hinting
33   text as long as the user didn't enter any text
34
35   @short LineEdit with customizable "Click here" text
36   @author Daniel Molkentin
37 */
38 class ClickLineEdit : public QLineEdit
39 {
40     Q_OBJECT
41     Q_PROPERTY( QString clickMessage READ clickMessage WRITE setClickMessage )
42 public:
43     ClickLineEdit( const QString &msg, QWidget *parent );
44     virtual ~ClickLineEdit() {};
45     void setClickMessage( const QString &msg );
46     QString clickMessage() const { return mClickMessage; }
47     virtual void setText( const QString& txt );
48 protected:
49     virtual void paintEvent( QPaintEvent *e );
50     virtual void dropEvent( QDropEvent *ev );
51     virtual void focusInEvent( QFocusEvent *ev );
52     virtual void focusOutEvent( QFocusEvent *ev );
53 private:
54     QString mClickMessage;
55     bool mDrawClickMsg;
56 };
57
58 /*****************************************************************
59  * Custom views
60  *****************************************************************/
61 #include <QMouseEvent>
62 #include <QTreeView>
63 #include <QCursor>
64 #include <QPoint>
65 #include <QModelIndex>
66
67 class QVLCTreeView : public QTreeView
68 {
69     Q_OBJECT;
70 public:
71     QVLCTreeView( QWidget * parent ) : QTreeView( parent )
72     {
73     };
74     virtual ~QVLCTreeView()   {};
75
76     void mouseReleaseEvent(QMouseEvent* e )
77     {
78         if( e->button() & Qt::RightButton )
79         {
80             emit rightClicked( indexAt( QPoint( e->x(), e->y() ) ),
81                                QCursor::pos() );
82         }
83     }
84 signals:
85     void rightClicked( QModelIndex, QPoint  );
86 };
87
88 class QKeyEvent;
89 int qtEventToVLCKey( QKeyEvent *e );
90 QString VLCKeyToString( int val );
91 int qtKeyModifiersToVLC( QInputEvent* e );
92
93 #endif