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