]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/interface_widgets.hpp
Qt4 - MainInterface, avoid the bug that makes the popupMenu toggle the TimeDisplay().
[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 #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 signals:
214     void timeLabelClicked();
215 };
216
217 /******************** Playlist Widgets ****************/
218 #include <QModelIndex>
219 #include <QSplitter>
220 class QSignalMapper;
221 class PLSelector;
222 class PLPanel;
223 class QPushButton;
224
225 class PlaylistWidget : public QSplitter
226 {
227     Q_OBJECT;
228 public:
229     PlaylistWidget( intf_thread_t *_p_i ) ;
230     virtual ~PlaylistWidget();
231     QSize widgetSize;
232     virtual QSize sizeHint() const;
233 private:
234     PLSelector *selector;
235     PLPanel *rightPanel;
236     QPushButton *addButton;
237     QLabel *art;
238     QString prevArt;
239 protected:
240      intf_thread_t *p_intf;
241 private slots:
242     void setArt( QString );
243 signals:
244     void rootChanged( int );
245     void artSet( QString );
246 };
247
248
249 /******************** Speed Control Widgets ****************/
250 class SpeedControlWidget : public QFrame
251 {
252     Q_OBJECT
253 public:
254     SpeedControlWidget( intf_thread_t *);
255     virtual ~SpeedControlWidget();
256     void updateControls( int );
257 private:
258     intf_thread_t *p_intf;
259     QSlider *speedSlider;
260     QPushButton *normalSpeedButton;
261 private slots:
262     void updateRate( int );
263     void resetRate();
264 };
265
266
267 #endif