]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/interface_widgets.hpp
Qt: Move code around and simplify the inclusion of headers.
[vlc] / modules / gui / qt4 / components / interface_widgets.hpp
1 /*****************************************************************************
2  * interface_widgets.hpp : Custom widgets for the main interface
3  ****************************************************************************
4  * Copyright (C) 2006 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 <vlc_common.h>
34 #include <vlc_interface.h>
35 //#include <vlc_aout.h> Visualizer
36
37 #include "qt4.hpp"
38 #include "main_interface.hpp"
39 #include "input_manager.hpp"
40 #include "components/controller.hpp"
41 #include "components/controller_widget.hpp"
42
43 #include <QWidget>
44 #include <QFrame>
45 #include <QLabel>
46 #include <QMouseEvent>
47
48 class ResizeEvent;
49 class QPalette;
50 class QPixmap;
51 class QHBoxLayout;
52
53 /******************** Video Widget ****************/
54 class VideoWidget : public QFrame
55 {
56     Q_OBJECT
57 friend class MainInterface;
58
59 public:
60     VideoWidget( intf_thread_t * );
61     virtual ~VideoWidget();
62
63     void *request( vout_thread_t *, int *, int *,
64                    unsigned int *, unsigned int * );
65     void  release( void );
66     int   control( void *, int, va_list );
67
68     virtual QSize sizeHint() const;
69
70 protected:
71     virtual QPaintEngine *paintEngine() const
72     {
73         return NULL;
74     }
75
76     virtual void paintEvent(QPaintEvent *);
77
78 private:
79     intf_thread_t *p_intf;
80     vout_thread_t *p_vout;
81
82     QSize videoSize;
83
84 signals:
85     void askVideoWidgetToShow( unsigned int, unsigned int );
86
87 public slots:
88     void SetSizing( unsigned int, unsigned int );
89
90 };
91
92 /******************** Background Widget ****************/
93 class BackgroundWidget : public QWidget
94 {
95     Q_OBJECT
96 public:
97     BackgroundWidget( intf_thread_t * );
98     virtual ~BackgroundWidget();
99
100 private:
101     QPalette plt;
102     QLabel *label;
103     virtual void contextMenuEvent( QContextMenuEvent *event );
104     intf_thread_t *p_intf;
105     virtual void resizeEvent( QResizeEvent * event );
106
107 public slots:
108     void toggle(){ TOGGLEV( this ); }
109     void updateArt( input_item_t* );
110 };
111
112 #if 0
113 class VisualSelector : public QFrame
114 {
115     Q_OBJECT
116 public:
117     VisualSelector( intf_thread_t *);
118     virtual ~VisualSelector();
119 private:
120     intf_thread_t *p_intf;
121     QLabel *current;
122 private slots:
123     void prev();
124     void next();
125 };
126 #endif
127
128 class TimeLabel : public QLabel
129 {
130     Q_OBJECT
131 public:
132     TimeLabel( intf_thread_t *_p_intf );
133 protected:
134     virtual void mousePressEvent( QMouseEvent *event )
135     {
136         toggleTimeDisplay();
137     }
138     virtual void mouseDoubleClickEvent( QMouseEvent *event )
139     {
140         toggleTimeDisplay();
141         emit timeLabelDoubleClicked();
142     }
143 private:
144     intf_thread_t *p_intf;
145     bool b_remainingTime;
146     void toggleTimeDisplay();
147 signals:
148     void timeLabelDoubleClicked();
149 private slots:
150     void setDisplayPosition( float pos, int time, int length );
151     void setStatus( int i_status );
152 };
153
154 class SpeedLabel : public QLabel
155 {
156     Q_OBJECT
157 public:
158     SpeedLabel( intf_thread_t *_p_intf, const QString text ): QLabel( text)
159     { p_intf = _p_intf; }
160
161 protected:
162     virtual void mouseDoubleClickEvent ( QMouseEvent * event )
163     {
164         THEMIM->getIM()->setRate( INPUT_RATE_DEFAULT );
165     }
166 private:
167     intf_thread_t *p_intf;
168 };
169
170 /******************** Speed Control Widgets ****************/
171 class SpeedControlWidget : public QFrame
172 {
173     Q_OBJECT
174 public:
175     SpeedControlWidget( intf_thread_t *);
176     virtual ~SpeedControlWidget();
177     void updateControls( int );
178 private:
179     intf_thread_t *p_intf;
180     QSlider *speedSlider;
181 public slots:
182     void setEnable( bool );
183 private slots:
184     void updateRate( int );
185     void resetRate();
186 };
187
188 class CoverArtLabel : public QLabel
189 {
190     Q_OBJECT
191 public:
192     CoverArtLabel( QWidget *parent,
193                    vlc_object_t *p_this,
194                    input_item_t *p_input = NULL );
195     virtual ~CoverArtLabel()
196             { if( p_input ) vlc_gc_decref( p_input ); };
197 private:
198     input_item_t *p_input;
199     vlc_object_t *p_this;
200     QString prevArt;
201
202 public slots:
203     void requestUpdate() { emit updateRequested(); };
204     void update( input_item_t* p_item )
205             { if( p_input ) vlc_gc_decref( p_input );
206               if( ( p_input = p_item ) ) vlc_gc_incref( p_input );
207               requestUpdate(); }
208
209 private slots:
210     void doUpdate();
211     void downloadCover();
212
213 signals:
214     void updateRequested();
215 };
216
217 #endif