input_manager.hpp 5.05 KB
Newer Older
zorglub's avatar
zorglub committed
1
2
3
/*****************************************************************************
 * input_manager.hpp : Manage an input and interact with its GUI elements
 ****************************************************************************
4
 * Copyright (C) 2006-2008 the VideoLAN team
5
 * $Id$
zorglub's avatar
zorglub committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 *
 * Authors: Clément Stenac <zorglub@videolan.org>
 *
 * 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.
 *****************************************************************************/

#ifndef _INPUT_MANAGER_H_
#define _INPUT_MANAGER_H_

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

31
#include <vlc_common.h>
zorglub's avatar
zorglub committed
32
#include <vlc_input.h>
zorglub's avatar
zorglub committed
33

34
35
#include "qt4.hpp"

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
36
#include <QObject>
37
38
#include <QEvent>

39
40
static int const PositionUpdate_Type   = QEvent::User + IMEventType + 1;
static int const ItemChanged_Type      = QEvent::User + IMEventType + 2;
41
42
static int const ItemStateChanged_Type = QEvent::User + IMEventType + 3;
static int const ItemTitleChanged_Type = QEvent::User + IMEventType + 4;
43
44
static int const ItemRateChanged_Type  = QEvent::User + IMEventType + 5;
static int const VolumeChanged_Type    = QEvent::User + IMEventType + 6;
45
46
47
48
49
static int const ItemSpuChanged_Type   = QEvent::User + IMEventType + 7;

static int const FullscreenControlShow_Type = QEvent::User + IMEventType + 10;
static int const FullscreenControlHide_Type = QEvent::User + IMEventType + 11;
static int const FullscreenControlPlanHide_Type = QEvent::User + IMEventType + 12;
50
51
52
53
54
55
56
57
58
59

class IMEvent : public QEvent
{
public:
    IMEvent( int type, int id ) : QEvent( (QEvent::Type)(type) )
    { i_id = id ; } ;
    virtual ~IMEvent() {};

    int i_id;
};
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
60

zorglub's avatar
zorglub committed
61
62
63
64
class InputManager : public QObject
{
    Q_OBJECT;
public:
65
    InputManager( QObject *, intf_thread_t * );
zorglub's avatar
zorglub committed
66
67
    virtual ~InputManager();

68
    void delInput();
zorglub's avatar
zorglub committed
69
    bool hasInput() { return p_input && !p_input->b_dead && !p_input->b_die; }
70
71
    bool hasAudio();
    bool hasVideo();
72

zorglub's avatar
zorglub committed
73
private:
74
75
76
77
78
79
80
    intf_thread_t  *p_intf;
    input_thread_t *p_input;
    int             i_input_id;
    int             i_old_playing_status;
    QString         old_name;
    QString         artUrl;
    int             i_rate;
81
    bool            b_transparentTelextext;
82

83
    void customEvent( QEvent * );
84
85
86
87
88
    void addCallbacks();
    void delCallbacks();
    void UpdateRate();
    void UpdateMeta();
    void UpdateStatus();
89
    void UpdateNavigation();
90
    void UpdatePosition();
91
    void UpdateSPU();
92
    void UpdateArt();
93

zorglub's avatar
zorglub committed
94
public slots:
zorglub's avatar
zorglub committed
95
    void setInput( input_thread_t * ); ///< Our controlled input changed
zorglub's avatar
zorglub committed
96
    void sliderUpdate( float ); ///< User dragged the slider. We get new pos
97
    void togglePlayPause();
zorglub's avatar
zorglub committed
98
99
100
    void slower();
    void faster();
    void normalRate();
101
    void setRate( int );
102
103
104
    void sectionNext();
    void sectionPrev();
    void sectionMenu();
105
106
    void telexGotoPage( int ); ///< Goto teletext page
    void telexToggle( bool );  ///< Enable disable teletext buttons
lukas.durfina's avatar
lukas.durfina committed
107
    void telexToggleButtons(); ///< Toggle buttons after click
108
    void telexSetTransparency(); ///< Set transparency on teletext background
109

zorglub's avatar
zorglub committed
110
111
112
signals:
    /// Send new position, new time and new length
    void positionUpdated( float , int, int );
113
    void rateChanged( int );
114
    void nameChanged( QString );
115
    /// Used to signal whether we should show navigation buttons
116
    void navigationChanged( int );
117
    /// Play/pause status
118
    void statusChanged( int );
119
    void artChanged( QString );
lukas.durfina's avatar
lukas.durfina committed
120
121
    /// Controll of fullscreen controller
    void inputUnset();
122
    /// Teletext
123
    void teletextEnabled( bool );
lukas.durfina's avatar
lukas.durfina committed
124
125
126
    void toggleTelexButtons();
    void toggleTelexTransparency();
    void setNewTelexPage( int );
zorglub's avatar
zorglub committed
127
128
};

129
130
131
132
133
134
135
136
137
138
class MainInputManager : public QObject
{
    Q_OBJECT;
public:
    static MainInputManager *getInstance( intf_thread_t *_p_intf )
    {
        if( !instance )
            instance = new MainInputManager( _p_intf );
        return instance;
    }
zorglub's avatar
zorglub committed
139
140
141
142
143
    static void killInstance()
    {
        if( instance ) delete instance;
    }
    virtual ~MainInputManager();
144

145
146
147
148
    input_thread_t *getInput() { return p_input; };
    InputManager *getIM() { return im; };

private:
149
    MainInputManager( intf_thread_t * );
150
    void customEvent( QEvent * );
151
152
153

    InputManager            *im;
    input_thread_t          *p_input;
154
155

    intf_thread_t           *p_intf;
156
    static MainInputManager *instance;
157
public slots:
158
    bool teletextState();
159
    void togglePlayPause();
160
161
162
    void stop();
    void next();
    void prev();
163
signals:
164
    void inputChanged( input_thread_t * );
165
    void volumeChanged();
166
167
};

zorglub's avatar
zorglub committed
168
#endif