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