1 /*****************************************************************************
2 * main_inteface.cpp : Main interface
3 ****************************************************************************
4 * Copyright (C) 2000-2005 the VideoLAN team
5 * $Id: wxwidgets.cpp 15731 2006-05-25 14:43:53Z zorglub $
7 * Authors: Clément Stenac <zorglub@videolan.org>
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.
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.
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. *****************************************************************************/
23 #include "main_interface.hpp"
24 #include "input_manager.hpp"
25 #include "util/input_slider.hpp"
26 #include "dialogs_provider.hpp"
27 #include <QCloseEvent>
30 MainInterface::MainInterface( intf_thread_t *_p_intf ) :
31 QWidget( NULL ), p_intf( _p_intf)
34 slider = new InputSlider( Qt::Horizontal, this );
36 /* Init input manager */
38 main_input_manager = new InputManager( this, p_intf );
41 void MainInterface::init()
43 /* Get timer updates */
44 QObject::connect( DialogsProvider::getInstance(NULL)->fixed_timer,
45 SIGNAL( timeout() ), this, SLOT(updateOnTimer() ) );
46 /* Tell input manager about the input changes */
47 QObject::connect( this, SIGNAL( inputChanged( input_thread_t * ) ),
48 main_input_manager, SLOT( setInput( input_thread_t * ) ) );
50 /* Connect the slider and the input manager (both ways) */
51 QObject::connect( main_input_manager, SIGNAL(positionUpdated(
52 float, int, int ) ), slider, SLOT( setPosition( float,int,
54 QObject::connect( slider, SIGNAL( sliderDragged( float ) ),
55 main_input_manager, SLOT( sliderUpdate( float ) ) );
57 /* Connect the display and the input manager */
60 MainInterface::~MainInterface()
64 void MainInterface::updateOnTimer()
70 vlc_mutex_lock( &p_intf->change_lock );
71 if( p_input && p_input->b_dead )
73 vlc_object_release( p_input );
75 emit inputChanged( NULL );
80 playlist_t *p_playlist = (playlist_t *) vlc_object_find( p_intf,
81 VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
85 p_input = p_playlist->p_input;
88 vlc_object_yield( p_input );
89 emit inputChanged( p_input );
93 vlc_object_release( p_playlist );
95 vlc_mutex_unlock( &p_intf->change_lock );
98 void MainInterface::closeEvent( QCloseEvent *e )
101 p_intf->b_die = VLC_TRUE;