]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/interface_widgets.hpp
Disable unused code.
[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_common.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
44 #define VOLUME_MAX 200
45
46 /* on WIN32 hide() for fullscreen controller doesnt work, so it have to be
47    done by trick with setting the opacity of window */
48 #ifdef WIN32
49     #define WIN32TRICK
50 #endif
51
52 /* to trying transparency with fullscreen controller on windows enable that */
53 /* it can be enabled on-non windows systems,
54    but it will be transparent only with composite manager */
55 #ifndef WIN32
56     #define HAVE_TRANSPARENCY 1
57 #else
58     #define HAVE_TRANSPARENCY 0
59 #endif
60
61 /* Default value of opacity for FS controller */
62 #define DEFAULT_OPACITY 0.75
63
64 class ResizeEvent;
65 class QPalette;
66 class QPixmap;
67 class QLabel;
68 class QHBoxLayout;
69
70 /******************** Video Widget ****************/
71 class VideoWidget : public QFrame
72 {
73     Q_OBJECT
74 friend class MainInterface;
75
76 public:
77     VideoWidget( intf_thread_t * );
78     virtual ~VideoWidget();
79
80     void *request( vout_thread_t *, int *, int *,
81                    unsigned int *, unsigned int * );
82     void  release( void * );
83     int   control( void *, int, va_list );
84
85     virtual QSize sizeHint() const;
86 private:
87     intf_thread_t *p_intf;
88     int i_vout;
89
90     QSize videoSize;
91
92 signals:
93     void askVideoWidgetToShow( unsigned int, unsigned int );
94
95 public slots:
96     void SetSizing( unsigned int, unsigned int );
97
98 protected:
99     virtual QPaintEngine *paintEngine() const
100     {
101         return NULL;
102     }
103
104     virtual void paintEvent(QPaintEvent *);
105 };
106
107 /******************** Background Widget ****************/
108 class BackgroundWidget : public QWidget
109 {
110     Q_OBJECT
111 public:
112     BackgroundWidget( intf_thread_t * );
113     virtual ~BackgroundWidget();
114
115 private:
116     QPalette plt;
117     QLabel *label;
118     virtual void contextMenuEvent( QContextMenuEvent *event );
119     intf_thread_t *p_intf;
120     virtual void resizeEvent( QResizeEvent * event );
121 public slots:
122     void toggle(){ TOGGLEV( this ); }
123     void updateArt( QString );
124 };
125
126 #if 0
127 class VisualSelector : public QFrame
128 {
129     Q_OBJECT
130 public:
131     VisualSelector( intf_thread_t *);
132     virtual ~VisualSelector();
133 private:
134     intf_thread_t *p_intf;
135     QLabel *current;
136 private slots:
137     void prev();
138     void next();
139 };
140 #endif
141
142 /* Advanced Button Bar */
143 class QPushButton;
144 class AdvControlsWidget : public QFrame
145 {
146     Q_OBJECT
147 public:
148     AdvControlsWidget( intf_thread_t *);
149     virtual ~AdvControlsWidget();
150
151     void enableInput( bool );
152     void enableVideo( bool );
153
154 private:
155     intf_thread_t *p_intf;
156     QPushButton *recordButton, *ABButton;
157     QPushButton *snapshotButton, *frameButton;
158
159     mtime_t timeA, timeB;
160
161 private slots:
162     void snapshot();
163 #if 0
164     void frame();
165 #endif
166     void fromAtoB();
167     void record();
168     void AtoBLoop( float, int, int );
169 };
170
171 /* Button Bar */
172 class InputSlider;
173 class QSlider;
174 class QGridLayout;
175 class VolumeClickHandler;
176 class SoundSlider;
177 class QAbstractSlider;
178 class QToolButton;
179
180 class ControlsWidget : public QFrame
181 {
182     Q_OBJECT
183 public:
184     /* p_intf, advanced control visible or not, blingbling or not */
185     ControlsWidget( intf_thread_t *_p_i, MainInterface *_p_mi,
186         bool b_advControls, bool b_shiny, bool b_fsCreation = false);
187     virtual ~ControlsWidget();
188
189     QPushButton *playlistButton;
190     void setStatus( int );
191     void enableInput( bool );
192     void enableVideo( bool );
193 public slots:
194     void setNavigation( int );
195 protected:
196     friend class MainInterface;
197     friend class VolumeClickHandler;
198 protected:
199     intf_thread_t       *p_intf;
200     QWidget             *discFrame;
201     QWidget             *telexFrame;
202     QGridLayout         *controlLayout;
203     InputSlider         *slider;
204     QPushButton         *prevSectionButton, *nextSectionButton, *menuButton;
205     QPushButton         *playButton, *fullscreenButton, *extSettingsButton;
206     QPushButton         *telexTransparent, *telexOn;
207     QSpinBox            *telexPage;
208     QToolButton         *slowerButton, *fasterButton;
209     QHBoxLayout         *controlButLayout;
210     AdvControlsWidget   *advControls;
211     QLabel              *volMuteLabel;
212     QAbstractSlider     *volumeSlider;
213     VolumeClickHandler  *hVolLabel;
214
215     bool                 b_advancedVisible;
216     bool                 b_telexTransparent;
217     bool                 b_telexEnabled;
218 protected slots:
219     void play();
220     void stop();
221     void prev();
222     void next();
223     void updateVolume( int );
224     void updateVolume( void );
225     void updateInput();
226     void fullscreen();
227     void extSettings();
228     void faster();
229     void slower();
230     void toggleAdvanced();
231     void toggleTeletext();
232     void toggleTeletextTransparency();
233     void enableTeletext( bool );
234 signals:
235     void advancedControlsToggled( bool );
236 };
237
238 /***********************************
239  * Fullscreen controller
240  ***********************************/
241 class FullscreenControllerWidget : public ControlsWidget
242 {
243     Q_OBJECT
244 public:
245     FullscreenControllerWidget( intf_thread_t *, MainInterface*, bool, bool );
246     virtual ~FullscreenControllerWidget();
247
248     /* */
249     void attachVout( vout_thread_t *p_vout );
250     void detachVout( vout_thread_t *p_vout );
251     void fullscreenChanged( vout_thread_t *, bool b_fs, int i_timeout );
252
253 protected:
254     friend class MainInterface;
255     friend class VolumeClickHandler;
256
257     virtual void mouseMoveEvent( QMouseEvent *event );
258     virtual void mousePressEvent( QMouseEvent *event );
259     virtual void enterEvent( QEvent *event );
260     virtual void leaveEvent( QEvent *event );
261     virtual void keyPressEvent( QKeyEvent *event );
262
263 private slots:
264     void showFSC();
265     void planHideFSC();
266     void hideFSC();
267
268     void slowHideFSC();
269
270
271 private:
272     QTimer *p_hideTimer;
273 #if HAVE_TRANSPARENCY
274     QTimer *p_slowHideTimer;
275 #endif
276
277     int i_mouse_last_x;
278     int i_mouse_last_y;
279
280     bool b_mouse_over;
281
282     bool b_slow_hide_begin;
283     int  i_slow_hide_timeout;
284
285 #ifdef WIN32TRICK
286     bool fscHidden;
287 #endif
288
289     virtual void customEvent( QEvent *event );
290
291     /* Shared variable between FSC and VLC (protected by a lock) */
292     vlc_mutex_t lock;
293     bool        b_fullscreen;
294     int         i_hide_timeout;  /* FSC hiding timeout, same as mouse hiding timeout */
295 };
296
297
298
299 class VolumeClickHandler : public QObject
300 {
301 public:
302     VolumeClickHandler( intf_thread_t *_p_intf, ControlsWidget *_m ) :QObject(_m)
303     {m = _m; p_intf = _p_intf; }
304     virtual ~VolumeClickHandler() {};
305     bool eventFilter( QObject *obj, QEvent *e )
306     {
307         if (e->type() == QEvent::MouseButtonPress  )
308         {
309             aout_VolumeMute( p_intf, NULL );
310             audio_volume_t i_volume;
311             aout_VolumeGet( p_intf, &i_volume );
312             m->updateVolume( i_volume *  VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
313             return true;
314         }
315         return false;
316     }
317 private:
318     ControlsWidget *m;
319     intf_thread_t *p_intf;
320 };
321
322 #include <QLabel>
323 #include <QMouseEvent>
324 class TimeLabel : public QLabel
325 {
326     Q_OBJECT
327     void mousePressEvent( QMouseEvent *event )
328     {
329         emit timeLabelClicked();
330     }
331     void mouseDoubleClickEvent( QMouseEvent *event )
332     {
333         emit timeLabelDoubleClicked();
334     }
335 signals:
336     void timeLabelClicked();
337     void timeLabelDoubleClicked();
338 };
339
340 class SpeedLabel : public QLabel
341 {
342     Q_OBJECT
343 public:
344     SpeedLabel( intf_thread_t *_p_intf, const QString text ): QLabel( text)
345     { p_intf = _p_intf; }
346
347 protected:
348     virtual void mouseDoubleClickEvent ( QMouseEvent * event )
349     {
350         THEMIM->getIM()->setRate( INPUT_RATE_DEFAULT );
351     }
352 private:
353     intf_thread_t *p_intf;
354 };
355
356 /******************** Speed Control Widgets ****************/
357 class SpeedControlWidget : public QFrame
358 {
359     Q_OBJECT
360 public:
361     SpeedControlWidget( intf_thread_t *);
362     virtual ~SpeedControlWidget();
363     void updateControls( int );
364 private:
365     intf_thread_t *p_intf;
366     QSlider *speedSlider;
367 public slots:
368     void setEnable( bool );
369 private slots:
370     void updateRate( int );
371     void resetRate();
372 };
373
374 #endif