]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/interface_widgets.hpp
Qt4 - Have a slider to control precisely the rate, usefull since we can here audio...
[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     int i_video_height, i_video_width;
59     vout_thread_t *p_vout;
60
61     QSize widgetSize;
62     virtual QSize sizeHint() const;
63 private:
64     QWidget *frame;
65     intf_thread_t *p_intf;
66     vlc_mutex_t lock;
67 signals:
68     void askResize();
69 private slots:
70     void SetMinSize();
71 };
72
73 /******************** Background Widget ****************/
74 class BackgroundWidget : public QFrame
75 {
76     Q_OBJECT
77 public:
78     BackgroundWidget( intf_thread_t * );
79     virtual ~BackgroundWidget();
80     QSize widgetSize;
81     virtual QSize sizeHint() const;
82 private:
83     QPalette plt;
84     QLabel *label;
85     QHBoxLayout *backgroundLayout;
86     virtual void resizeEvent( QResizeEvent *e );
87     int DrawBackground();
88     int CleanBackground();
89     intf_thread_t *p_intf;
90 private slots:
91     void setArt( QString );
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 class QPushButton;
109 class AdvControlsWidget : public QFrame
110 {
111     Q_OBJECT
112 public:
113     AdvControlsWidget( intf_thread_t *);
114     virtual ~AdvControlsWidget();
115     void enableInput( bool );
116     void enableVideo( bool );
117 private:
118     intf_thread_t *p_intf;
119     QPushButton *normalButton, *recordButton, *ABButton;
120     QPushButton *snapshotButton, *frameButton;
121 private slots:
122     void normal();
123     void snapshot();
124     void frame();
125     void fromAtoB();
126     void record();
127 };
128
129
130
131 class InputSlider;
132 class QSlider;
133 class QGridLayout;
134 class VolumeClickHandler;
135 class ControlsWidget : public QFrame
136 {
137     Q_OBJECT
138 public:
139     ControlsWidget( intf_thread_t *, bool );
140     virtual ~ControlsWidget();
141
142     QPushButton *playlistButton;
143     QSlider *volumeSlider;
144     void setStatus( int );
145     void enableInput( bool );
146     void enableVideo( bool );
147 public slots:
148     void setNavigation( int );
149     void updateOnTimer();
150 protected:
151     friend class MainInterface;
152     friend class VolumeClickHandler;
153 private:
154     intf_thread_t       *p_intf;
155     QFrame              *discFrame;
156     QGridLayout         *controlLayout;
157     InputSlider         *slider;
158     QPushButton         *prevSectionButton, *nextSectionButton, *menuButton;
159     QPushButton         *playButton, *fullscreenButton;
160     QPushButton         *slowerButton, *fasterButton;
161     AdvControlsWidget   *advControls;
162     QLabel              *volMuteLabel;
163
164     bool                 b_advancedVisible;
165 private slots:
166     void play();
167     void stop();
168     void prev();
169     void next();
170     void updateVolume( int );
171     void fullscreen();
172     void extSettings();
173     void prefs();
174     void faster();
175     void slower();
176     void toggleAdvanced();
177 signals:
178     void advancedControlsToggled( bool );
179 };
180
181 class VolumeClickHandler : public QObject
182 {
183 public:
184     VolumeClickHandler( intf_thread_t *_p_intf, ControlsWidget *_m ) :QObject(_m)
185     {m = _m; p_intf = _p_intf; }
186     virtual ~VolumeClickHandler() {};
187     bool eventFilter( QObject *obj, QEvent *e )
188     {
189         if (e->type() == QEvent::MouseButtonPress )
190         {
191             aout_VolumeMute( p_intf, NULL );
192             audio_volume_t i_volume;
193             aout_VolumeGet( p_intf, &i_volume );
194             m->updateVolume( i_volume *  VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
195             return true;
196         }
197         return false;
198     }
199 private:
200     ControlsWidget *m;
201     intf_thread_t *p_intf;
202 };
203
204
205 /******************** Playlist Widgets ****************/
206 #include <QModelIndex>
207 #include <QSplitter>
208 class QSignalMapper;
209 class PLSelector;
210 class PLPanel;
211 class QPushButton;
212
213 class PlaylistWidget : public QSplitter
214 {
215     Q_OBJECT;
216 public:
217     PlaylistWidget( intf_thread_t *_p_i ) ;
218     virtual ~PlaylistWidget();
219     QSize widgetSize;
220     virtual QSize sizeHint() const;
221 private:
222     PLSelector *selector;
223     PLPanel *rightPanel;
224     QPushButton *addButton;
225     QLabel *art;
226     QString prevArt;
227 protected:
228      intf_thread_t *p_intf;
229 private slots:
230     void setArt( QString );
231 signals:
232     void rootChanged( int );
233     void artSet( QString );
234 };
235
236
237 /******************** Speed Control Widgets ****************/
238 class SpeedControlWidget : public QFrame
239 {
240     Q_OBJECT
241 public:
242     SpeedControlWidget( intf_thread_t *);
243     virtual ~SpeedControlWidget();
244     void updateControls( int );
245 private:
246     intf_thread_t *p_intf;
247     QSlider *speedSlider;
248     QPushButton *normalSpeedButton;
249 private slots:
250     void updateRate( int );
251     void resetRate();
252 };
253
254
255 #endif