]> git.sesse.net Git - vlc/blob - modules/gui/qt4/input_manager.hpp
Qt: connect the delay of ES to the extended panels.
[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  *          Jean-Baptiste <jb@videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #ifndef _INPUT_MANAGER_H_
26 #define _INPUT_MANAGER_H_
27
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31
32 #include <vlc_input.h>
33
34 #include "qt4.hpp"
35
36 #include <QObject>
37 #include <QEvent>
38
39
40 enum {
41     PositionUpdate_Type = QEvent::User + IMEventType + 1,
42     ItemChanged_Type,
43     ItemStateChanged_Type,
44     ItemTitleChanged_Type,
45     ItemRateChanged_Type,
46     VolumeChanged_Type,
47     ItemEsChanged_Type,
48     ItemTeletextChanged_Type,
49     InterfaceVoutUpdate_Type,
50     StatisticsUpdate_Type, /*10*/
51     MetaChanged_Type,
52     NameChanged_Type,
53     InfoChanged_Type,
54     SynchroChanged_Type,
55
56     FullscreenControlToggle_Type = QEvent::User + IMEventType + 20,
57     FullscreenControlShow_Type,
58     FullscreenControlHide_Type,
59     FullscreenControlPlanHide_Type,
60 };
61
62 class IMEvent : public QEvent
63 {
64 friend class InputManager;
65     public:
66     IMEvent( int type, int id ) : QEvent( (QEvent::Type)(type) )
67     { i_id = id ; } ;
68     virtual ~IMEvent() {};
69
70 private:
71     int i_id;
72 };
73
74 class InputManager : public QObject
75 {
76     Q_OBJECT;
77     friend class MainInputManager;
78
79 public:
80     InputManager( QObject *, intf_thread_t * );
81     virtual ~InputManager();
82
83     void delInput();
84     bool hasInput()
85     {
86         return p_input /* We have an input */
87             && !p_input->b_dead /* not dead yet, */
88             && !p_input->b_eof  /* not EOF either, */
89             && vlc_object_alive (p_input); /* and the VLC object is alive */
90     }
91
92     bool hasAudio();
93     bool hasVideo() { return hasInput() && b_video; }
94
95     QString getName() { return oldName; }
96
97 private:
98     intf_thread_t  *p_intf;
99     input_thread_t *p_input;
100     int             i_input_id;
101     int             i_old_playing_status;
102     QString         oldName;
103     QString         artUrl;
104     int             i_rate;
105     bool            b_video;
106     mtime_t         timeA, timeB;
107
108     void customEvent( QEvent * );
109
110     void addCallbacks();
111     void delCallbacks();
112
113     void UpdateRate();
114     void UpdateName();
115     void UpdateStatus();
116     void UpdateNavigation();
117     void UpdatePosition();
118     void UpdateTeletext();
119     void UpdateArt();
120     void UpdateInfo();
121     void UpdateMeta();
122     void UpdateVout();
123     void UpdateStats();
124
125     void AtoBLoop( int );
126
127 public slots:
128     void setInput( input_thread_t * ); ///< Our controlled input changed
129     void sliderUpdate( float ); ///< User dragged the slider. We get new pos
130     /* SpeedRate Rate Management */
131     void reverse();
132     void slower();
133     void faster();
134     void normalRate();
135     void setRate( int );
136     /* Menus */
137     void sectionNext();
138     void sectionPrev();
139     void sectionMenu();
140     /* Teletext */
141     void telexSetPage( int );          ///< Goto teletext page
142     void telexSetTransparency( bool ); ///< Transparency on teletext background
143     void telexActivation( bool );      ///< Enable disable teletext buttons
144     void activateTeletext( bool );     ///< Toggle buttons after click
145     /* A to B Loop */
146     void setAtoB();
147
148 private slots:
149     void togglePlayPause();
150
151 signals:
152     /// Send new position, new time and new length
153     void positionUpdated( float , int, int );
154     void rateChanged( int );
155     void nameChanged( QString );
156     /// Used to signal whether we should show navigation buttons
157     void titleChanged( bool );
158     void chapterChanged( bool );
159     /// Statistics are updated
160     void statisticsUpdated( input_item_t* );
161     void infoChanged( input_item_t* );
162     void metaChanged( input_item_t* );
163     void artChanged( input_item_t* );
164     /// Play/pause status
165     void statusChanged( int );
166     /// Teletext
167     void teletextPossible( bool );
168     void teletextActivated( bool );
169     void teletextTransparencyActivated( bool );
170     void newTelexPageSet( int );
171     /// Advanced buttons
172     void AtoBchanged( bool, bool );
173     /// Vout
174     void voutChanged( bool );
175     void synchroChanged();
176 };
177
178 class MainInputManager : public QObject
179 {
180     Q_OBJECT;
181 public:
182     static MainInputManager *getInstance( intf_thread_t *_p_intf )
183     {
184         if( !instance )
185             instance = new MainInputManager( _p_intf );
186         return instance;
187     }
188     static void killInstance()
189     {
190         if( instance ) delete instance;
191     }
192     virtual ~MainInputManager();
193
194     input_thread_t *getInput() { return p_input; };
195     InputManager *getIM() { return im; };
196
197 private:
198     MainInputManager( intf_thread_t * );
199     static MainInputManager *instance;
200
201     void customEvent( QEvent * );
202
203     InputManager            *im;
204     input_thread_t          *p_input;
205     intf_thread_t           *p_intf;
206
207 public slots:
208     void togglePlayPause();
209     void stop();
210     void next();
211     void prev();
212
213 signals:
214     void inputChanged( input_thread_t * );
215     void volumeChanged();
216 };
217
218 #endif