main_interface.cpp 3.03 KB
Newer Older
zorglub's avatar
zorglub committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*****************************************************************************
 * main_inteface.cpp : Main interface
 ****************************************************************************
 * Copyright (C) 2000-2005 the VideoLAN team
 * $Id: wxwidgets.cpp 15731 2006-05-25 14:43:53Z zorglub $
 *
 * Authors: Clément Stenac <zorglub@videolan.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/

#include "main_interface.hpp"
zorglub's avatar
zorglub committed
24
25
#include "input_manager.hpp"
#include "dialogs_provider.hpp"
zorglub's avatar
zorglub committed
26
#include <QCloseEvent>
27
#include <assert.h>
zorglub's avatar
zorglub committed
28

zorglub's avatar
zorglub committed
29
30
MainInterface::MainInterface( intf_thread_t *_p_intf ) :
                            QWidget( NULL ), p_intf( _p_intf)
zorglub's avatar
zorglub committed
31
{
zorglub's avatar
zorglub committed
32
33
34
35
36
    fprintf( stderr, "QT Main interface\n" );

    /* Init UI */

    /* Init input manager */
zorglub's avatar
zorglub committed
37
38
    p_input = NULL;
    main_input_manager = new InputManager( this, p_intf );
zorglub's avatar
zorglub committed
39
40
41
42
43
44
}

void MainInterface::init()
{
    /* Get timer updates */
    QObject::connect( DialogsProvider::getInstance(NULL)->fixed_timer,
zorglub's avatar
zorglub committed
45
                      SIGNAL( timeout() ), this, SLOT(updateOnTimer() ) );
zorglub's avatar
zorglub committed
46
47
    /* Tell input manager about the input changes */
    QObject::connect( this, SIGNAL( inputChanged( input_thread_t * ) ),
zorglub's avatar
zorglub committed
48
49
                   main_input_manager, SLOT( setInput( input_thread_t * ) ) );

50
51
52
53
    /* Connect the slider and the input manager */
    // both ways 

    /* Connect the display and the input manager */
zorglub's avatar
zorglub committed
54
55
56
57
58
}

MainInterface::~MainInterface()
{
}
zorglub's avatar
zorglub committed
59
60
61

void MainInterface::updateOnTimer()
{
zorglub's avatar
zorglub committed
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
    if( p_intf->b_die )
    {
        QApplication::quit();
    }
    vlc_mutex_lock( &p_intf->change_lock );
    if( p_input && p_input->b_dead )
    {
        vlc_object_release( p_input );
        p_input = NULL;
        emit inputChanged( NULL );
    }

    if( !p_input )
    {
        playlist_t *p_playlist = (playlist_t *) vlc_object_find( p_intf,
                                        VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
        assert( p_playlist );
        PL_LOCK;

        p_input = p_playlist->p_input;
        if( p_input )
        {
            vlc_object_yield( p_input );
            fprintf( stderr, "Sending input\n");
            emit inputChanged( p_input );
        }
zorglub's avatar
zorglub committed
88

zorglub's avatar
zorglub committed
89
90
91
92
93
94
95
96
97
98
        PL_UNLOCK;
        vlc_object_release( p_playlist );
    }
    vlc_mutex_unlock( &p_intf->change_lock );
}

void MainInterface::closeEvent( QCloseEvent *e )
{
    hide();
    p_intf->b_die = VLC_TRUE;
zorglub's avatar
zorglub committed
99
}