]> git.sesse.net Git - vlc/blob - modules/gui/qt4/input_manager.hpp
7a120ce76e5e572eb959e59dbd392cb180241a2f
[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  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #ifndef _INPUT_MANAGER_H_
25 #define _INPUT_MANAGER_H_
26
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #include <vlc_common.h>
32 #include <vlc_input.h>
33
34 #include "qt4.hpp"
35
36 #include <QObject>
37 #include <QEvent>
38
39 static int const PositionUpdate_Type   = QEvent::User + IMEventType + 1;
40 static int const ItemChanged_Type      = QEvent::User + IMEventType + 2;
41 static int const ItemStateChanged_Type = QEvent::User + IMEventType + 3;
42 static int const ItemTitleChanged_Type = QEvent::User + IMEventType + 4;
43 static int const ItemRateChanged_Type  = QEvent::User + IMEventType + 5;
44 static int const VolumeChanged_Type    = QEvent::User + IMEventType + 6;
45 static int const ItemSpuChanged_Type   = QEvent::User + IMEventType + 7;
46
47 static int const FullscreenControlShow_Type = QEvent::User + IMEventType + 10;
48 static int const FullscreenControlHide_Type = QEvent::User + IMEventType + 11;
49 static int const FullscreenControlPlanHide_Type = QEvent::User + IMEventType + 12;
50
51 class IMEvent : public QEvent
52 {
53 public:
54     IMEvent( int type, int id ) : QEvent( (QEvent::Type)(type) )
55     { i_id = id ; } ;
56     virtual ~IMEvent() {};
57
58     int i_id;
59 };
60
61 class InputManager : public QObject
62 {
63     Q_OBJECT;
64 public:
65     InputManager( QObject *, intf_thread_t * );
66     virtual ~InputManager();
67
68     void delInput();
69     bool hasInput() { return p_input && !p_input->b_dead && !p_input->b_die; }
70     bool hasAudio();
71     bool hasVideo();
72
73 private:
74     intf_thread_t  *p_intf;
75     input_thread_t *p_input;
76     int             i_input_id;
77     int             i_old_playing_status;
78     QString         old_name;
79     QString         artUrl;
80     int             i_rate;
81     bool            b_transparentTelextext;
82
83     void customEvent( QEvent * );
84     void addCallbacks();
85     void delCallbacks();
86     void UpdateRate();
87     void UpdateMeta();
88     void UpdateStatus();
89     void UpdateNavigation();
90     void UpdatePosition();
91     void UpdateSPU();
92     void UpdateArt();
93
94 public slots:
95     void setInput( input_thread_t * ); ///< Our controlled input changed
96     void sliderUpdate( float ); ///< User dragged the slider. We get new pos
97     void togglePlayPause();
98     void slower();
99     void faster();
100     void normalRate();
101     void setRate( int );
102     void sectionNext();
103     void sectionPrev();
104     void sectionMenu();
105     void telexGotoPage( int ); ///< Goto teletext page
106     void telexToggle( bool );  ///< Enable disable teletext buttons
107     void telexToggleButtons(); ///< Toggle buttons after click
108     void telexSetTransparency(); ///< Set transparency on teletext background
109
110 signals:
111     /// Send new position, new time and new length
112     void positionUpdated( float , int, int );
113     void rateChanged( int );
114     void nameChanged( QString );
115     /// Used to signal whether we should show navigation buttons
116     void navigationChanged( int );
117     /// Play/pause status
118     void statusChanged( int );
119     void artChanged( QString );
120     /// Controll of fullscreen controller
121     void inputUnset();
122     /// Teletext
123     void teletextEnabled( bool );
124     void toggleTelexButtons();
125     void toggleTelexTransparency();
126     void setNewTelexPage( int );
127 };
128
129 class MainInputManager : public QObject
130 {
131     Q_OBJECT;
132 public:
133     static MainInputManager *getInstance( intf_thread_t *_p_intf )
134     {
135         if( !instance )
136             instance = new MainInputManager( _p_intf );
137         return instance;
138     }
139     static void killInstance()
140     {
141         if( instance ) delete instance;
142     }
143     virtual ~MainInputManager();
144
145     input_thread_t *getInput() { return p_input; };
146     InputManager *getIM() { return im; };
147
148 private:
149     MainInputManager( intf_thread_t * );
150     void customEvent( QEvent * );
151
152     InputManager            *im;
153     input_thread_t          *p_input;
154
155     intf_thread_t           *p_intf;
156     static MainInputManager *instance;
157 public slots:
158     bool teletextState();
159     void togglePlayPause();
160     void stop();
161     void next();
162     void prev();
163 signals:
164     void inputChanged( input_thread_t * );
165     void volumeChanged();
166 };
167
168 #endif