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