]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/interface_widgets.hpp
don't poll volume-change, change volumecontrol to use signal from
[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     vout_thread_t *p_vout;
61
62     vlc_mutex_t lock;
63
64 signals:
65     void askVideoWidgetToShow();
66     //void askResize();
67
68 public slots:
69     void SetSizing( unsigned int, unsigned int );
70 };
71
72 /******************** Background Widget ****************/
73 class BackgroundWidget : public QWidget
74 {
75     Q_OBJECT
76 public:
77     BackgroundWidget( intf_thread_t * );
78     virtual ~BackgroundWidget();
79
80 private:
81     QPalette plt;
82     QLabel *label;
83     virtual void contextMenuEvent( QContextMenuEvent *event );
84     intf_thread_t *p_intf;
85
86 public slots:
87     void toggle(){ TOGGLEV( this ); }
88     void update( QString );
89 };
90
91 class VisualSelector : public QFrame
92 {
93     Q_OBJECT
94 public:
95     VisualSelector( intf_thread_t *);
96     virtual ~VisualSelector();
97 private:
98     intf_thread_t *p_intf;
99     QLabel *current;
100 private slots:
101     void prev();
102     void next();
103 };
104
105 /* Advanced Button Bar */
106 class QPushButton;
107 class AdvControlsWidget : public QFrame
108 {
109     Q_OBJECT
110 public:
111     AdvControlsWidget( intf_thread_t *);
112     virtual ~AdvControlsWidget();
113
114     void enableInput( bool );
115     void enableVideo( bool );
116
117 private:
118     intf_thread_t *p_intf;
119     QPushButton *recordButton, *ABButton;
120     QPushButton *snapshotButton, *frameButton;
121
122     mtime_t timeA, timeB;
123
124 private slots:
125     void snapshot();
126     void frame();
127     void fromAtoB();
128     void record();
129     void AtoBLoop( float, int, int );
130 };
131
132 /* Button Bar */
133 class InputSlider;
134 class QSlider;
135 class QGridLayout;
136 class VolumeClickHandler;
137 class SoundSlider;
138 class QAbstractSlider;
139 class QToolButton;
140
141 class ControlsWidget : public QFrame
142 {
143     Q_OBJECT
144 public:
145     /* p_intf, advanced control visible or not, blingbling or not */
146     ControlsWidget( intf_thread_t *, MainInterface*, bool, bool );
147     virtual ~ControlsWidget();
148
149     QPushButton *playlistButton;
150     void setStatus( int );
151     void enableInput( bool );
152     void enableVideo( bool );
153 public slots:
154     void setNavigation( int );
155 protected:
156     friend class MainInterface;
157     friend class VolumeClickHandler;
158 private:
159     intf_thread_t       *p_intf;
160     QWidget             *discFrame;
161     QWidget             *telexFrame;
162     QGridLayout         *controlLayout;
163     InputSlider         *slider;
164     QPushButton         *prevSectionButton, *nextSectionButton, *menuButton;
165     QPushButton         *playButton, *fullscreenButton;
166     QToolButton         *slowerButton, *fasterButton;
167     AdvControlsWidget   *advControls;
168     QLabel              *volMuteLabel;
169     QAbstractSlider     *volumeSlider;
170
171     bool                 b_advancedVisible;
172 private slots:
173     void play();
174     void stop();
175     void prev();
176     void next();
177     void updateVolume( int );
178     void updateVolume( void );
179     void fullscreen();
180     void extSettings();
181     void faster();
182     void slower();
183     void toggleAdvanced();
184 signals:
185     void advancedControlsToggled( bool );
186 };
187
188 class VolumeClickHandler : public QObject
189 {
190 public:
191     VolumeClickHandler( intf_thread_t *_p_intf, ControlsWidget *_m ) :QObject(_m)
192     {m = _m; p_intf = _p_intf; }
193     virtual ~VolumeClickHandler() {};
194     bool eventFilter( QObject *obj, QEvent *e )
195     {
196         if (e->type() == QEvent::MouseButtonPress  )
197         {
198             aout_VolumeMute( p_intf, NULL );
199             audio_volume_t i_volume;
200             aout_VolumeGet( p_intf, &i_volume );
201             m->updateVolume( i_volume *  VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
202             return true;
203         }
204         return false;
205     }
206 private:
207     ControlsWidget *m;
208     intf_thread_t *p_intf;
209 };
210
211 #include <QLabel>
212 #include <QMouseEvent>
213 class TimeLabel : public QLabel
214 {
215     Q_OBJECT
216     void mousePressEvent( QMouseEvent *event )
217     {
218         emit timeLabelClicked();
219     }
220     void mouseDoubleClickEvent( QMouseEvent *event )
221     {
222         emit timeLabelDoubleClicked();
223     }
224 signals:
225     void timeLabelClicked();
226     void timeLabelDoubleClicked();
227 };
228
229
230 /******************** Speed Control Widgets ****************/
231 class SpeedControlWidget : public QFrame
232 {
233     Q_OBJECT
234 public:
235     SpeedControlWidget( intf_thread_t *);
236     virtual ~SpeedControlWidget();
237     void updateControls( int );
238 private:
239     intf_thread_t *p_intf;
240     QSlider *speedSlider;
241 private slots:
242     void updateRate( int );
243     void resetRate();
244 };
245
246 #endif