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