]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/interface_widgets.hpp
Qt4 - time left implementation. Do it better, faster, with also a middle click, and...
[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     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     virtual QSize sizeHint() const;
83 private:
84     QPalette plt;
85     QLabel *label;
86     QHBoxLayout *backgroundLayout;
87     virtual void resizeEvent( QResizeEvent *e );
88     virtual void contextMenuEvent( QContextMenuEvent *event );
89     int DrawBackground();
90     int CleanBackground();
91     intf_thread_t *p_intf;
92 public slots:
93     void setArt( QString );
94     void toggle(){ TOGGLEV( this ); }
95 };
96
97 class VisualSelector : public QFrame
98 {
99     Q_OBJECT
100 public:
101     VisualSelector( intf_thread_t *);
102     virtual ~VisualSelector();
103 private:
104     intf_thread_t *p_intf;
105     QLabel *current;
106 private slots:
107     void prev();
108     void next();
109 };
110
111 /* Advanced Button Bar */
112 class QPushButton;
113 class AdvControlsWidget : public QFrame
114 {
115     Q_OBJECT
116 public:
117     AdvControlsWidget( intf_thread_t *);
118     virtual ~AdvControlsWidget();
119
120     void enableInput( bool );
121     void enableVideo( bool );
122
123 private:
124     intf_thread_t *p_intf;
125     QPushButton *recordButton, *ABButton;
126     QPushButton *snapshotButton, *frameButton;
127
128 private slots:
129     void snapshot();
130     void frame();
131     void fromAtoB();
132     void record();
133 };
134
135 /* Button Bar */
136 class InputSlider;
137 class QSlider;
138 class QGridLayout;
139 class VolumeClickHandler;
140 class ControlsWidget : public QFrame
141 {
142     Q_OBJECT
143 public:
144     ControlsWidget( intf_thread_t *, bool );
145     virtual ~ControlsWidget();
146
147     QPushButton *playlistButton;
148     QSlider *volumeSlider;
149     void setStatus( int );
150     void enableInput( bool );
151     void enableVideo( bool );
152 public slots:
153     void setNavigation( int );
154     void updateOnTimer();
155 protected:
156     friend class MainInterface;
157     friend class VolumeClickHandler;
158 private:
159     intf_thread_t       *p_intf;
160     QFrame              *discFrame;
161     QGridLayout         *controlLayout;
162     InputSlider         *slider;
163     QPushButton         *prevSectionButton, *nextSectionButton, *menuButton;
164     QPushButton         *playButton, *fullscreenButton;
165     QPushButton         *slowerButton, *fasterButton;
166     AdvControlsWidget   *advControls;
167     QLabel              *volMuteLabel;
168
169     bool                 b_advancedVisible;
170 private slots:
171     void play();
172     void stop();
173     void prev();
174     void next();
175     void updateVolume( int );
176     void fullscreen();
177     void extSettings();
178     void faster();
179     void slower();
180     void toggleAdvanced();
181 signals:
182     void advancedControlsToggled( bool );
183 };
184
185 class VolumeClickHandler : public QObject
186 {
187 public:
188     VolumeClickHandler( intf_thread_t *_p_intf, ControlsWidget *_m ) :QObject(_m)
189     {m = _m; p_intf = _p_intf; }
190     virtual ~VolumeClickHandler() {};
191     bool eventFilter( QObject *obj, QEvent *e )
192     {
193         if (e->type() == QEvent::MouseButtonPress  )
194         {
195             aout_VolumeMute( p_intf, NULL );
196             audio_volume_t i_volume;
197             aout_VolumeGet( p_intf, &i_volume );
198             m->updateVolume( i_volume *  VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
199             return true;
200         }
201         return false;
202     }
203 private:
204     ControlsWidget *m;
205     intf_thread_t *p_intf;
206 };
207
208 #include <QLabel>
209 #include <QMouseEvent>
210 class TimeLabel : public QLabel
211 {
212     Q_OBJECT
213     void mousePressEvent( QMouseEvent *event )
214     {
215         emit timeLabelClicked();
216     }
217     void mouseDoubleClickEvent( QMouseEvent *event )
218     {
219         emit timeLabelDoubleClicked();
220     }
221 signals:
222     void timeLabelClicked();
223     void timeLabelDoubleClicked();
224 };
225
226 /******************** Playlist Widgets ****************/
227 #include <QModelIndex>
228 #include <QSplitter>
229 class QSignalMapper;
230 class PLSelector;
231 class PLPanel;
232 class QPushButton;
233
234 class PlaylistWidget : public QSplitter
235 {
236     Q_OBJECT;
237 public:
238     PlaylistWidget( intf_thread_t *_p_i ) ;
239     virtual ~PlaylistWidget();
240 private:
241     PLSelector *selector;
242     PLPanel *rightPanel;
243     QPushButton *addButton;
244     QLabel *art;
245     QString prevArt;
246 protected:
247      intf_thread_t *p_intf;
248 private slots:
249     void setArt( QString );
250 signals:
251     void rootChanged( int );
252     void artSet( QString );
253 };
254
255
256 /******************** Speed Control Widgets ****************/
257 class SpeedControlWidget : public QFrame
258 {
259     Q_OBJECT
260 public:
261     SpeedControlWidget( intf_thread_t *);
262     virtual ~SpeedControlWidget();
263     void updateControls( int );
264 private:
265     intf_thread_t *p_intf;
266     QSlider *speedSlider;
267     QPushButton *normalSpeedButton;
268 private slots:
269     void updateRate( int );
270     void resetRate();
271 };
272
273
274 #endif