interface_widgets.hpp 6.68 KB
Newer Older
1
/*****************************************************************************
2
 * interface_widgets.hpp : Custom widgets for the main interface
3
 ****************************************************************************
4
5
 * Copyright (C) 2006 the VideoLAN team
 * $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
29

#include <vlc/vlc.h>
zorglub's avatar
zorglub committed
30
#include <vlc_interface.h>
zorglub's avatar
zorglub committed
31

32
#include <vlc_aout.h>
zorglub's avatar
zorglub committed
33
34
#include "qt4.hpp"

35
#include <QWidget>
zorglub's avatar
zorglub committed
36
#include <QFrame>
37
#define VOLUME_MAX 200
38

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
39
40
41
class ResizeEvent;
class QPalette;
class QPixmap;
zorglub's avatar
zorglub committed
42
class QLabel;
43
44
class QHBoxLayout;

45
/******************** Video Widget ****************/
zorglub's avatar
zorglub committed
46
class VideoWidget : public QFrame
47
{
zorglub's avatar
zorglub committed
48
    Q_OBJECT
49
public:
50
    VideoWidget( intf_thread_t * );
51
52
    virtual ~VideoWidget();

53
    void *request( vout_thread_t *, int *, int *,
54
                   unsigned int *, unsigned int * );
55
56
    void release( void * );
    int control( void *, int, va_list );
57

58
    int i_video_height, i_video_width;
zorglub's avatar
zorglub committed
59
    vout_thread_t *p_vout;
60
61
62

    QSize widgetSize;
    virtual QSize sizeHint() const;
63
64
65
66
private:
    QWidget *frame;
    intf_thread_t *p_intf;
    vlc_mutex_t lock;
67
68
signals:
    void askResize();
69
    void askVideoToShow();
70
71
private slots:
    void SetMinSize();
72
73
};

74
/******************** Background Widget ****************/
75
76
77
78
79
80
class BackgroundWidget : public QFrame
{
    Q_OBJECT
public:
    BackgroundWidget( intf_thread_t * );
    virtual ~BackgroundWidget();
81
82
    QSize widgetSize;
    virtual QSize sizeHint() const;
83
84
85
86
87
private:
    QPalette plt;
    QLabel *label;
    QHBoxLayout *backgroundLayout;
    virtual void resizeEvent( QResizeEvent *e );
88
    virtual void contextMenuEvent( QContextMenuEvent *event );
89
90
91
    int DrawBackground();
    int CleanBackground();
    intf_thread_t *p_intf;
92
public slots:
93
    void setArt( QString );
94
    void toggle(){ TOGGLEV( this ); }
95
96
};

zorglub's avatar
zorglub committed
97
98
99
100
101
102
103
104
class VisualSelector : public QFrame
{
    Q_OBJECT
public:
    VisualSelector( intf_thread_t *);
    virtual ~VisualSelector();
private:
    intf_thread_t *p_intf;
zorglub's avatar
zorglub committed
105
106
107
108
    QLabel *current;
private slots:
    void prev();
    void next();
zorglub's avatar
zorglub committed
109
};
110

111
/* Advanced Button Bar */
zorglub's avatar
zorglub committed
112
class QPushButton;
113
class AdvControlsWidget : public QFrame
zorglub's avatar
zorglub committed
114
115
116
{
    Q_OBJECT
public:
117
118
    AdvControlsWidget( intf_thread_t *);
    virtual ~AdvControlsWidget();
119

zorglub's avatar
zorglub committed
120
121
    void enableInput( bool );
    void enableVideo( bool );
122

zorglub's avatar
zorglub committed
123
124
private:
    intf_thread_t *p_intf;
125
    QPushButton *recordButton, *ABButton;
126
    QPushButton *snapshotButton, *frameButton;
127

zorglub's avatar
zorglub committed
128
129
private slots:
    void snapshot();
130
    void frame();
131
    void fromAtoB();
132
    void record();
zorglub's avatar
zorglub committed
133
134
};

135
/* Button Bar */
136
137
138
139
140
141
142
143
class InputSlider;
class QSlider;
class QGridLayout;
class VolumeClickHandler;
class ControlsWidget : public QFrame
{
    Q_OBJECT
public:
144
    ControlsWidget( intf_thread_t *, bool );
145
146
147
148
149
    virtual ~ControlsWidget();

