]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/interface_widgets.hpp
Qt4 - use a docked playlist, remove dead code, don't reinvent the wheel, remove the...
[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     virtual void contextMenuEvent( QContextMenuEvent *event );
88     int DrawBackground();
89     int CleanBackground();
90     intf_thread_t *p_intf;
91 public slots:
92     void setArt( QString );
93 };
94
95 class VisualSelector : public QFrame
96 {
97     Q_OBJECT
98 public:
99     VisualSelector( intf_thread_t *);
100     virtual ~VisualSelector();
101 private:
102     intf_thread_t *p_intf;
103     QLabel *current;
104 private slots:
105     void prev();
106     void next();
107 };
108
109 class QPushButton;
110 class AdvControlsWidget : public QFrame
111 {
112     Q_OBJECT
113 public:
114     AdvControlsWidget( intf_thread_t *);
115     virtual ~AdvControlsWidget();
116     void enableInput( bool );
117     void enableVideo( bool );
118 private:
119     intf_thread_t *p_intf;
120     QPushButton *normalButton, *recordButton, *ABButton;
121     QPushButton *snapshotButton, *frameButton;
122 private slots:
123     void normal();
124     void snapshot();
125     void frame();
126     void fromAtoB();
127     void record();
128 };
129
130
131
132 class InputSlider;
133 class QSlider;
134 class QGridLayout;
135 class VolumeClickHandler;
136 class ControlsWidget : public QFrame
137 {
138     Q_OBJECT
139 public:
140     ControlsWidget( intf_thread_t *, bool );
141     virtual ~ControlsWidget();
142
143     QPushButton *playlistButton;
144     QSlider *volumeSlider;
145     void setStatus( int );
146     void enableInput( bool );
147     void enableVideo( bool );
148 public slots:
149     void setNavigation( int );
150     void updateOnTimer();
151 protected:
152     friend class MainInterface;
153     friend class VolumeClickHandler;
154 private:
155     intf_thread_t       *p_intf;
156     QFrame              *discFrame;
157     QGridLayout         *controlLayout;
158     InputSlider         *slider;
159     QPushButton         *prevSectionButton, *nextSectionButton, *menuButton;
160     QPushButton         *playButton, *fullscreenButton;
161     QPushButton         *slowerButton, *fasterButton;
162     AdvControlsWidget   *advControls;
163     QLabel              *volMuteLabel;
164
165     bool                 b_advancedVisible;
166 private slots:
167     void play();
168     void stop();
169     void prev();
170     void next();
171     void updateVolume( int );
172     void fullscreen();
173     void extSettings();
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 #include <QLabel>
205 #include <QMouseEvent>
206 class TimeLabel : public QLabel
207 {
208     Q_OBJECT
209     void mousePressEvent( QMouseEvent *event )
210     {
211         if( event->button() == Qt::LeftButton ) emit timeLabelClicked();
212     }
213     void mouseDoubleClickEvent( QMouseEvent *event )
214     {
215         emit timeLabelDoubleClicked();
216     }
217 signals:
218     void timeLabelClicked();
219     void timeLabelDoubleClicked();
220 };
221
222 /******************** Playlist Widgets ****************/
223 #include <QModelIndex>
224 #include <QSplitter>
225 class QSignalMapper;
226 class PLSelector;
227 class PLPanel;
228 class QPushButton;
229
230 class PlaylistWidget : public QSplitter
231 {
232     Q_OBJECT;
233 public:
234     PlaylistWidget( intf_thread_t *_p_i ) ;
235     virtual ~PlaylistWidget();
236     QSize widgetSize;
237     virtual QSize sizeHint() const;
238 private:
239     PLSelector *selector;
240     PLPanel *rightPanel;
241     QPushButton *addButton;
242     QLabel *art;
243     QString prevArt;
244 protected:
245      intf_thread_t *p_intf;
246 private slots:
247     void setArt( QString );
248 signals:
249     void rootChanged( int );
250     void artSet( QString );
251 };
252
253
254 /******************** Speed Control Widgets ****************/
255 class SpeedControlWidget : public QFrame
256 {
257     Q_OBJECT
258 public:
259     SpeedControlWidget( intf_thread_t *);
260     virtual ~SpeedControlWidget();
261     void updateControls( int );
262 private:
263     intf_thread_t *p_intf;
264     QSlider *speedSlider;
265     QPushButton *normalSpeedButton;
266 private slots:
267     void updateRate( int );
268     void resetRate();
269 };
270
271
272 #endif