]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/interface_widgets.hpp
qt4: uses setMinimumSize from the good thread using signal/slot
[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  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #ifndef _INTFWIDGETS_H_
26 #define _INTFWIDGETS_H_
27
28 #include <vlc/vlc.h>
29 #include <vlc_interface.h>
30
31 #include <vlc_aout.h>
32 #include "qt4.hpp"
33
34 #include <QWidget>
35 #include <QFrame>
36
37 class ResizeEvent;
38 class QPalette;
39 class QPixmap;
40 class QLabel;
41 class QHBoxLayout;
42
43 /******************** Video Widget ****************/
44 class VideoWidget : public QFrame
45 {
46     Q_OBJECT
47 public:
48     VideoWidget( intf_thread_t * );
49     virtual ~VideoWidget();
50
51     void *request( vout_thread_t *, int *, int *,
52                    unsigned int *, unsigned int * );
53     void release( void * );
54     int control( void *, int, va_list );
55
56     int i_video_height, i_video_width;
57     vout_thread_t *p_vout;
58
59     QSize widgetSize;
60     virtual QSize sizeHint() const;
61 private:
62     QWidget *frame;
63     intf_thread_t *p_intf;
64     vlc_mutex_t lock;
65 signals:
66     void askResize();
67 private slots:
68     void SetMinSize();
69 };
70
71 /******************** Background Widget ****************/
72 class BackgroundWidget : public QFrame
73 {
74     Q_OBJECT
75 public:
76     BackgroundWidget( intf_thread_t * );
77     virtual ~BackgroundWidget();
78     QSize widgetSize;
79     virtual QSize sizeHint() const;
80 private:
81     QPalette plt;
82     QLabel *label;
83     QHBoxLayout *backgroundLayout;
84     virtual void resizeEvent( QResizeEvent *e );
85     int DrawBackground();
86     int CleanBackground();
87     intf_thread_t *p_intf;
88 private slots:
89     void setArt( QString );
90 };
91
92 class VisualSelector : public QFrame
93 {
94     Q_OBJECT
95 public:
96     VisualSelector( intf_thread_t *);
97     virtual ~VisualSelector();
98 private:
99     intf_thread_t *p_intf;
100     QLabel *current;
101 private slots:
102     void prev();
103     void next();
104 };
105
106 class QPushButton;
107 class AdvControlsWidget : public QFrame
108 {
109     Q_OBJECT
110 public:
111     AdvControlsWidget( intf_thread_t *);
112     virtual ~AdvControlsWidget();
113     void enableInput( bool );
114     void enableVideo( bool );
115 private:
116     intf_thread_t *p_intf;
117     QPushButton *normalButton;
118     QPushButton *snapshotButton;
119 private slots:
120     void normal();
121     void snapshot();
122     void fullscreen();
123 };
124
125 class InputSlider;
126 class QSlider;
127 class QGridLayout;
128 class VolumeClickHandler;
129 class ControlsWidget : public QFrame
130 {
131     Q_OBJECT
132 public:
133     ControlsWidget( intf_thread_t *);
134     virtual ~ControlsWidget();
135
136     QPushButton *playlistButton;
137     QSlider *volumeSlider;
138     void setStatus( int );
139     void enableInput( bool );
140     void enableVideo( bool );
141 public slots:
142     void setNavigation( int );
143     void updateOnTimer();
144 protected:
145     friend class MainInterface;
146     friend class VolumeClickHandler;
147 private:
148     intf_thread_t *p_intf;
149     QFrame *discFrame;
150     QGridLayout *controlLayout;
151     InputSlider         *slider;
152     QPushButton *prevSectionButton, *nextSectionButton, *menuButton;
153     QPushButton *playButton, *fullscreenButton;
154     QPushButton *slowerButton, *fasterButton;
155 private slots:
156     void play();
157     void stop();
158     void prev();
159     void next();
160     void updateVolume( int );
161     void fullscreen();
162     void extSettings();
163     void prefs();
164     void faster();
165     void slower();
166 };
167
168 class VolumeClickHandler : public QObject
169 {
170 public:
171     VolumeClickHandler( intf_thread_t *_p_intf, ControlsWidget *_m ) :QObject(_m)
172     {m = _m; p_intf = _p_intf; }
173     virtual ~VolumeClickHandler() {};
174     bool eventFilter( QObject *obj, QEvent *e )
175     {
176         if (e->type() == QEvent::MouseButtonPress )
177         {
178             aout_VolumeMute( p_intf, NULL );
179             return true;
180         }
181         return false;
182     }
183 private:
184     ControlsWidget *m;
185     intf_thread_t *p_intf;
186 };
187
188
189 /******************** Playlist Widgets ****************/
190 #include <QModelIndex>
191 #include <QSplitter>
192 class QSignalMapper;
193 class PLSelector;
194 class PLPanel;
195 class QPushButton;
196
197 class PlaylistWidget : public QSplitter
198 {
199     Q_OBJECT;
200 public:
201     PlaylistWidget( intf_thread_t *_p_i ) ;
202     virtual ~PlaylistWidget();
203     QSize widgetSize;
204     virtual QSize sizeHint() const;
205 private:
206     PLSelector *selector;
207     PLPanel *rightPanel;
208     QPushButton *addButton;
209     QLabel *art;
210     QString prevArt;
211 protected:
212      intf_thread_t *p_intf;
213 private slots:
214     void setArt( QString );
215 signals:
216     void rootChanged( int );
217     void artSet( QString );
218 };
219
220 #endif