interface_widgets.hpp 5.42 KB
Newer Older
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
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

26
27
#ifndef _INTFWIDGETS_H_
#define _INTFWIDGETS_H_
28

Christophe Mutricy's avatar
Christophe Mutricy committed
29
30
31
32
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

33
34
#include "main_interface.hpp" /* Interface integration */
#include "input_manager.hpp"  /* Speed control */
35

36
#include "components/controller.hpp"
37
#include "components/controller_widget.hpp"
zorglub's avatar
zorglub committed
38

39
#include <QWidget>
zorglub's avatar
zorglub committed
40
#include <QFrame>
41
42
#include <QLabel>
#include <QMouseEvent>
43

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
44
45
class ResizeEvent;
class QPixmap;
46
class QHBoxLayout;
47
class QMenu;
48
class QSlider;
49
class ReparentableWidget;
50

51
/******************** Video Widget ****************/
zorglub's avatar
zorglub committed
52
class VideoWidget : public QFrame
53
{
zorglub's avatar
zorglub committed
54
    Q_OBJECT
55
friend class ReparentableWidget;
56

57
public:
58
    VideoWidget( intf_thread_t * );
59
60
    virtual ~VideoWidget();

61
    WId request( int *, int *, unsigned int *, unsigned int *, bool );
62
    void  release( void );
63
    int   control( void *, int, va_list );
64

65
66
67
68
69
70
protected:
    virtual QPaintEngine *paintEngine() const
    {
        return NULL;
    }

71
72
private:
    intf_thread_t *p_intf;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
73

74
75
    QWidget *reparentable;
    QLayout *layout;
76
    virtual bool eventFilter ( QObject * watched, QEvent * event );
77
78
signals:
    void keyPressed( QKeyEvent * );
79
    void sizeChanged( int, int );
80

81
82
public slots:
    void SetSizing( unsigned int, unsigned int );
83
    void SetFullScreen( bool );
84
85
};

86
/******************** Background Widget ****************/
87
class BackgroundWidget : public QWidget
88
89
90
91
{
    Q_OBJECT
public:
    BackgroundWidget( intf_thread_t * );
François Cartegnie's avatar
François Cartegnie committed
92
    void setExpandstoHeight( bool b_expand ) { b_expandPixmap = b_expand; }
93
private:
François Cartegnie's avatar
François Cartegnie committed
94
95
    QString pixmapUrl;
    bool b_expandPixmap;
96
    virtual void contextMenuEvent( QContextMenuEvent *event );
97
    intf_thread_t *p_intf;
François Cartegnie's avatar
François Cartegnie committed
98
99
100
protected:
    void paintEvent( QPaintEvent *e );
    static const int MARGIN = 5;
101
public slots:
102
    void toggle(){ TOGGLEV( this ); }
103
    void updateArt( const QString& );
104
105
};

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
106
#if 0
zorglub's avatar
zorglub committed
107
108
109
110
111
112
113
114
class VisualSelector : public QFrame
{
    Q_OBJECT
public:
    VisualSelector( intf_thread_t *);
    virtual ~VisualSelector();
private:
    intf_thread_t *p_intf;
zorglub's avatar
zorglub committed
115
116
117
118
    QLabel *current;
private slots:
    void prev();
    void next();
zorglub's avatar
zorglub committed
119
};
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
120
#endif
121

122
123
124
class TimeLabel : public QLabel
{
    Q_OBJECT
125
126
127
128
public:
    TimeLabel( intf_thread_t *_p_intf );
protected:
    virtual void mousePressEvent( QMouseEvent *event )
129
    {
130
        toggleTimeDisplay();
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
131
        event->accept();
132
    }
133
    virtual void mouseDoubleClickEvent( QMouseEvent *event )
134
    {
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
135
        event->accept();
136
        toggleTimeDisplay();
137
138
        emit timeLabelDoubleClicked();
    }
139
140
141
private:
    intf_thread_t *p_intf;
    bool b_remainingTime;
142
    int cachedLength;
143
144
145
146
    QTimer *bufTimer;
    float bufVal;
    bool buffering;
    bool showBuffering;
147
148
    char psz_length[MSTRTIME_MAX_SIZE];
    char psz_time[MSTRTIME_MAX_SIZE];
149
    void toggleTimeDisplay();
150
    void paintEvent( QPaintEvent* );
151
signals:
152
    void timeLabelDoubleClicked();
153
private slots:
154
    void setDisplayPosition( float pos, int64_t time, int length );
155
    void setDisplayPosition( float pos );
156
157
    void updateBuffering( float );
    void updateBuffering();
158
};
zorglub's avatar
zorglub committed
159

160
161
162
163
class SpeedLabel : public QLabel
{
    Q_OBJECT
public:
164
    SpeedLabel( intf_thread_t *, QWidget * );
165
    virtual ~SpeedLabel();
166
167

protected:
168
    virtual void mousePressEvent ( QMouseEvent * event )
169
    {
170
        showSpeedMenu( event->pos() );
171
    }
172
173
private slots:
    void showSpeedMenu( QPoint );
174
    void setRate( float );
175
176
private:
    intf_thread_t *p_intf;
177
    QMenu *speedControlMenu;
178
    QString tooltipStringPattern;
179
    SpeedControlWidget *speedControl;
180
};
181

182
183
184
185
186
/******************** Speed Control Widgets ****************/
class SpeedControlWidget : public QFrame
{
    Q_OBJECT
public:
187
    SpeedControlWidget( intf_thread_t *, QWidget * );
188
    void updateControls( float );
189
190
191
private:
    intf_thread_t *p_intf;
    QSlider *speedSlider;
192
    int lastValue;
193

194
public slots:
195
    void activateOnState();
196

197
198
199
200
201
private slots:
    void updateRate( int );
    void resetRate();
};

202
203
204
205
class CoverArtLabel : public QLabel
{
    Q_OBJECT
public:
206
    CoverArtLabel( QWidget *parent, intf_thread_t * );
207
    virtual ~CoverArtLabel();
208

209
private:
210
    intf_thread_t *p_intf;
211
212

public slots:
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
213
    void requestUpdate() { emit updateRequested(); }
214
    void update( )
215
216
217
    {
        requestUpdate();
    }
218
    void showArtUpdate( const QString& );
219
220

private slots:
221
    void askForUpdate();
222
223
224
225
226

signals:
    void updateRequested();
};

227
#endif