]> git.sesse.net Git - vlc/blob - modules/gui/qt4/input_manager.hpp
don't poll volume-change, change volumecontrol to use signal from
[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-2007 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 #include <vlc/vlc.h>
28 #include <vlc_input.h>
29
30 #include <QObject>
31 #include <QEvent>
32
33 static int PositionUpdate_Type = QEvent::User + 6;
34 static int ItemChanged_Type = QEvent::User + 7;
35 static int ItemRateChanged_Type = QEvent::User + 8;
36 static int ItemTitleChanged_Type = QEvent::User + 9;
37 static int ItemStateChanged_Type = QEvent::User + 10;
38 static int VolumeChanged_Type = QEvent::User + 11;
39
40 class IMEvent : public QEvent
41 {
42 public:
43     IMEvent( int type, int id ) : QEvent( (QEvent::Type)(type) )
44     { i_id = id ; } ;
45     virtual ~IMEvent() {};
46
47     int i_id;
48 };
49
50 class InputManager : public QObject
51 {
52     Q_OBJECT;
53 public:
54     InputManager( QObject *, intf_thread_t * );
55     virtual ~InputManager();
56
57     void delInput();
58     bool hasInput() { return p_input && !p_input->b_dead && !p_input->b_die; }
59     bool hasAudio() { return b_has_audio; }
60     bool hasVideo() { return b_has_video; }
61     bool b_has_audio, b_has_video, b_had_audio, b_had_video;
62 private:
63     void customEvent( QEvent * );
64     void addCallbacks( void );
65     void delCallbacks( void );
66     void UpdateRate( void );
67     void UpdateMeta( void );
68     void UpdateStatus( void );
69     void UpdateTitle( void );
70     void UpdatePosition( void );
71     intf_thread_t  *p_intf;
72     input_thread_t *p_input;
73     int             i_old_playing_status;
74     QString         old_name;
75     QString         artUrl;
76     int             i_rate;
77 public slots:
78     void togglePlayPause();
79     void setInput( input_thread_t * ); ///< Our controlled input changed
80     void sliderUpdate( float ); ///< User dragged the slider. We get new pos
81     void slower();
82     void faster();
83     void normalRate();
84     void setRate( int );
85     void sectionNext();
86     void sectionPrev();
87     void sectionMenu();
88 #ifdef ZVBI_COMPILED
89     void telexGotoPage( int );
90     void telexToggle( bool );
91     void telexSetTransparency( bool );
92 #endif
93 signals:
94     /// Send new position, new time and new length
95     void positionUpdated( float , int, int );
96     void rateChanged( int );
97     void nameChanged( QString );
98     /// Used to signal whether we should show navigation buttons
99     void navigationChanged( int );
100 #ifdef ZVBI_COMPILED
101     void teletextEnabled( bool );
102 #endif
103     /// Play/pause status
104     void statusChanged( int );
105     void artChanged( QString );
106 };
107
108 class MainInputManager : public QObject
109 {
110     Q_OBJECT;
111 public:
112     static MainInputManager *getInstance( intf_thread_t *_p_intf )
113     {
114         if( !instance )
115             instance = new MainInputManager( _p_intf );
116         return instance;
117     }
118     static void killInstance()
119     {
120         if( instance ) delete instance;
121     }
122     virtual ~MainInputManager();
123     input_thread_t *getInput() { return p_input; };
124     InputManager *getIM() { return im; };
125
126 private:
127     void customEvent( QEvent * );
128     MainInputManager( intf_thread_t * );
129
130     InputManager            *im;
131     intf_thread_t           *p_intf;
132     input_thread_t          *p_input;
133     static MainInputManager *instance;
134 public slots:
135     void togglePlayPause();
136     void stop();
137     void next();
138     void prev();
139 private slots:
140     //void updateInput();
141 signals:
142     void inputChanged( input_thread_t * );
143     void volumeChanged( void );
144 };
145
146 #endif