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