]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs/streaminfo.cpp
Advanced controls bar
[vlc] / modules / gui / qt4 / dialogs / streaminfo.cpp
1 /*****************************************************************************
2  * streaminfo.cpp : Information about an item
3  ****************************************************************************
4  * Copyright (C) 2006 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 #include <QTabWidget>
24 #include <QGridLayout>
25
26 #include "dialogs/streaminfo.hpp"
27 #include "input_manager.hpp"
28 #include "dialogs_provider.hpp"
29 #include "util/qvlcframe.hpp"
30 #include "components/infopanels.hpp"
31 #include "qt4.hpp"
32
33 static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
34                         vlc_value_t oldval, vlc_value_t newval, void *param );
35 StreamInfoDialog *StreamInfoDialog::instance = NULL;
36
37 StreamInfoDialog::StreamInfoDialog( intf_thread_t *_p_intf ) :QVLCFrame( _p_intf )
38 {
39     i_runs = 0;
40     setWindowTitle( _("Stream information" ) );
41     QGridLayout *layout = new QGridLayout(this);
42
43     IT = new InfoTab( this, p_intf, true ) ;
44     QPushButton *closeButton = new QPushButton(qtr("&Close"));
45     layout->addWidget(IT,0,0,1,3);
46     layout->addWidget(closeButton,1,2);
47
48     BUTTONACT( closeButton, close() );
49     ON_TIMEOUT( update() );
50     p_input = NULL;
51
52     var_AddCallback( THEPL, "item-change", ItemChanged, this );
53
54     readSettings( "StreamInfo" , QSize( 470, 450 ) );
55 }
56
57 StreamInfoDialog::~StreamInfoDialog()
58 {
59     var_DelCallback( THEPL, "item-change", ItemChanged, this );
60     writeSettings( "StreamInfo" );
61 }
62
63 static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
64                         vlc_value_t oldval, vlc_value_t newval, void *param )
65 {
66     StreamInfoDialog *p_d = (StreamInfoDialog *)param;
67     p_d->need_update = VLC_TRUE;
68     return VLC_SUCCESS;
69 }
70
71 void StreamInfoDialog::update()
72 {
73     // Timer runs at 150 ms, dont' update more than 2 times per second
74     i_runs++;
75     if( i_runs % 3 != 0 ) return;
76
77     input_thread_t *p_input = MainInputManager::getInstance( p_intf )->getInput();
78     if( !p_input || p_input->b_dead )
79     {
80         IT->clear();
81         return;
82     }
83
84     vlc_object_yield( p_input );
85     vlc_mutex_lock( &p_input->input.p_item->lock );
86
87     IT->update( p_input->input.p_item, need_update, need_update );
88     need_update = false;
89
90     vlc_mutex_unlock( &p_input->input.p_item->lock );
91     vlc_object_release( p_input );
92 }
93
94 void StreamInfoDialog::close()
95 {
96     this->toggleVisible();
97 }