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