interface_widgets.hpp 7.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 VLC_QT_INTERFACE_WIDGETS_HPP_
#define VLC_QT_INTERFACE_WIDGETS_HPP_
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"
38 39
#include "dialogs_provider.hpp"
#include "components/info_panels.hpp"
40

41
#include <QWidget>
42
#include <QFrame>
43 44
#include <QLabel>
#include <QMouseEvent>
45
#include <QPropertyAnimation>
46
#include <QLinkedList>
47

48
class QMenu;
49
class QSlider;
50
class QWidgetAction;
51
class SpeedControlWidget;
52
struct vout_window_t;
53

54
/******************** Video Widget ****************/
55
class VideoWidget : public QFrame
56
{
57
    Q_OBJECT
58
public:
59
    VideoWidget( intf_thread_t * );
60 61
    virtual ~VideoWidget();

62
    WId request( struct vout_window_t *, unsigned int *, unsigned int *, bool );
63
    void  release( void );
64
    void  sync( void );
65

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

72
    virtual void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE;
73 74 75 76
    void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE;
    void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE;
    void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE;
    void mouseDoubleClickEvent(QMouseEvent *) Q_DECL_OVERRIDE;
77

78
private:
79
    int qtMouseButton2VLC( Qt::MouseButton );
80
    intf_thread_t *p_intf;
81
    vout_window_t *p_window;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
82

83
    QWidget *stable;
84
    QLayout *layout;
85
signals:
86
    void sizeChanged( int, int );
87

88
public slots:
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
89
    void setSize( unsigned int, unsigned int );
90 91
};

92
/******************** Background Widget ****************/
93
class BackgroundWidget : public QWidget
94 95 96 97
{
    Q_OBJECT
public:
    BackgroundWidget( intf_thread_t * );
François Cartegnie's avatar
François Cartegnie committed
98
    void setExpandstoHeight( bool b_expand ) { b_expandPixmap = b_expand; }
99
    void setWithArt( bool b_withart_ ) { b_withart = b_withart_; };
100
private:
101
    intf_thread_t *p_intf;
François Cartegnie's avatar
François Cartegnie committed
102 103
    QString pixmapUrl;
    bool b_expandPixmap;
104
    bool b_withart;
105
    QPropertyAnimation *fadeAnimation;
106
    void contextMenuEvent( QContextMenuEvent *event ) Q_DECL_OVERRIDE;
François Cartegnie's avatar
François Cartegnie committed
107
protected:
108 109
    void paintEvent( QPaintEvent *e ) Q_DECL_OVERRIDE;
    void showEvent( QShowEvent * e ) Q_DECL_OVERRIDE;
François Cartegnie's avatar
François Cartegnie committed
110
    static const int MARGIN = 5;
111
    QString defaultArt;
112
public slots:
113
    void toggle(){ TOGGLEV( this ); }
114
    void updateArt( const QString& );
115 116
};

117 118 119 120 121 122 123 124 125 126 127 128
class EasterEggBackgroundWidget : public BackgroundWidget
{
    Q_OBJECT

public:
    EasterEggBackgroundWidget( intf_thread_t * );
    virtual ~EasterEggBackgroundWidget();

public slots:
    void animate();

protected:
129 130 131 132
    void paintEvent( QPaintEvent *e ) Q_DECL_OVERRIDE;
    void showEvent( QShowEvent *e ) Q_DECL_OVERRIDE;
    void hideEvent( QHideEvent * ) Q_DECL_OVERRIDE;
    void resizeEvent( QResizeEvent * ) Q_DECL_OVERRIDE;
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151

private slots:
    void spawnFlakes();
    void reset();

private:
    struct flake
    {
        QPoint point;
        bool b_fat;
    };
    QTimer *timer;
    QLinkedList<flake *> *flakes;
    int i_rate;
    int i_speed;
    bool b_enabled;
    static const int MAX_FLAKES = 1000;
};

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
152
#if 0
Clément Stenac's avatar
Clément Stenac committed
153 154 155 156 157 158 159 160
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
161 162 163 164
    QLabel *current;
private slots:
    void prev();
    void next();
Clément Stenac's avatar
Clément Stenac committed
165
};
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
166
#endif
167

