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