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