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