]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/interface_widgets.hpp
Qt: separate status bar label for "Buffering" + show time while seeking (close #2760)
[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     virtual ~BackgroundWidget();
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     char psz_length[MSTRTIME_MAX_SIZE];
145     char psz_time[MSTRTIME_MAX_SIZE];
146     void toggleTimeDisplay();
147 signals:
148     void timeLabelDoubleClicked();
149 private slots:
150     void setDisplayPosition( float pos, int64_t time, int length );
151     void setDisplayPosition( float pos );
152 };
153
154 class SpeedLabel : public QLabel
155 {
156     Q_OBJECT
157 public:
158     SpeedLabel( intf_thread_t *, const QString&, QWidget * );
159     virtual ~SpeedLabel();
160
161 protected:
162     virtual void mousePressEvent ( QMouseEvent * event )
163     {
164         showSpeedMenu( event->pos() );
165     }
166 private slots:
167     void showSpeedMenu( QPoint );
168     void setRate( int );
169 private:
170     intf_thread_t *p_intf;
171     QMenu *speedControlMenu;
172     SpeedControlWidget *speedControl;
173 };
174
175 class CacheLabel : public QLabel
176 {
177     Q_OBJECT
178 public:
179     CacheLabel( intf_thread_t *, QWidget * );
180 private slots:
181     void showCaching( float );
182     void hideCaching();
183 private:
184     void paintEvent( QPaintEvent* );
185     intf_thread_t *p_intf;
186     float cached;
187 };
188
189 /******************** Speed Control Widgets ****************/
190 class SpeedControlWidget : public QFrame
191 {
192     Q_OBJECT
193 public:
194     SpeedControlWidget( intf_thread_t *, QWidget * );
195     void updateControls( int );
196 private:
197     intf_thread_t *p_intf;
198     QSlider *speedSlider;
199
200 public slots:
201     void activateOnState();
202
203 private slots:
204     void updateRate( int );
205     void resetRate();
206 };
207
208 class CoverArtLabel : public QLabel
209 {
210     Q_OBJECT
211 public:
212     CoverArtLabel( QWidget *parent, intf_thread_t * );
213     virtual ~CoverArtLabel();
214
215 private:
216     intf_thread_t *p_intf;
217
218 public slots:
219     void requestUpdate() { emit updateRequested(); }
220     void update( )
221     {
222         requestUpdate();
223     }
224     void showArtUpdate( const QString& );
225
226 private slots:
227     void askForUpdate();
228
229 signals:
230     void updateRequested();
231 };
232
233 #endif