interface_widgets.hpp 6.7 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

128
129
    mtime_t timeA, timeB;

zorglub's avatar
zorglub committed
130
131
private slots:
    void snapshot();
132
    void frame();
133
    void fromAtoB();
134
    void record();
135
    void AtoBLoop( float, int, int );
zorglub's avatar
zorglub committed
136
137
};

138
/* Button Bar */
139
140
141
142
class InputSlider;
class QSlider;
class QGridLayout;
class VolumeClickHandler;
143
144
class SoundSlider;

145
146
147
148
class ControlsWidget : public QFrame
{
    Q_OBJECT
public:
149
    ControlsWidget( intf_thread_t *, bool );
150
151
152
    virtual ~ControlsWidget();

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

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

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 )
    {
198
        if (e->type() == QEvent::MouseButtonPress  )
199
200
        {
            aout_VolumeMute( p_intf, NULL );
201
202
            audio_volume_t i_volume;
            aout_VolumeGet( p_intf, &i_volume );
203
            m->updateVolume( i_volume *  VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
204
205
206
207
208
209
210
211
212
            return true;
        }
        return false;
    }
private:
    ControlsWidget *m;
    intf_thread_t *p_intf;
};

213
214
215
216
217
218
219
#include <QLabel>
#include <QMouseEvent>
class TimeLabel : public QLabel
{
    Q_OBJECT
    void mousePressEvent( QMouseEvent *event )
    {
220
        emit timeLabelClicked();
221
    }
222
223
224
225
    void mouseDoubleClickEvent( QMouseEvent *event )
    {
        emit timeLabelDoubleClicked();
    }
226
227
signals:
    void timeLabelClicked();
228
    void timeLabelDoubleClicked();
229
};
zorglub's avatar
zorglub committed
230

231

zorglub's avatar
zorglub committed
232
/******************** Playlist Widgets ****************/
233
#include <QModelIndex>
234
#include <QSplitter>
235
236
237
class QSignalMapper;
class PLSelector;
class PLPanel;
zorglub's avatar
zorglub committed
238
class QPushButton;
239

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

261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278

/******************** 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();
};

279
#endif