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