]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/interface_widgets.hpp
9ef35877037d232557044ce63f9912f0b6cbe532
[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 #ifdef HAVE_CONFIG_H
30 # include "config.h"
31 #endif
32
33 #include <vlc_common.h>
34 #include <vlc_interface.h>
35 #include <vlc_aout.h>
36
37 #include "qt4.hpp"
38 #include "main_interface.hpp"
39 #include "components/controller.hpp"
40 #include "components/controller_widget.hpp"
41
42 #include <QWidget>
43 #include <QFrame>
44 #include <QLabel>
45 #include <QMouseEvent>
46
47 class ResizeEvent;
48 class QPalette;
49 class QPixmap;
50 class QHBoxLayout;
51
52 /******************** Video Widget ****************/
53 class VideoWidget : public QFrame
54 {
55     Q_OBJECT
56 friend class MainInterface;
57
58 public:
59     VideoWidget( intf_thread_t * );
60     virtual ~VideoWidget();
61
62     void *request( vout_thread_t *, int *, int *,
63                    unsigned int *, unsigned int * );
64     void  release( void );
65     int   control( void *, int, va_list );
66
67     virtual QSize sizeHint() const;
68
69 protected:
70     virtual QPaintEngine *paintEngine() const
71     {
72         return NULL;
73     }
74
75     virtual void paintEvent(QPaintEvent *);
76
77 private:
78     intf_thread_t *p_intf;
79     vout_thread_t *p_vout;
80
81     QSize videoSize;
82
83 signals:
84     void askVideoWidgetToShow( unsigned int, unsigned int );
85
86 public slots:
87     void SetSizing( unsigned int, unsigned int );
88
89 };
90
91 /******************** Background Widget ****************/
92 class BackgroundWidget : public QWidget
93 {
94     Q_OBJECT
95 public:
96     BackgroundWidget( intf_thread_t * );
97     virtual ~BackgroundWidget();
98
99 private:
100     QPalette plt;
101     QLabel *label;
102     virtual void contextMenuEvent( QContextMenuEvent *event );
103     intf_thread_t *p_intf;
104     virtual void resizeEvent( QResizeEvent * event );
105
106 public slots:
107     void toggle(){ TOGGLEV( this ); }
108     void updateArt( input_item_t* );
109 };
110
111 #if 0
112 class VisualSelector : public QFrame
113 {
114     Q_OBJECT
115 public:
116     VisualSelector( intf_thread_t *);
117     virtual ~VisualSelector();
118 private:
119     intf_thread_t *p_intf;
120     QLabel *current;
121 private slots:
122     void prev();
123     void next();
124 };
125 #endif
126
127 #define VOLUME_MAX 200
128 class VolumeClickHandler : public QObject
129 {
130 public:
131     VolumeClickHandler( intf_thread_t *_p_intf, SoundWidget *_m ) : QObject(_m)
132     {m = _m; p_intf = _p_intf; }
133     virtual ~VolumeClickHandler() {};
134     virtual bool eventFilter( QObject *obj, QEvent *e );
135 private:
136     SoundWidget *m;
137     intf_thread_t *p_intf;
138 };
139
140 class TimeLabel : public QLabel
141 {
142     Q_OBJECT
143 public:
144     TimeLabel( intf_thread_t *_p_intf );
145 protected:
146     virtual void mousePressEvent( QMouseEvent *event )
147     {
148         toggleTimeDisplay();
149     }
150     virtual void mouseDoubleClickEvent( QMouseEvent *event )
151     {
152         toggleTimeDisplay();
153         emit timeLabelDoubleClicked();
154     }
155 private:
156     intf_thread_t *p_intf;
157     bool b_remainingTime;
158     void toggleTimeDisplay();
159 signals:
160     void timeLabelDoubleClicked();
161 private slots:
162     void setDisplayPosition( float pos, int time, int length );
163     void setStatus( int i_status );
164 };
165
166 class SpeedLabel : public QLabel
167 {
168     Q_OBJECT
169 public:
170     SpeedLabel( intf_thread_t *_p_intf, const QString text ): QLabel( text)
171     { p_intf = _p_intf; }
172
173 protected:
174     virtual void mouseDoubleClickEvent ( QMouseEvent * event )
175     {
176         THEMIM->getIM()->setRate( INPUT_RATE_DEFAULT );
177     }
178 private:
179     intf_thread_t *p_intf;
180 };
181
182 /******************** Speed Control Widgets ****************/
183 class SpeedControlWidget : public QFrame
184 {
185     Q_OBJECT
186 public:
187     SpeedControlWidget( intf_thread_t *);
188     virtual ~SpeedControlWidget();
189     void updateControls( int );
190 private:
191     intf_thread_t *p_intf;
192     QSlider *speedSlider;
193 public slots:
194     void setEnable( bool );
195 private slots:
196     void updateRate( int );
197     void resetRate();
198 };
199
200 class CoverArtLabel : public QLabel
201 {
202     Q_OBJECT
203 public:
204     CoverArtLabel( QWidget *parent,
205                    vlc_object_t *p_this,
206                    input_item_t *p_input = NULL );
207     virtual ~CoverArtLabel()
208             { if( p_input ) vlc_gc_decref( p_input ); };
209 private:
210     input_item_t *p_input;
211     vlc_object_t *p_this;
212     QString prevArt;
213
214 public slots:
215     void requestUpdate() { emit updateRequested(); };
216     void update( input_item_t* p_item )
217             { if( p_input ) vlc_gc_decref( p_input );
218               if( ( p_input = p_item ) ) vlc_gc_incref( p_input );
219               requestUpdate(); }
220
221 private slots:
222     void doUpdate();
223     void downloadCover();
224
225 signals:
226     void updateRequested();
227 };
228
229 #endif