]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/interface_widgets.hpp
Qt4 - Volume Icon updates NOT in an TIMEOUT function, which is called very often...
[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
38 class ResizeEvent;
39 class QPalette;
40 class QPixmap;
41 class QLabel;
42 class QHBoxLayout;
43
44 /******************** Video Widget ****************/
45 class VideoWidget : public QFrame
46 {
47     Q_OBJECT
48 public:
49     VideoWidget( intf_thread_t * );
50     virtual ~VideoWidget();
51
52     void *request( vout_thread_t *, int *, int *,
53                    unsigned int *, unsigned int * );
54     void release( void * );
55     int control( void *, int, va_list );
56
57     int i_video_height, i_video_width;
58     vout_thread_t *p_vout;
59
60     QSize widgetSize;
61     virtual QSize sizeHint() const;
62 private:
63     QWidget *frame;
64     intf_thread_t *p_intf;
65     vlc_mutex_t lock;
66 signals:
67     void askResize();
68 private slots:
69     void SetMinSize();
70 };
71
72 /******************** Background Widget ****************/
73 class BackgroundWidget : public QFrame
74 {
75     Q_OBJECT
76 public:
77     BackgroundWidget( intf_thread_t * );
78     virtual ~BackgroundWidget();
79     QSize widgetSize;
80     virtual QSize sizeHint() const;
81 private:
82     QPalette plt;
83     QLabel *label;
84     QHBoxLayout *backgroundLayout;
85     virtual void resizeEvent( QResizeEvent *e );
86     int DrawBackground();
87     int CleanBackground();
88     intf_thread_t *p_intf;
89 private slots:
90     void setArt( QString );
91 };
92
93 class VisualSelector : public QFrame
94 {
95     Q_OBJECT
96 public:
97     VisualSelector( intf_thread_t *);
98     virtual ~VisualSelector();
99 private:
100     intf_thread_t *p_intf;
101     QLabel *current;
102 private slots:
103     void prev();
104     void next();
105 };
106
107 class QPushButton;
108 class AdvControlsWidget : public QFrame
109 {
110     Q_OBJECT
111 public:
112     AdvControlsWidget( intf_thread_t *);
113     virtual ~AdvControlsWidget();
114     void enableInput( bool );
115     void enableVideo( bool );
116 private:
117     intf_thread_t *p_intf;
118     QPushButton *normalButton, *recordButton, *ABButton;
119     QPushButton *snapshotButton, *frameButton;
120 private slots:
121     void normal();
122     void snapshot();
123     void frame();
124     void fromAtoB();
125     void record();
126 };
127
128 class InputSlider;
129 class QSlider;
130 class QGridLayout;
131 class VolumeClickHandler;
132 class ControlsWidget : public QFrame
133 {
134     Q_OBJECT
135 public:
136     ControlsWidget( intf_thread_t *, bool );
137     virtual ~ControlsWidget();
138
139     QPushButton *playlistButton;
140     QSlider *volumeSlider;
141     void setStatus( int );
142     void enableInput( bool );
143     void enableVideo( bool );
144 public slots:
145     void setNavigation( int );
146     void updateOnTimer();
147 protected:
148     friend class MainInterface;
149     friend class VolumeClickHandler;
150 private:
151     intf_thread_t       *p_intf;
152     QFrame              *discFrame;
153     QGridLayout         *controlLayout;
154     InputSlider         *slider;
155     QPushButton         *prevSectionButton, *nextSectionButton, *menuButton;
156     QPushButton         *playButton, *fullscreenButton;
157     QPushButton         *slowerButton, *fasterButton;
158     AdvControlsWidget   *advControls;
159     QLabel              *volMuteLabel;
160
161     bool                 b_advancedVisible;
162 private slots:
163     void play();
164     void stop();
165     void prev();
166     void next();
167     void updateVolume( int );
168     void fullscreen();
169     void extSettings();
170     void prefs();
171     void faster();
172     void slower();
173     void toggleAdvanced();
174 signals:
175     void advancedControlsToggled( bool );
176 };
177
178 class VolumeClickHandler : public QObject
179 {
180 public:
181     VolumeClickHandler( intf_thread_t *_p_intf, ControlsWidget *_m ) :QObject(_m)
182     {m = _m; p_intf = _p_intf; }
183     virtual ~VolumeClickHandler() {};
184     bool eventFilter( QObject *obj, QEvent *e )
185     {
186         if (e->type() == QEvent::MouseButtonPress )
187         {
188             aout_VolumeMute( p_intf, NULL );
189             audio_volume_t i_volume;
190             aout_VolumeGet( p_intf, &i_volume );
191             m->updateVolume( i_volume *  200 /AOUT_VOLUME_MAX );
192             return true;
193         }
194         return false;
195     }
196 private:
197     ControlsWidget *m;
198     intf_thread_t *p_intf;
199 };
200
201
202 /******************** Playlist Widgets ****************/
203 #include <QModelIndex>
204 #include <QSplitter>
205 class QSignalMapper;
206 class PLSelector;
207 class PLPanel;
208 class QPushButton;
209
210 class PlaylistWidget : public QSplitter
211 {
212     Q_OBJECT;
213 public:
214     PlaylistWidget( intf_thread_t *_p_i ) ;
215     virtual ~PlaylistWidget();
216     QSize widgetSize;
217     virtual QSize sizeHint() const;
218 private:
219     PLSelector *selector;
220     PLPanel *rightPanel;
221     QPushButton *addButton;
222     QLabel *art;
223     QString prevArt;
224 protected:
225      intf_thread_t *p_intf;
226 private slots:
227     void setArt( QString );
228 signals:
229     void rootChanged( int );
230     void artSet( QString );
231 };
232
233 #endif