]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/interface_widgets.hpp
Qt4 - Clean more.
[vlc] / modules / gui / qt4 / components / interface_widgets.hpp
1 /*****************************************************************************
2  * interface_widgets.hpp : Custom widgets for the main interface
3  ****************************************************************************
4  * Copyright (C) 2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Clément Stenac <zorglub@videolan.org>
8  *          Jean-Baptiste Kempf <jb@videolan.org>
9  *          Rafaël Carré <funman@videolanorg>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24  *****************************************************************************/
25
26 #ifndef _INTFWIDGETS_H_
27 #define _INTFWIDGETS_H_
28
29 #include <vlc/vlc.h>
30 #include <vlc_interface.h>
31
32 #include <vlc_aout.h>
33 #include "qt4.hpp"
34
35 #include <QWidget>
36 #include <QFrame>
37 #define VOLUME_MAX 200
38
39 class ResizeEvent;
40 class QPalette;
41 class QPixmap;
42 class QLabel;
43 class QHBoxLayout;
44
45 /******************** Video Widget ****************/
46 class VideoWidget : public QFrame
47 {
48     Q_OBJECT
49 public:
50     VideoWidget( intf_thread_t * );
51     virtual ~VideoWidget();
52
53     void *request( vout_thread_t *, int *, int *,
54                    unsigned int *, unsigned int * );
55     void release( void * );
56     int control( void *, int, va_list );
57
58 private:
59     intf_thread_t *p_intf;
60     vlc_mutex_t lock;
61     vout_thread_t *p_vout;
62
63 signals:
64     //void askResize();
65     void askVideoWidgetToShow();
66
67 public slots:
68     void SetSizing( unsigned int, unsigned int );
69 };
70
71 /******************** Background Widget ****************/
72 class BackgroundWidget : public QFrame
73 {
74     Q_OBJECT
75 public:
76     BackgroundWidget( intf_thread_t * );
77     virtual ~BackgroundWidget();
78     QSize widgetSize;
79     QSize sizeHint() const;
80     bool b_need_update;
81 private:
82     QPalette plt;
83     QLabel *label;
84     virtual void resizeEvent( QResizeEvent *e );
85     virtual void contextMenuEvent( QContextMenuEvent *event );
86     intf_thread_t *p_intf;
87     int i_runs;
88 public slots:
89     void toggle(){ TOGGLEV( this ); }
90     void update( input_thread_t * );
91 };
92
93 class VisualSelector : public QFrame
94 {
95     Q_OBJECT
96 public:
97     VisualSelector( intf_thread_t *);
98     virtual ~VisualSelector();
99 private:
100     intf_thread_t *p_intf;
101     QLabel *current;
102 private slots:
103     void prev();
104     void next();
105 };
106
107 /* Advanced Button Bar */
108 class QPushButton;
109 class AdvControlsWidget : public QFrame
110 {
111     Q_OBJECT
112 public:
113     AdvControlsWidget( intf_thread_t *);
114     virtual ~AdvControlsWidget();
115
116     void enableInput( bool );
117     void enableVideo( bool );
118
119 private:
120     intf_thread_t *p_intf;
121     QPushButton *recordButton, *ABButton;
122     QPushButton *snapshotButton, *frameButton;
123
124     mtime_t timeA, timeB;
125
126 private slots:
127     void snapshot();
128     void frame();
129     void fromAtoB();
130     void record();
131     void AtoBLoop( float, int, int );
132 };
133
134 /* Button Bar */
135 class InputSlider;
136 class QSlider;
137 class QGridLayout;
138 class VolumeClickHandler;
139 class SoundSlider;
140 class QAbstractSlider;
141 class QToolButton;
142
143 class ControlsWidget : public QFrame
144 {
145     Q_OBJECT
146 public:
147     /* p_intf, advanced control visible or not, blingbling or not */
148     ControlsWidget( intf_thread_t *, MainInterface*, bool, bool );
149     virtual ~ControlsWidget();
150
151     QPushButton *playlistButton;
152     void setStatus( int );
153     void enableInput( bool );
154     void enableVideo( bool );
155 public slots:
156     void setNavigation( int );
157     void updateOnTimer();
158 protected:
159     friend class MainInterface;
160     friend class VolumeClickHandler;
161 private:
162     intf_thread_t       *p_intf;
163     QWidget             *discFrame;
164     QWidget             *telexFrame;
165     QGridLayout         *controlLayout;
166     InputSlider         *slider;
167     QPushButton         *prevSectionButton, *nextSectionButton, *menuButton;
168     QPushButton         *playButton, *fullscreenButton;
169     QToolButton         *slowerButton, *fasterButton;
170     AdvControlsWidget   *advControls;
171     QLabel              *volMuteLabel;
172     QAbstractSlider     *volumeSlider;
173
174     bool                 b_advancedVisible;
175 private slots:
176     void play();
177     void stop();
178     void prev();
179     void next();
180     void updateVolume( int );
181     void fullscreen();
182     void extSettings();
183     void faster();
184     void slower();
185     void toggleAdvanced();
186 signals:
187     void advancedControlsToggled( bool );
188 };
189
190 class VolumeClickHandler : public QObject
191 {
192 public:
193     VolumeClickHandler( intf_thread_t *_p_intf, ControlsWidget *_m ) :QObject(_m)
194     {m = _m; p_intf = _p_intf; }
195     virtual ~VolumeClickHandler() {};
196     bool eventFilter( QObject *obj, QEvent *e )
197     {
198         if (e->type() == QEvent::MouseButtonPress  )
199         {
200             aout_VolumeMute( p_intf, NULL );
201             audio_volume_t i_volume;
202             aout_VolumeGet( p_intf, &i_volume );
203             m->updateVolume( i_volume *  VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
204             return true;
205         }
206         return false;
207     }
208 private:
209     ControlsWidget *m;
210     intf_thread_t *p_intf;
211 };
212
213 #include <QLabel>
214 #include <QMouseEvent>
215 class TimeLabel : public QLabel
216 {
217     Q_OBJECT
218     void mousePressEvent( QMouseEvent *event )
219     {
220         emit timeLabelClicked();
221     }
222     void mouseDoubleClickEvent( QMouseEvent *event )
223     {
224         emit timeLabelDoubleClicked();
225     }
226 signals:
227     void timeLabelClicked();
228     void timeLabelDoubleClicked();
229 };
230
231
232 /******************** Speed Control Widgets ****************/
233 class SpeedControlWidget : public QFrame
234 {
235     Q_OBJECT
236 public:
237     SpeedControlWidget( intf_thread_t *);
238     virtual ~SpeedControlWidget();
239     void updateControls( int );
240 private:
241     intf_thread_t *p_intf;
242     QSlider *speedSlider;
243 private slots:
244     void updateRate( int );
245     void resetRate();
246 };
247
248 #endif