]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/interface_widgets.hpp
Qt4 - Actually implement double-click on speed does reset the speed... Don't laugh...
[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 #ifdef HAVE_CONFIG_H
30 # include "config.h"
31 #endif
32
33 #include <vlc/vlc.h>
34 #include <vlc_interface.h>
35 #include <vlc_aout.h>
36
37 #include "qt4.hpp"
38 #include "main_interface.hpp"
39 #include "input_manager.hpp"
40
41 #include <QWidget>
42 #include <QFrame>
43 #define VOLUME_MAX 200
44
45 class ResizeEvent;
46 class QPalette;
47 class QPixmap;
48 class QLabel;
49 class QHBoxLayout;
50
51 /******************** Video Widget ****************/
52 class VideoWidget : public QFrame
53 {
54     Q_OBJECT
55 friend class MainInterface;
56
57 public:
58     VideoWidget( intf_thread_t * );
59     virtual ~VideoWidget();
60
61     void *request( vout_thread_t *, int *, int *,
62                    unsigned int *, unsigned int * );
63     void  release( void * );
64     int   control( void *, int, va_list );
65
66     virtual QSize sizeHint() const;
67 private:
68     intf_thread_t *p_intf;
69     vout_thread_t *p_vout;
70
71     vlc_mutex_t lock;
72     QSize videoSize;
73
74 signals:
75     void askVideoWidgetToShow();
76     //void askResize();
77
78 public slots:
79     void SetSizing( unsigned int, unsigned int );
80 };
81
82 /******************** Background Widget ****************/
83 class BackgroundWidget : public QWidget
84 {
85     Q_OBJECT
86 public:
87     BackgroundWidget( intf_thread_t * );
88     virtual ~BackgroundWidget();
89
90 private:
91     QPalette plt;
92     QLabel *label;
93     virtual void contextMenuEvent( QContextMenuEvent *event );
94     intf_thread_t *p_intf;
95     virtual void resizeEvent( QResizeEvent * event );
96 public slots:
97     void toggle(){ TOGGLEV( this ); }
98     void update( QString );
99 };
100
101 class VisualSelector : public QFrame
102 {
103     Q_OBJECT
104 public:
105     VisualSelector( intf_thread_t *);
106     virtual ~VisualSelector();
107 private:
108     intf_thread_t *p_intf;
109     QLabel *current;
110 private slots:
111     void prev();
112     void next();
113 };
114
115 /* Advanced Button Bar */
116 class QPushButton;
117 class AdvControlsWidget : public QFrame
118 {
119     Q_OBJECT
120 public:
121     AdvControlsWidget( intf_thread_t *);
122     virtual ~AdvControlsWidget();
123
124     void enableInput( bool );
125     void enableVideo( bool );
126
127 private:
128     intf_thread_t *p_intf;
129     QPushButton *recordButton, *ABButton;
130     QPushButton *snapshotButton, *frameButton;
131
132     mtime_t timeA, timeB;
133
134 private slots:
135     void snapshot();
136 #if 0
137     void frame();
138 #endif
139     void fromAtoB();
140     void record();
141     void AtoBLoop( float, int, int );
142 };
143
144 /* Button Bar */
145 class InputSlider;
146 class QSlider;
147 class QGridLayout;
148 class VolumeClickHandler;
149 class SoundSlider;
150 class QAbstractSlider;
151 class QToolButton;
152
153 class ControlsWidget : public QFrame
154 {
155     Q_OBJECT
156 public:
157     /* p_intf, advanced control visible or not, blingbling or not */
158     ControlsWidget( intf_thread_t *, MainInterface*, bool, bool );
159     virtual ~ControlsWidget();
160
161     QPushButton *playlistButton;
162     void setStatus( int );
163     void enableInput( bool );
164     void enableVideo( bool );
165 public slots:
166     void setNavigation( int );
167 protected:
168     friend class MainInterface;
169     friend class VolumeClickHandler;
170 private:
171     intf_thread_t       *p_intf;
172     QWidget             *discFrame;
173     QWidget             *telexFrame;
174     QGridLayout         *controlLayout;
175     InputSlider         *slider;
176     QPushButton         *prevSectionButton, *nextSectionButton, *menuButton;
177     QPushButton         *playButton, *fullscreenButton;
178     QToolButton         *slowerButton, *fasterButton;
179     AdvControlsWidget   *advControls;
180     QLabel              *volMuteLabel;
181     QAbstractSlider     *volumeSlider;
182
183     bool                 b_advancedVisible;
184 private slots:
185     void play();
186     void stop();
187     void prev();
188     void next();
189     void updateVolume( int );
190     void updateVolume( void );
191     void updateInput();
192     void fullscreen();
193     void extSettings();
194     void faster();
195     void slower();
196     void toggleAdvanced();
197 signals:
198     void advancedControlsToggled( bool );
199 };
200
201 class VolumeClickHandler : public QObject
202 {
203 public:
204     VolumeClickHandler( intf_thread_t *_p_intf, ControlsWidget *_m ) :QObject(_m)
205     {m = _m; p_intf = _p_intf; }
206     virtual ~VolumeClickHandler() {};
207     bool eventFilter( QObject *obj, QEvent *e )
208     {
209         if (e->type() == QEvent::MouseButtonPress  )
210         {
211             aout_VolumeMute( p_intf, NULL );
212             audio_volume_t i_volume;
213             aout_VolumeGet( p_intf, &i_volume );
214             m->updateVolume( i_volume *  VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
215             return true;
216         }
217         return false;
218     }
219 private:
220     ControlsWidget *m;
221     intf_thread_t *p_intf;
222 };
223
224 #include <QLabel>
225 #include <QMouseEvent>
226 class TimeLabel : public QLabel
227 {
228     Q_OBJECT
229     void mousePressEvent( QMouseEvent *event )
230     {
231         emit timeLabelClicked();
232     }
233     void mouseDoubleClickEvent( QMouseEvent *event )
234     {
235         emit timeLabelDoubleClicked();
236     }
237 signals:
238     void timeLabelClicked();
239     void timeLabelDoubleClicked();
240 };
241
242 class SpeedLabel : public QLabel
243 {
244     Q_OBJECT
245 public:
246     SpeedLabel( intf_thread_t *_p_intf, const QString text ): QLabel( text)
247     { p_intf = _p_intf; }
248
249 protected:
250     virtual void mouseDoubleClickEvent ( QMouseEvent * event )
251     {
252         THEMIM->getIM()->setRate( INPUT_RATE_DEFAULT );
253     }
254 private:
255     intf_thread_t *p_intf;
256 };
257
258 /******************** Speed Control Widgets ****************/
259 class SpeedControlWidget : public QFrame
260 {
261     Q_OBJECT
262 public:
263     SpeedControlWidget( intf_thread_t *);
264     virtual ~SpeedControlWidget();
265     void updateControls( int );
266 private:
267     intf_thread_t *p_intf;
268     QSlider *speedSlider;
269 public slots:
270     void setEnable( bool );
271 private slots:
272     void updateRate( int );
273     void resetRate();
274 };
275
276 #endif