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