]> git.sesse.net Git - vlc/blob - modules/gui/qt4/util/customwidgets.hpp
2d05fb19fe2f8ebc5d5b09698e71e038fea52b4a
[vlc] / modules / gui / qt4 / util / customwidgets.hpp
1 /*****************************************************************************
2  * customwidgets.hpp: 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 #include <QCheckBox>
36 #include <QList>
37 #include <QToolButton>
38 #include <QDial>
39
40 #include "animators.hpp"
41 #include "qt4.hpp"
42
43 class QPixmap;
44 class QWidget;
45
46 class QFramelessButton : public QPushButton
47 {
48     Q_OBJECT
49 public:
50     QFramelessButton( QWidget *parent = NULL );
51     QSize sizeHint() const Q_DECL_OVERRIDE { return iconSize(); }
52 protected:
53     void paintEvent( QPaintEvent * event ) Q_DECL_OVERRIDE;
54 };
55
56 class VLCQDial : public QDial
57 {
58     Q_OBJECT
59 public:
60     VLCQDial( QWidget *parent = NULL );
61 protected:
62     void paintEvent( QPaintEvent * event ) Q_DECL_OVERRIDE;
63 };
64
65 class QToolButtonExt : public QToolButton
66 {
67     Q_OBJECT
68 public:
69     QToolButtonExt( QWidget *parent = 0, int ms = 0 );
70 private:
71     bool shortClick;
72     bool longClick;
73 private slots:
74     void releasedSlot();
75     void clickedSlot();
76 signals:
77     void shortClicked();
78     void longClicked();
79 };
80
81 class QElidingLabel : public QLabel
82 {
83 public:
84     QElidingLabel( const QString &s = QString(),
85                       Qt::TextElideMode mode = Qt::ElideRight,
86                       QWidget * parent = NULL );
87     void setElideMode( Qt::TextElideMode );
88 protected:
89     void paintEvent( QPaintEvent * event ) Q_DECL_OVERRIDE;
90 private:
91     Qt::TextElideMode elideMode;
92 };
93
94
95 class QVLCStackedWidget : public QStackedWidget
96 {
97 public:
98     QVLCStackedWidget( QWidget *parent ) : QStackedWidget( parent ) { }
99     QSize minimumSizeHint () const
100     {
101         return currentWidget() ? currentWidget()->minimumSizeHint() : QSize();
102     }
103 };
104
105 class QVLCDebugLevelSpinBox : public QSpinBox
106 {
107     Q_OBJECT
108 public:
109     QVLCDebugLevelSpinBox( QWidget *parent ) : QSpinBox( parent ) { };
110 protected:
111     QString textFromValue( int ) const Q_DECL_OVERRIDE;
112     /* QVLCDebugLevelSpinBox is read-only */
113     int valueFromText( const QString& ) const Q_DECL_OVERRIDE { return -1; }
114 };
115
116 /** This spinning icon, to the colors of the VLC cone, will show
117  * that there is some background activity running
118  **/
119 class SpinningIcon : public QLabel
120 {
121     Q_OBJECT
122
123 public:
124     SpinningIcon( QWidget *parent );
125     void play( int loops = -1, int fps = 0 )
126     {
127         animator->setLoopCount( loops );
128         if ( fps ) animator->setFps( fps );
129         animator->start();
130     }
131     void stop() { animator->stop(); }
132     bool isPlaying() { return animator->state() == PixmapAnimator::Running; }
133 private:
134     PixmapAnimator *animator;
135 };
136
137 class YesNoCheckBox : public QCheckBox
138 {
139     Q_OBJECT
140 public:
141     YesNoCheckBox( QWidget *parent );
142 };
143
144 /* VLC Key/Wheel hotkeys interactions */
145
146 class QKeyEvent;
147 class QWheelEvent;
148 class QInputEvent;
149
150 int qtKeyModifiersToVLC( QInputEvent* e );
151 int qtEventToVLCKey( QKeyEvent *e );
152 int qtWheelEventToVLCKey( QWheelEvent *e );
153 QString VLCKeyToString( unsigned val, bool );
154
155 #endif