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