    QPushButton *playlistButton;
    QSlider *volumeSlider;
    void setStatus( int );
150
    void enableInput( bool );
151
    void enableVideo( bool );
152
153
154
155
156
157
158
public slots:
    void setNavigation( int );
    void updateOnTimer();
protected:
    friend class MainInterface;
    friend class VolumeClickHandler;
private:
159
160
161
    intf_thread_t       *p_intf;
    QFrame              *discFrame;
    QGridLayout         *controlLayout;
162
    InputSlider         *slider;
163
164
165
166
    QPushButton         *prevSectionButton, *nextSectionButton, *menuButton;
    QPushButton         *playButton, *fullscreenButton;
    QPushButton         *slowerButton, *fasterButton;
    AdvControlsWidget   *advControls;
167
    QLabel              *volMuteLabel;
168
169

    bool                 b_advancedVisible;
170
171
172
173
174
175
176
177
private slots:
    void play();
    void stop();
    void prev();
    void next();
    void updateVolume( int );
    void fullscreen();
    void extSettings();
178
179
    void faster();
    void slower();
180
181
    void toggleAdvanced();
signals:
182
    void advancedControlsToggled( bool );
183
184
185
186
187
188
189
190
191
192
};

class VolumeClickHandler : public QObject
{
public:
    VolumeClickHandler( intf_thread_t *_p_intf, ControlsWidget *_m ) :QObject(_m)
    {m = _m; p_intf = _p_intf; }
    virtual ~VolumeClickHandler() {};
    bool eventFilter( QObject *obj, QEvent *e )
    {
193
        if (e->type() == QEvent::MouseButtonPress  )
194
195
        {
            aout_VolumeMute( p_intf, NULL );
196
197
            audio_volume_t i_volume;
            aout_VolumeGet( p_intf, &i_volume );
198
            m->updateVolume( i_volume *  VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
199
200
201
202
203
204
205
206
207
            return true;
        }
        return false;
    }
private:
    ControlsWidget *m;
    intf_thread_t *p_intf;
};

208
209
210
211
212
213
214
215
216
#include <QLabel>
#include <QMouseEvent>
class TimeLabel : public QLabel
{
    Q_OBJECT
    void mousePressEvent( QMouseEvent *event )
    {
        if( event->button() == Qt::LeftButton ) emit timeLabelClicked();
    }
217
218
219
220
    void mouseDoubleClickEvent( QMouseEvent *event )
    {
        emit timeLabelDoubleClicked();
    }
221
222
signals:
    void timeLabelClicked();
223
    void timeLabelDoubleClicked();
224
};
zorglub's avatar
zorglub committed
225

zorglub's avatar
zorglub committed
226
/******************** Playlist Widgets ****************/
227
#include <QModelIndex>
228
#include <QSplitter>
229
230
231
class QSignalMapper;
class PLSelector;
class PLPanel;
zorglub's avatar
zorglub committed
232
class QPushButton;
233

234
class PlaylistWidget : public QSplitter
235
236
237
{
    Q_OBJECT;
public:
238
    PlaylistWidget( intf_thread_t *_p_i ) ;
239
240
241
242
243
    virtual ~PlaylistWidget();
    virtual QSize sizeHint() const;
private:
    PLSelector *selector;
    PLPanel *rightPanel;
zorglub's avatar
zorglub committed
244
    QPushButton *addButton;
245
    QLabel *art;
zorglub's avatar
zorglub committed
246
    QString prevArt;
247
248
protected:
     intf_thread_t *p_intf;
249
250
private slots:
    void setArt( QString );
zorglub's avatar
zorglub committed
251
252
signals:
    void rootChanged( int );
253
    void artSet( QString );
254
};
255

256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274

/******************** Speed Control Widgets ****************/
class SpeedControlWidget : public QFrame
{
    Q_OBJECT
public:
    SpeedControlWidget( intf_thread_t *);
    virtual ~SpeedControlWidget();
    void updateControls( int );
private:
    intf_thread_t *p_intf;
    QSlider *speedSlider;
    QPushButton *normalSpeedButton;
private slots:
    void updateRate( int );
    void resetRate();
};


275
#endif