]> git.sesse.net Git - vlc/blob - modules/gui/qt4/input_manager.hpp
f3356ee0afe59fd36fbaff8d889804f882fd8766
[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     CachingEvent_Type,
56     BookmarksChanged_Type,
57 /*    RecordingEvent_Type,
58     ProgramChanged_Type,
59     SignalChanged_Type, */
60
61     FullscreenControlToggle_Type = QEvent::User + IMEventType + 20,
62     FullscreenControlShow_Type,
63     FullscreenControlHide_Type,
64     FullscreenControlPlanHide_Type,
65 };
66
67 class IMEvent : public QEvent
68 {
69 friend class InputManager;
70     public:
71     IMEvent( int type, int id ) : QEvent( (QEvent::Type)(type) )
72     { i_id = id ; } ;
73     virtual ~IMEvent() {};
74
75 private:
76     int i_id;
77 };
78
79 class InputManager : public QObject
80 {
81     Q_OBJECT;
82     friend class MainInputManager;
83
84 public:
85     InputManager( QObject *, intf_thread_t * );
86     virtual ~InputManager();
87
88     void delInput();
89     bool hasInput()
90     {
91         return p_input /* We have an input */
92             && !p_input->b_dead /* not dead yet, */
93             && !p_input->b_eof  /* not EOF either, */
94             && vlc_object_alive (p_input); /* and the VLC object is alive */
95     }
96
97     bool hasAudio();
98     bool hasVideo() { return hasInput() && b_video; }
99
100     QString getName() { return oldName; }
101
102 private:
103     intf_thread_t  *p_intf;
104     input_thread_t *p_input;
105     int             i_input_id;
106     int             i_old_playing_status;
107     QString         oldName;
108     QString         artUrl;
109     int             i_rate;
110     float           f_cache;
111     bool            b_video;
112     mtime_t         timeA, timeB;
113
114     void customEvent( QEvent * );
115
116     void addCallbacks();
117     void delCallbacks();
118
119     void UpdateRate();
120     void UpdateName();
121     void UpdateStatus();
122     void UpdateNavigation();
123     void UpdatePosition();
124     void UpdateTeletext();
125     void UpdateArt();
126     void UpdateInfo();
127     void UpdateMeta();
128     void UpdateVout();
129     void UpdateStats();
130     void UpdateCaching();
131
132     void AtoBLoop( int );
133
134 public slots:
135     void setInput( input_thread_t * ); ///< Our controlled input changed
136     void sliderUpdate( float ); ///< User dragged the slider. We get new pos
137     /* SpeedRate Rate Management */
138     void reverse();
139     void slower();
140     void faster();
141     void normalRate();
142     void setRate( int );
143     /* Menus */
144     void sectionNext();
145     void sectionPrev();
146     void sectionMenu();
147     /* Teletext */
148     void telexSetPage( int );          ///< Goto teletext page
149     void telexSetTransparency( bool ); ///< Transparency on teletext background
150     void telexActivation( bool );      ///< Enable disable teletext buttons
151     void activateTeletext( bool );     ///< Toggle buttons after click
152     /* A to B Loop */
153     void setAtoB();
154
155 private slots:
156     void togglePlayPause();
157
158 signals:
159     /// Send new position, new time and new length
160     void positionUpdated( float , int, int );
161     void rateChanged( int );
162     void nameChanged( QString );
163     /// Used to signal whether we should show navigation buttons
164     void titleChanged( bool );
165     void chapterChanged( bool );
166     /// Statistics are updated
167     void statisticsUpdated( input_item_t* );
168     void infoChanged( input_item_t* );
169     void metaChanged( input_item_t* );
170     void artChanged( input_item_t* );
171     /// Play/pause status
172     void statusChanged( int );
173     /// Teletext
174     void teletextPossible( bool );
175     void teletextActivated( bool );
176     void teletextTransparencyActivated( bool );
177     void newTelexPageSet( int );
178     /// Advanced buttons
179     void AtoBchanged( bool, bool );
180     /// Vout
181     void voutChanged( bool );
182     void synchroChanged();
183     void bookmarksChanged();
184     void cachingChanged( float );
185 };
186
187 class MainInputManager : public QObject
188 {
189     Q_OBJECT;
190 public:
191     static MainInputManager *getInstance( intf_thread_t *_p_intf )
192     {
193         if( !instance )
194             instance = new MainInputManager( _p_intf );
195         return instance;
196     }
197     static void killInstance()
198     {
199         if( instance ) delete instance;
200     }
201     virtual ~MainInputManager();
202
203     input_thread_t *getInput() { return p_input; };
204     InputManager *getIM() { return im; };
205
206 private:
207     MainInputManager( intf_thread_t * );
208     static MainInputManager *instance;
209
210     void customEvent( QEvent * );
211
212     InputManager            *im;
213     input_thread_t          *p_input;
214     intf_thread_t           *p_intf;
215
216 public slots:
217     void togglePlayPause();
218     void stop();
219     void next();
220     void prev();
221
222 signals:
223     void inputChanged( input_thread_t * );
224     void volumeChanged();
225 };
226
227 #endif