]> git.sesse.net Git - vlc/blob - modules/gui/qt4/input_manager.hpp
Fix toggling of transparency on teletext pages. Keep in mind that the subpicture...
[vlc] / modules / gui / qt4 / input_manager.hpp
1 /*****************************************************************************
2  * input_manager.hpp : Manage an input and interact with its GUI elements
3  ****************************************************************************
4  * Copyright (C) 2006-2008 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #ifndef _INPUT_MANAGER_H_
25 #define _INPUT_MANAGER_H_
26
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #include <vlc_common.h>
32 #include <vlc_input.h>
33
34 #include "qt4.hpp"
35
36 #include <QObject>
37 #include <QEvent>
38
39 static int const PositionUpdate_Type   = QEvent::User + IMEventType + 1;
40 static int const ItemChanged_Type      = QEvent::User + IMEventType + 2;
41 static int const ItemStateChanged_Type = QEvent::User + IMEventType + 3;
42 static int const ItemTitleChanged_Type = QEvent::User + IMEventType + 4;
43 static int const ItemRateChanged_Type  = QEvent::User + IMEventType + 5;
44 static int const VolumeChanged_Type    = QEvent::User + IMEventType + 6;
45 static int const FullscreenControlShow_Type = QEvent::User + IMEventType + 7;
46 static int const FullscreenControlHide_Type = QEvent::User + IMEventType + 8;
47 static int const FullscreenControlPlanHide_Type = QEvent::User + IMEventType + 9;
48 static int const ItemSpuChanged_Type = QEvent::User + IMEventType + 10;
49
50 class IMEvent : public QEvent
51 {
52 public:
53     IMEvent( int type, int id ) : QEvent( (QEvent::Type)(type) )
54     { i_id = id ; } ;
55     virtual ~IMEvent() {};
56
57     int i_id;
58 };
59
60 class InputManager : public QObject
61 {
62     Q_OBJECT;
63 public:
64     InputManager( QObject *, intf_thread_t * );
65     virtual ~InputManager();
66
67     void delInput();
68     bool hasInput() { return p_input && !p_input->b_dead && !p_input->b_die; }
69     bool hasAudio();
70     bool hasVideo();
71
72 private:
73     intf_thread_t  *p_intf;
74     input_thread_t *p_input;
75     int             i_input_id;
76     int             i_old_playing_status;
77     QString         old_name;
78     QString         artUrl;
79     int             i_rate;
80     bool            b_transparentTelextext;
81
82     void customEvent( QEvent * );
83     void addCallbacks();
84     void delCallbacks();
85     void UpdateRate();
86     void UpdateMeta();
87     void UpdateStatus();
88     void UpdateNavigation();
89     void UpdatePosition();
90     void UpdateSPU();
91     void UpdateArt();
92
93 public slots:
94     void setInput( input_thread_t * ); ///< Our controlled input changed
95     void sliderUpdate( float ); ///< User dragged the slider. We get new pos
96     void togglePlayPause();
97     void slower();
98     void faster();
99     void normalRate();
100     void setRate( int );
101     void sectionNext();
102     void sectionPrev();
103     void sectionMenu();
104     void telexGotoPage( int ); ///< Goto teletext page
105     void telexToggle( bool );  ///< Enable disable teletext buttons
106     void telexSetTransparency(); ///< Set transparency on teletext background
107
108 signals:
109     /// Send new position, new time and new length
110     void positionUpdated( float , int, int );
111     void rateChanged( int );
112     void nameChanged( QString );
113     /// Used to signal whether we should show navigation buttons
114     void navigationChanged( int );
115     /// Play/pause status
116     void statusChanged( int );
117     void artChanged( QString );
118     /// Controll of fullscreen controller
119     void inputUnset();
120     /// Teletext
121     void teletextEnabled( bool );
122 };
123
124 class MainInputManager : public QObject
125 {
126     Q_OBJECT;
127 public:
128     static MainInputManager *getInstance( intf_thread_t *_p_intf )
129     {
130         if( !instance )
131             instance = new MainInputManager( _p_intf );
132         return instance;
133     }
134     static void killInstance()
135     {
136         if( instance ) delete instance;
137     }
138     virtual ~MainInputManager();
139
140     input_thread_t *getInput() { return p_input; };
141     InputManager *getIM() { return im; };
142
143 private:
144     MainInputManager( intf_thread_t * );
145     void customEvent( QEvent * );
146
147     InputManager            *im;
148     input_thread_t          *p_input;
149
150     intf_thread_t           *p_intf;
151     static MainInputManager *instance;
152 public slots:
153     bool teletextState();
154     void togglePlayPause();
155     void stop();
156     void next();
157     void prev();
158 signals:
159     void inputChanged( input_thread_t * );
160     void volumeChanged();
161 };
162
163 #endif