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