]> git.sesse.net Git - vlc/blob - modules/gui/qt4/util/customwidgets.hpp
Qt: misc simplifications and corrections
[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 class QVLCFramelessButton : public QPushButton
37 {
38     Q_OBJECT
39 public:
40     QVLCFramelessButton( QWidget *parent = NULL );
41     virtual QSize sizeHint() const { return iconSize(); }
42 protected:
43     virtual void paintEvent( QPaintEvent * event );
44 };
45
46
47 class QVLCElidingLabel : public QLabel
48 {
49 public:
50     QVLCElidingLabel( const QString &s = QString(),
51                       Qt::TextElideMode mode = Qt::ElideRight,
52                       QWidget * parent = NULL );
53     void setElideMode( Qt::TextElideMode );
54 protected:
55     virtual void paintEvent( QPaintEvent * event );
56 private:
57     Qt::TextElideMode elideMode;
58 };
59
60
61 class QVLCStackedWidget : public QStackedWidget
62 {
63 public:
64     QVLCStackedWidget( QWidget *parent ) : QStackedWidget( parent ) { }
65     QSize minimumSizeHint () const
66     {
67         return currentWidget() ? currentWidget()->minimumSizeHint() : QSize();
68     }
69 };
70
71 class DebugLevelSpinBox : public QSpinBox
72 {
73     Q_OBJECT
74 public:
75     DebugLevelSpinBox( QWidget *parent ) : QSpinBox( parent ) { };
76 protected:
77     virtual QString textFromValue( int ) const;
78     /* DebugLevelSpinBox is read-only */
79     virtual int valueFromText( const QString& ) const { return -1; }
80 };
81
82 /* VLC Key/Wheel hotkeys interactions */
83
84 class QKeyEvent;
85 class QWheelEvent;
86 class QInputEvent;
87
88 int qtKeyModifiersToVLC( QInputEvent* e );
89 int qtEventToVLCKey( QKeyEvent *e );
90 int qtWheelEventToVLCKey( QWheelEvent *e );
91 QString VLCKeyToString( int val );
92
93 #endif
94