interface_widgets.hpp 6.57 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
69
70
signals:
    void askResize();
private slots:
    void SetMinSize();
71
72
};

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

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

zorglub's avatar
zorglub committed
108
class QPushButton;
109
class AdvControlsWidget : public QFrame
zorglub's avatar
zorglub committed
110
111
112
{
    Q_OBJECT
public:
113
114
    AdvControlsWidget( intf_thread_t *);
    virtual ~AdvControlsWidget();
zorglub's avatar
zorglub committed
115
116
117
118
    void enableInput( bool );
    void enableVideo( bool );
private:
    intf_thread_t *p_intf;
119
120
    QPushButton *normalButton, *recordButton, *ABButton;
    QPushButton *snapshotButton, *frameButton;
zorglub's avatar
zorglub committed
121
122
123
private slots:
    void normal();
    void snapshot();
124
    void frame();
125
    void fromAtoB();
126
    void record();
zorglub's avatar
zorglub committed
127
128
};

129
130


131
132
133
134
135
136
137
138
class InputSlider;
class QSlider;
class QGridLayout;
class VolumeClickHandler;
class ControlsWidget : public QFrame
{
    Q_OBJECT
public:
139
    ControlsWidget( intf_thread_t *, bool );
140
141
142
143
144
    virtual ~ControlsWidget();

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

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

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 )
    {
188
        if (e->type() == QEvent::MouseButtonPress  )
189
190
        {
            aout_VolumeMute( p_intf, NULL );
191
192
            audio_volume_t i_volume;
            aout_VolumeGet( p_intf, &i_volume );
193
            m->updateVolume( i_volume *  VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
194
195
196
197
198
199
200
201
202
            return true;
        }
        return false;
    }
private:
    ControlsWidget *m;
    intf_thread_t *p_intf;
};

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

zorglub's avatar
zorglub committed
221
/******************** Playlist Widgets ****************/
222
#include <QModelIndex>
223
#include <QSplitter>
224
225
226
class QSignalMapper;
class PLSelector;
class PLPanel;
zorglub's avatar
zorglub committed
227
class QPushButton;
228

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

252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270

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


271
#endif