]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/interface_widgets.hpp
Qt4 window: full-screen support
[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 <vlc_aout.h> Visualizer
40
41 #include <QWidget>
42 #include <QFrame>
43 #include <QLabel>
44 #include <QMouseEvent>
45
46 class ResizeEvent;
47 class QPalette;
48 class QPixmap;
49 class QHBoxLayout;
50 class QMenu;
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     WId request( int *, int *,
63                  unsigned int *, unsigned int *, bool );
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
80     QSize videoSize;
81     QWidget *reparentable;
82     QLayout *layout;
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     virtual ~BackgroundWidget();
96
97 private:
98     QPalette plt;
99     QLabel *label;
100     virtual void contextMenuEvent( QContextMenuEvent *event );
101     intf_thread_t *p_intf;
102     virtual void resizeEvent( QResizeEvent * event );
103
104 public slots:
105     void toggle(){ TOGGLEV( this ); }
106     void updateArt( const QString& );
107 };
108
109 #if 0
110 class VisualSelector : public QFrame
111 {
112     Q_OBJECT
113 public:
114     VisualSelector( intf_thread_t *);
115     virtual ~VisualSelector();
116 private:
117     intf_thread_t *p_intf;
118     QLabel *current;
119 private slots:
120     void prev();
121     void next();
122 };
123 #endif
124
125 class TimeLabel : public QLabel
126 {
127     Q_OBJECT
128 public:
129     TimeLabel( intf_thread_t *_p_intf );
130 protected:
131     virtual void mousePressEvent( QMouseEvent *event )
132     {
133         toggleTimeDisplay();
134         event->accept();
135     }
136     virtual void mouseDoubleClickEvent( QMouseEvent *event )
137     {
138         event->accept();
139         toggleTimeDisplay();
140         emit timeLabelDoubleClicked();
141     }
142 private:
143     intf_thread_t *p_intf;
144     bool b_remainingTime;
145     void toggleTimeDisplay();
146 signals:
147     void timeLabelDoubleClicked();
148 private slots:
149     void setDisplayPosition( float pos, int time, int length );
150     void setCaching( float );
151 };
152
153 class SpeedLabel : public QLabel
154 {
155     Q_OBJECT
156 public:
157     SpeedLabel( intf_thread_t *, const QString&, QWidget * );
158     virtual ~SpeedLabel();
159
160 protected:
161     virtual void mousePressEvent ( QMouseEvent * event )
162     {
163         showSpeedMenu( event->pos() );
164     }
165 private slots:
166     void showSpeedMenu( QPoint );
167     void setRate( int );
168 private:
169     intf_thread_t *p_intf;
170     QMenu *speedControlMenu;
171     SpeedControlWidget *speedControl;
172 };
173
174 /******************** Speed Control Widgets ****************/
175 class SpeedControlWidget : public QFrame
176 {
177     Q_OBJECT
178 public:
179     SpeedControlWidget( intf_thread_t *, QWidget * );
180     void updateControls( int );
181 private:
182     intf_thread_t *p_intf;
183     QSlider *speedSlider;
184
185 public slots:
186     void activateOnState();
187
188 private slots:
189     void updateRate( int );
190     void resetRate();
191 };
192
193 class CoverArtLabel : public QLabel
194 {
195     Q_OBJECT
196 public:
197     CoverArtLabel( QWidget *parent, intf_thread_t * );
198     virtual ~CoverArtLabel();
199
200 private:
201     intf_thread_t *p_intf;
202
203 public slots:
204     void requestUpdate() { emit updateRequested(); };
205     void update( )
206     {
207         requestUpdate();
208     }
209
210 private slots:
211     void askForUpdate();
212     void showArtUpdate( const QString& );
213
214 signals:
215     void updateRequested();
216 };
217
218 #endif