168 169 170 171
class ClickableQLabel : public QLabel
{
    Q_OBJECT
public:
172
    void mouseDoubleClickEvent( QMouseEvent *event ) Q_DECL_OVERRIDE
173 174 175 176 177 178 179 180 181
    {
        Q_UNUSED( event );
        emit doubleClicked();
    }
signals:
    void doubleClicked();
};

class TimeLabel : public ClickableQLabel
182 183
{
    Q_OBJECT
184
public:
185 186 187 188 189 190 191 192
    enum Display
    {
        Elapsed,
        Remaining,
        Both
    };

    TimeLabel( intf_thread_t *_p_intf, TimeLabel::Display _displayType = TimeLabel::Both );
193
protected:
194
    void mousePressEvent( QMouseEvent *event ) Q_DECL_OVERRIDE
195
    {
196
        if( displayType == TimeLabel::Elapsed ) return;
197
        toggleTimeDisplay();
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
198
        event->accept();
199
    }
200
    void mouseDoubleClickEvent( QMouseEvent *event ) Q_DECL_OVERRIDE
201
    {
202
        if( displayType != TimeLabel::Both ) return;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
203
        event->accept();
204
        toggleTimeDisplay();
205
        ClickableQLabel::mouseDoubleClickEvent( event );
206
    }
207 208 209
private:
    intf_thread_t *p_intf;
    bool b_remainingTime;
210
    int cachedLength;
211
    TimeLabel::Display displayType;
212

213 214
    char psz_length[MSTRTIME_MAX_SIZE];
    char psz_time[MSTRTIME_MAX_SIZE];
215
    void toggleTimeDisplay();
216
private slots:
217
    void setRemainingTime( bool );
218
    void setDisplayPosition( float pos, int64_t time, int length );
219
    void setDisplayPosition( float pos );
220 221
signals:
    void broadcastRemainingTime( bool );
222
};
Clément Stenac's avatar
Clément Stenac committed
223

224 225 226 227
class SpeedLabel : public QLabel
{
    Q_OBJECT
public:
228
    SpeedLabel( intf_thread_t *, QWidget * );
229
    virtual ~SpeedLabel();
230 231

protected:
232
    void mousePressEvent ( QMouseEvent * event ) Q_DECL_OVERRIDE
233
    {
234
        showSpeedMenu( event->pos() );
235
    }
236 237
private slots:
    void showSpeedMenu( QPoint );
238
    void setRate( float );
239 240
private:
    intf_thread_t *p_intf;
241
    QMenu *speedControlMenu;
242
    QString tooltipStringPattern;
243
    SpeedControlWidget *speedControl;
244
    QWidgetAction *widgetAction;
245
};
246

247 248 249 250 251
/******************** Speed Control Widgets ****************/
class SpeedControlWidget : public QFrame
{
    Q_OBJECT
public:
252
    SpeedControlWidget( intf_thread_t *, QWidget * );
253
    void updateControls( float );
254
private:
255 256 257
    intf_thread_t* p_intf;
    QSlider* speedSlider;
    QDoubleSpinBox* spinBox;
258
    int lastValue;
259

260
public slots:
261
    void activateOnState();
262

263 264
private slots:
    void updateRate( int );
265
    void updateSpinBoxRate( double );
266 267 268
    void resetRate();
};

269 270 271 272
class CoverArtLabel : public QLabel
{
    Q_OBJECT
public:
273
    CoverArtLabel( QWidget *parent, intf_thread_t * );
274
    void setItem( input_item_t * );
275
    virtual ~CoverArtLabel();
276

277
protected:
278
    void mouseDoubleClickEvent( QMouseEvent *event ) Q_DECL_OVERRIDE
279
    {
280
        if( ! p_item && qobject_cast<MetaPanel *>(this->window()) == NULL )
281 282 283 284 285
        {
            THEDP->mediaInfoDialog();
        }
        event->accept();
    }
286
private:
287
    intf_thread_t *p_intf;
288
    input_item_t *p_item;
289 290

public slots:
291
    void showArtUpdate( const QString& );
292
    void showArtUpdate( input_item_t * );
293
    void askForUpdate();
Angelo Haller's avatar
Angelo Haller committed
294
    void setArtFromFile();
295
    void clear();
296 297
};

298
#endif