]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/interface_widgets.hpp
Qt4 - Remove preferences button from interface. Remove unuseful debug.
[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 faster();
174     void slower();
175     void toggleAdvanced();
176 signals:
177     void advancedControlsToggled( bool );
178 };
179
180 class VolumeClickHandler : public QObject
181 {
182 public:
183     VolumeClickHandler( intf_thread_t *_p_intf, ControlsWidget *_m ) :QObject(_m)
184     {m = _m; p_intf = _p_intf; }
185     virtual ~VolumeClickHandler() {};
186     bool eventFilter( QObject *obj, QEvent *e )
187     {
188         if (e->type() == QEvent::MouseButtonPress  )
189         {
190             aout_VolumeMute( p_intf, NULL );
191             audio_volume_t i_volume;
192             aout_VolumeGet( p_intf, &i_volume );
193             m->updateVolume( i_volume *  VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
194             return true;
195         }
196         return false;
197     }
198 private:
199     ControlsWidget *m;
200     intf_thread_t *p_intf;
201 };
202
203 #include <QLabel>
204 #include <QMouseEvent>
205 class TimeLabel : public QLabel
206 {
207     Q_OBJECT
208     void mousePressEvent( QMouseEvent *event )
209     {
210         if( event->button() == Qt::LeftButton ) emit timeLabelClicked();
211     }
212 signals:
213     void timeLabelClicked();
214 };
215
216 /******************** Playlist Widgets ****************/
217 #include <QModelIndex>
218 #include <QSplitter>
219 class QSignalMapper;
220 class PLSelector;
221 class PLPanel;
222 class QPushButton;
223
224 class PlaylistWidget : public QSplitter
225 {
226     Q_OBJECT;
227 public:
228     PlaylistWidget( intf_thread_t *_p_i ) ;
229     virtual ~PlaylistWidget();
230     QSize widgetSize;
231     virtual QSize sizeHint() const;
232 private:
233     PLSelector *selector;
234     PLPanel *rightPanel;
235     QPushButton *addButton;
236     QLabel *art;
237     QString prevArt;
238 protected:
239      intf_thread_t *p_intf;
240 private slots:
241     void setArt( QString );
242 signals:
243     void rootChanged( int );
244     void artSet( QString );
245 };
246
247
248 /******************** Speed Control Widgets ****************/
249 class SpeedControlWidget : public QFrame
250 {
251     Q_OBJECT
252 public:
253     SpeedControlWidget( intf_thread_t *);
254     virtual ~SpeedControlWidget();
255     void updateControls( int );
256 private:
257     intf_thread_t *p_intf;
258     QSlider *speedSlider;
259     QPushButton *normalSpeedButton;
260 private slots:
261     void updateRate( int );
262     void resetRate();
263 };
264
265
266 #endif