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