]> git.sesse.net Git - vlc/blob - modules/gui/qt4/input_manager.hpp
Qt: Audio control widget changes
[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 QVLC_INPUT_MANAGER_H_
26 #define QVLC_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     SoundMuteChanged_Type,
48     ItemEsChanged_Type,
49     ItemTeletextChanged_Type,
50     InterfaceVoutUpdate_Type,
51     StatisticsUpdate_Type, /*10*/
52     InterfaceAoutUpdate_Type,
53     MetaChanged_Type,
54     NameChanged_Type,
55     InfoChanged_Type,
56     SynchroChanged_Type,
57     CachingEvent_Type,
58     BookmarksChanged_Type,
59     RecordingEvent_Type,
60     ProgramChanged_Type,
61     RandomChanged_Type,
62     LoopChanged_Type,
63     RepeatChanged_Type,
64 /*    SignalChanged_Type, */
65
66     FullscreenControlToggle_Type = QEvent::User + IMEventType + 20,
67     FullscreenControlShow_Type,
68     FullscreenControlHide_Type,
69     FullscreenControlPlanHide_Type,
70 };
71
72 enum { NORMAL,    /* loop: 0, repeat: 0 */
73        REPEAT_ONE,/* loop: 1, repeat: 0 */
74        REPEAT_ALL,/* loop: 0, repeat: 1 */
75 };
76
77 class IMEvent : public QEvent
78 {
79 friend class InputManager;
80     public:
81     IMEvent( int type, input_item_t *p_input = NULL )
82         : QEvent( (QEvent::Type)(type) )
83     {
84         if( (p_item = p_input) != NULL )
85             vlc_gc_incref( p_item );
86     }
87     virtual ~IMEvent()
88     {
89         if( p_item )
90             vlc_gc_decref( p_item );
91     }
92
93 private:
94     input_item_t *p_item;
95 };
96
97 enum PLEventTypes
98 {
99     PLItemAppended_Type = QEvent::User + PLEventType + 1,
100     PLItemRemoved_Type
101 };
102
103 class PLEvent : public QEvent
104 {
105 public:
106     PLEvent( PLEventTypes t, int i, int p )
107         : QEvent( (QEvent::Type)t ), i_item(i), i_parent(p) {}
108     int i_item;
109     int i_parent;
110 };
111
112 class InputManager : public QObject
113 {
114     Q_OBJECT;
115     friend class MainInputManager;
116
117 public:
118     InputManager( QObject *, intf_thread_t * );
119     virtual ~InputManager();
120
121     void delInput();
122     bool hasInput()
123     {
124         return p_input /* We have an input */
125             && !p_input->b_dead /* not dead yet, */
126             && !p_input->b_eof  /* not EOF either, */
127             && vlc_object_alive (p_input); /* and the VLC object is alive */
128     }
129
130     bool hasAudio();
131     bool hasVideo() { return hasInput() && b_video; }
132     void requestArtUpdate();
133
134     QString getName() { return oldName; }
135
136 private:
137     intf_thread_t  *p_intf;
138     input_thread_t *p_input;
139     input_item_t   *p_item;
140     int             i_old_playing_status;
141     QString         oldName;
142     QString         artUrl;
143     int             i_rate;
144     float           f_cache;
145     bool            b_video;
146     mtime_t         timeA, timeB;
147
148     void customEvent( QEvent * );
149
150     void addCallbacks();
151     void delCallbacks();
152
153     void UpdateRate();
154     void UpdateName();
155     void UpdateStatus();
156     void UpdateNavigation();
157     void UpdatePosition();
158     void UpdateTeletext();
159     void UpdateArt();
160     void UpdateInfo();
161     void UpdateMeta();
162     void UpdateMeta(input_item_t *);
163     void UpdateVout();
164     void UpdateAout();
165     void UpdateStats();
166     void UpdateCaching();
167     void UpdateRecord();
168     void UpdateProgramEvent();
169
170 public slots:
171     void setInput( input_thread_t * ); ///< Our controlled input changed
172     void sliderUpdate( float ); ///< User dragged the slider. We get new pos
173     /* SpeedRate Rate Management */
174     void reverse();
175     void slower();
176     void faster();
177     void littlefaster();
178     void littleslower();
179     void normalRate();
180     void setRate( int );
181     /* Jumping */
182     void jumpFwd();
183     void jumpBwd();
184     /* Menus */
185     void sectionNext();
186     void sectionPrev();
187     void sectionMenu();
188     /* Teletext */
189     void telexSetPage( int );          ///< Goto teletext page
190     void telexSetTransparency( bool ); ///< Transparency on teletext background
191     void activateTeletext( bool );     ///< Toggle buttons after click
192     /* A to B Loop */
193     void setAtoB();
194
195 private slots:
196     void togglePlayPause();
197     void AtoBLoop( float, int, int );
198
199 signals:
200     /// Send new position, new time and new length
201     void positionUpdated( float , int, int );
202     void rateChanged( int );
203     void nameChanged( const QString& );
204     /// Used to signal whether we should show navigation buttons
205     void titleChanged( bool );
206     void chapterChanged( bool );
207     /// Statistics are updated
208     void statisticsUpdated( input_item_t* );
209     void infoChanged( input_item_t* );
210     void currentMetaChanged( input_item_t* );
211     void metaChanged( input_item_t *);
212     void artChanged( QString );
213     /// Play/pause status
214     void statusChanged( int );
215     void recordingStateChanged( bool );
216     /// Teletext
217     void teletextPossible( bool );
218     void teletextActivated( bool );
219     void teletextTransparencyActivated( bool );
220     void newTelexPageSet( int );
221     /// Advanced buttons
222     void AtoBchanged( bool, bool );
223     /// Vout
224     void voutChanged( bool );
225     void voutListChanged( vout_thread_t **pp_vout, int i_vout );
226     /// Other
227     void synchroChanged();
228     void bookmarksChanged();
229     void cachingChanged( float );
230     /// Program Event changes
231     void encryptionChanged( bool );
232 };
233
234 class MainInputManager : public QObject
235 {
236     Q_OBJECT;
237 public:
238     static MainInputManager *getInstance( intf_thread_t *_p_intf )
239     {
240         if( !instance )
241             instance = new MainInputManager( _p_intf );
242         return instance;
243     }
244     static void killInstance()
245     {
246         delete instance;
247         instance = NULL;
248     }
249
250     input_thread_t *getInput() { return p_input; }
251     InputManager *getIM() { return im; }
252
253     vout_thread_t* getVout();
254     aout_instance_t *getAout();
255
256 private:
257     MainInputManager( intf_thread_t * );
258     virtual ~MainInputManager();
259
260     static MainInputManager *instance;
261
262     void customEvent( QEvent * );
263
264     InputManager            *im;
265     input_thread_t          *p_input;
266     intf_thread_t           *p_intf;
267
268     void notifyRepeatLoop();
269 public slots:
270     void togglePlayPause();
271     void toggleRandom();
272     void stop();
273     void next();
274     void prev();
275     void activatePlayQuit( bool );
276
277     void loopRepeatLoopStatus();
278
279 signals:
280     void inputChanged( input_thread_t * );
281     void volumeChanged();
282     void soundMuteChanged();
283     void playlistItemAppended( int itemId, int parentId );
284     void playlistItemRemoved( int itemId );
285     void randomChanged( bool );
286     void repeatLoopChanged( int );
287 };
288
289 #endif