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

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

33
#include <vlc/vlc.h>
Clément Stenac's avatar
Clément Stenac committed
34
#include <vlc_interface.h>
35
#include <vlc_aout.h>
36

37
#include "qt4.hpp"
38
#include "main_interface.hpp"
39

40
#include <QWidget>
41
#include <QFrame>
42
#define VOLUME_MAX 200
43

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
44 45 46
class ResizeEvent;
class QPalette;
class QPixmap;
47
class QLabel;
48 49
class QHBoxLayout;

50
/******************** Video Widget ****************/
51
class VideoWidget : public QFrame
52
{
53
    Q_OBJECT
54 55
friend class MainInterface;

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

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

65
    virtual QSize sizeHint() const;
66 67
private:
    intf_thread_t *p_intf;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
68 69
    vout_thread_t *p_vout;

70
    vlc_mutex_t lock;
71
    QSize videoSize;
72

73
signals:
74
    void askVideoWidgetToShow();
75
    //void askResize();
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
76

77 78
public slots:
    void SetSizing( unsigned int, unsigned int );
79 80
};

81
/******************** Background Widget ****************/
82
class BackgroundWidget : public QWidget
83 84 85 86 87
{
    Q_OBJECT
public:
    BackgroundWidget( intf_thread_t * );
    virtual ~BackgroundWidget();
88

89 90 91
private:
    QPalette plt;
    QLabel *label;
92
    virtual void contextMenuEvent( QContextMenuEvent *event );
93
    intf_thread_t *p_intf;
94

95
public slots:
96
    void toggle(){ TOGGLEV( this ); }
97
    void update( QString );
98 99
};

Clément Stenac's avatar
Clément Stenac committed
100 101 102 103 104 105 106 107
class VisualSelector : public QFrame
{
    Q_OBJECT
public:
    VisualSelector( intf_thread_t *);
    virtual ~VisualSelector();
private:
    intf_thread_t *p_intf;
Clément Stenac's avatar
Clément Stenac committed
108 109 110 111
    QLabel *current;
private slots:
    void prev();
    void next();
Clément Stenac's avatar
Clément Stenac committed
112
};
113

114
/* Advanced Button Bar */
Clément Stenac's avatar
Clément Stenac committed
115
class QPushButton;
116
class AdvControlsWidget : public QFrame
Clément Stenac's avatar
Clément Stenac committed
117 118 119
{
    Q_OBJECT
public:
120 121
    AdvControlsWidget( intf_thread_t *);
    virtual ~AdvControlsWidget();
122

Clément Stenac's avatar
Clément Stenac committed
123 124
    void enableInput( bool );
    void enableVideo( bool );
125

Clément Stenac's avatar
Clément Stenac committed
126 127
private:
    intf_thread_t *p_intf;
128
    QPushButton *recordButton, *ABButton;
129
    QPushButton *snapshotButton, *frameButton;
130

131 132
    mtime_t timeA, timeB;

Clément Stenac's avatar
Clément Stenac committed
133 134
private slots:
    void snapshot();
135
#if 0
136
    void frame();
137
#endif
138
    void fromAtoB();
139
    void record();
140
    void AtoBLoop( float, int, int );
Clément Stenac's avatar
Clément Stenac committed
141 142
};

143
/* Button Bar */
144 145 146 147
class InputSlider;
class QSlider;
class QGridLayout;
class VolumeClickHandler;
148
class SoundSlider;
149
class QAbstractSlider;
150
class QToolButton;
151

152 153 154 155
class ControlsWidget : public QFrame
{
    Q_OBJECT
public:
156
    /* p_intf, advanced control visible or not, blingbling or not */
157
    ControlsWidget( intf_thread_t *, MainInterface*, bool, bool );
158 159 160 161
    virtual ~ControlsWidget();

    QPushButton *playlistButton;
    void setStatus( int );
162
    void enableInput( bool );
163
    void enableVideo( bool );
164 165 166 167 168 169
public slots:
    void setNavigation( int );
protected:
    friend class MainInterface;
    friend class VolumeClickHandler;
private:
170
    intf_thread_t       *p_intf;
171 172
    QWidget             *discFrame;
    QWidget             *telexFrame;
173
    QGridLayout         *controlLayout;
174
    InputSlider         *slider;
175 176
    QPushButton         *prevSectionButton, *nextSectionButton, *menuButton;
    QPushButton         *playButton, *fullscreenButton;
177
    QToolButton         *slowerButton, *fasterButton;
178
    AdvControlsWidget   *advControls;
179
    QLabel              *volMuteLabel;
180
    QAbstractSlider     *volumeSlider;
181 182

    bool                 b_advancedVisible;
183 184 185 186 187 188
private slots:
    void play();
    void stop();
    void prev();
    void next();
    void updateVolume( int );
189
    void updateVolume( void );
190
    void updateInput();
191 192
    void fullscreen();
    void extSettings();
193 194
    void faster();
    void slower();
195 196
    void toggleAdvanced();
signals:
197
    void advancedControlsToggled( bool );
198 199 200 201 202 203 204 205 206 207
};

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 )
    {
208
        if (e->type() == QEvent::MouseButtonPress  )
209 210
        {
            aout_VolumeMute( p_intf, NULL );
211 212
            audio_volume_t i_volume;
            aout_VolumeGet( p_intf, &i_volume );
213
            m->updateVolume( i_volume *  VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
214 215 216 217 218 219 220 221 222
            return true;
        }
        return false;
    }
private:
    ControlsWidget *m;
    intf_thread_t *p_intf;
};

223 224 225 226 227 228 229
#include <QLabel>
#include <QMouseEvent>
class TimeLabel : public QLabel
{
    Q_OBJECT
    void mousePressEvent( QMouseEvent *event )
    {
230
        emit timeLabelClicked();
231
    }
232 233 234 235
    void mouseDoubleClickEvent( QMouseEvent *event )
    {
        emit timeLabelDoubleClicked();
    }
236 237
signals:
    void timeLabelClicked();
238
    void timeLabelDoubleClicked();
239
};
Clément Stenac's avatar
Clément Stenac committed
240

241

242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
/******************** 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;
private slots:
    void updateRate( int );
    void resetRate();
};

258
#endif