]> git.sesse.net Git - vlc/blob - modules/gui/qt4/input_manager.hpp
2218eaac1b5cd5758d443df14108cc8d92fc3b7d
[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 static int const ItemTeletextChanged_Type= QEvent::User + IMEventType + 8;
47
48 static int const FullscreenControlToggle_Type = QEvent::User + IMEventType + 10;
49 static int const FullscreenControlShow_Type = QEvent::User + IMEventType + 11;
50 static int const FullscreenControlHide_Type = QEvent::User + IMEventType + 12;
51 static int const FullscreenControlPlanHide_Type = QEvent::User + IMEventType + 13;
52
53 class IMEvent : public QEvent
54 {
55 public:
56     IMEvent( int type, int id ) : QEvent( (QEvent::Type)(type) )
57     { i_id = id ; } ;
58     virtual ~IMEvent() {};
59
60     int i_id;
61 };
62
63 class InputManager : public QObject
64 {
65     Q_OBJECT;
66 public:
67     InputManager( QObject *, intf_thread_t * );
68     virtual ~InputManager();
69
70     void delInput();
71     bool hasInput() { return p_input && !p_input->b_dead && vlc_object_alive (p_input); }
72     bool hasAudio();
73     bool hasVideo();
74     
75     QString getName() { return old_name; }
76
77 private:
78     intf_thread_t  *p_intf;
79     input_thread_t *p_input;
80     int             i_input_id;
81     int             i_old_playing_status;
82     QString         old_name;
83     QString         artUrl;
84     int             i_rate;
85     bool            b_transparentTelextext;
86
87     void customEvent( QEvent * );
88     void addCallbacks();
89     void delCallbacks();
90     void UpdateRate();
91     void UpdateMeta();
92     void UpdateStatus();
93     void UpdateNavigation();
94     void UpdatePosition();
95     void UpdateSPU();
96     void UpdateTeletext();
97     void UpdateArt();
98
99 public slots:
100     void setInput( input_thread_t * ); ///< Our controlled input changed
101     void sliderUpdate( float ); ///< User dragged the slider. We get new pos
102     void togglePlayPause();
103     void slower();
104     void faster();
105     void normalRate();
106     void setRate( int );
107     void sectionNext();
108     void sectionPrev();
109     void sectionMenu();
110     void telexGotoPage( int ); ///< Goto teletext page
111     void telexToggle( bool );  ///< Enable disable teletext buttons
112     void telexToggleButtons(); ///< Toggle buttons after click
113     void telexSetTransparency(); ///< Set transparency on teletext background
114
115 signals:
116     /// Send new position, new time and new length
117     void positionUpdated( float , int, int );
118     void rateChanged( int );
119     void nameChanged( QString );
120     /// Used to signal whether we should show navigation buttons
121     void navigationChanged( int );
122     /// Play/pause status
123     void statusChanged( int );
124     void artChanged( QString );
125     /// Teletext
126     void teletextEnabled( bool );
127     void toggleTelexButtons();
128     void toggleTelexTransparency();
129     void setNewTelexPage( int );
130     /// Advanced buttons
131     void advControlsSetIcon();
132 };
133
134 class MainInputManager : public QObject
135 {
136     Q_OBJECT;
137 public:
138     static MainInputManager *getInstance( intf_thread_t *_p_intf )
139     {
140         if( !instance )
141             instance = new MainInputManager( _p_intf );
142         return instance;
143     }
144     static void killInstance()
145     {
146         if( instance ) delete instance;
147     }
148     virtual ~MainInputManager();
149
150     input_thread_t *getInput() { return p_input; };
151     InputManager *getIM() { return im; };
152
153 private:
154     MainInputManager( intf_thread_t * );
155     void customEvent( QEvent * );
156
157     InputManager            *im;
158     input_thread_t          *p_input;
159
160     intf_thread_t           *p_intf;
161     static MainInputManager *instance;
162 public slots:
163     bool teletextState();
164     void togglePlayPause();
165     void stop();
166     void next();
167     void prev();
168 signals:
169     void inputChanged( input_thread_t * );
170     void volumeChanged();
171 };
172
173 #endif