]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/interface_widgets.hpp
Qt: use forward declaration when possible and remove includes
[vlc] / modules / gui / qt4 / components / interface_widgets.hpp
1 /*****************************************************************************
2  * interface_widgets.hpp : Custom widgets for the main interface
3  ****************************************************************************
4  * Copyright (C) 2006-2008 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 "main_interface.hpp" /* Interface integration */
34 #include "input_manager.hpp"  /* Speed control */
35
36 #include "components/controller.hpp"
37 #include "components/controller_widget.hpp"
38
39 #include <QWidget>
40 #include <QFrame>
41 #include <QLabel>
42 #include <QMouseEvent>
43
44 class ResizeEvent;
45 class QPixmap;
46 class QHBoxLayout;
47 class QMenu;
48 class QSlider;
49 class ReparentableWidget;
50
51 /******************** Video Widget ****************/
52 class VideoWidget : public QFrame
53 {
54     Q_OBJECT
55 friend class ReparentableWidget;
56
57 public:
58     VideoWidget( intf_thread_t * );
59     virtual ~VideoWidget();
60
61     WId request( int *, int *,
62                  unsigned int *, unsigned int *, bool );
63     void  release( void );
64     int   control( void *, int, va_list );
65
66     virtual QSize sizeHint() const;
67
68 protected:
69     virtual QPaintEngine *paintEngine() const
70     {
71         return NULL;
72     }
73
74 private:
75     intf_thread_t *p_intf;
76
77     QSize videoSize;
78     QWidget *reparentable;
79     QLayout *layout;
80
81 signals:
82     void keyPressed( QKeyEvent * );
83
84 public slots:
85     void SetSizing( unsigned int, unsigned int );
86     void SetFullScreen( bool );
87 };
88
89 /******************** Background Widget ****************/
90 class BackgroundWidget : public QWidget
91 {
92     Q_OBJECT
93 public:
94     BackgroundWidget( intf_thread_t * );
95
96 private:
97     QLabel *label;
98     virtual void contextMenuEvent( QContextMenuEvent *event );
99     intf_thread_t *p_intf;
100     virtual void resizeEvent( QResizeEvent * event );
101
102 public slots:
103     void toggle(){ TOGGLEV( this ); }
104     void updateArt( const QString& );
105 };
106
107 #if 0
108 class VisualSelector : public QFrame
109 {
110     Q_OBJECT
111 public:
112     VisualSelector( intf_thread_t *);
113     virtual ~VisualSelector();
114 private:
115     intf_thread_t *p_intf;
116     QLabel *current;
117 private slots:
118     void prev();
119     void next();
120 };
121 #endif
122
123 class TimeLabel : public QLabel
124 {
125     Q_OBJECT
126 public:
127     TimeLabel( intf_thread_t *_p_intf );
128 protected:
129     virtual void mousePressEvent( QMouseEvent *event )
130     {
131         toggleTimeDisplay();
132         event->accept();
133     }
134     virtual void mouseDoubleClickEvent( QMouseEvent *event )
135     {
136         event->accept();
137         toggleTimeDisplay();
138         emit timeLabelDoubleClicked();
139     }
140 private:
141     intf_thread_t *p_intf;
142     bool b_remainingTime;
143     int cachedLength;
144     QTimer *bufTimer;
145     float bufVal;
146     bool buffering;
147     bool showBuffering;
148     char psz_length[MSTRTIME_MAX_SIZE];
149     char psz_time[MSTRTIME_MAX_SIZE];
150     void toggleTimeDisplay();
151     void paintEvent( QPaintEvent* );
152 signals:
153     void timeLabelDoubleClicked();
154 private slots:
155     void setDisplayPosition( float pos, int64_t time, int length );
156     void setDisplayPosition( float pos );
157     void updateBuffering( float );
158     void updateBuffering();
159 };
160
161 class SpeedLabel : public QLabel
162 {
163     Q_OBJECT
164 public:
165     SpeedLabel( intf_thread_t *, QWidget * );
166     virtual ~SpeedLabel();
167
168 protected:
169     virtual void mousePressEvent ( QMouseEvent * event )
170     {
171         showSpeedMenu( event->pos() );
172     }
173 private slots:
174     void showSpeedMenu( QPoint );
175     void setRate( float );
176 private:
177     intf_thread_t *p_intf;
178     QMenu *speedControlMenu;
179     SpeedControlWidget *speedControl;
180 };
181
182 /******************** Speed Control Widgets ****************/
183 class SpeedControlWidget : public QFrame
184 {
185     Q_OBJECT
186 public:
187     SpeedControlWidget( intf_thread_t *, QWidget * );
188     void updateControls( float );
189 private:
190     intf_thread_t *p_intf;
191     QSlider *speedSlider;
192
193 public slots:
194     void activateOnState();
195
196 private slots:
197     void updateRate( int );
198     void resetRate();
199 };
200
201 class CoverArtLabel : public QLabel
202 {
203     Q_OBJECT
204 public:
205     CoverArtLabel( QWidget *parent, intf_thread_t * );
206     virtual ~CoverArtLabel();
207
208 private:
209     intf_thread_t *p_intf;
210
211 public slots:
212     void requestUpdate() { emit updateRequested(); }
213     void update( )
214     {
215         requestUpdate();
216     }
217     void showArtUpdate( const QString& );
218
219 private slots:
220     void askForUpdate();
221
222 signals:
223     void updateRequested();
224 };
225
226 #endif