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