1 /*****************************************************************************
2 * mediainfo.cpp : Information about an item
3 ****************************************************************************
4 * Copyright (C) 2006-2007 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Jean-Baptiste Kempf <jb@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 ******************************************************************************/
28 #include "dialogs/mediainfo.hpp"
29 #include "input_manager.hpp"
32 #include <QGridLayout>
36 MediaInfoDialog *MediaInfoDialog::instance = NULL;
38 /* This Dialog has two main modes:
39 - General Mode that shows the current Played item, and the stats
40 - Single mode that shows the info on ONE SINGLE Item on the playlist
41 Please be Careful of not breaking one the modes behaviour... */
43 MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf,
44 input_item_t *_p_item,
47 QVLCFrame( _p_intf ), mainInput(_mainInput),
54 setWindowTitle( qtr( "Media Information" ) );
56 /* TabWidgets and Tabs creation */
58 MP = new MetaPanel( IT, p_intf );
59 IT->addTab( MP, qtr( "&General" ) );
60 EMP = new ExtraMetaPanel( IT, p_intf );
61 IT->addTab( EMP, qtr( "&Extra Metadata" ) );
62 IP = new InfoPanel( IT, p_intf );
63 IT->addTab( IP, qtr( "&Codec Details" ) );
66 ISP = new InputStatsPanel( IT, p_intf );
67 IT->addTab( ISP, qtr( "&Statistics" ) );
70 QGridLayout *layout = new QGridLayout( this );
72 /* No need to use a QDialogButtonBox here */
73 saveMetaButton = new QPushButton( qtr( "&Save Metadata" ) );
74 saveMetaButton->hide();
75 QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
76 closeButton->setDefault( true );
78 uriLine = new QLineEdit;
79 QLabel *uriLabel = new QLabel( qtr( "Location:" ) );
81 layout->addWidget( IT, 0, 0, 1, 8 );
82 layout->addWidget( uriLabel, 1, 0, 1, 1 );
83 layout->addWidget( uriLine, 1, 1, 1, 7 );
84 layout->addWidget( saveMetaButton, 2, 6 );
85 layout->addWidget( closeButton, 2, 7 );
87 BUTTONACT( closeButton, close() );
89 /* The tabs buttons are shown in the main dialog for space and cosmetics */
90 BUTTONACT( saveMetaButton, saveMeta() );
92 /* Let the MetaData Panel update the URI */
93 CONNECT( MP, uriSet( QString ), uriLine, setText( QString ) );
94 CONNECT( MP, editing(), this, showMetaSaveButton() );
96 CONNECT( IT, currentChanged( int ), this, updateButtons( int ) );
98 /* If using the General Mode */
101 msg_Dbg( p_intf, "Using a general windows" );
102 CONNECT( THEMIM, inputChanged( input_thread_t * ),
103 this, update( input_thread_t * ) );
105 if( THEMIM->getInput() )
106 p_item = input_GetItem( THEMIM->getInput() );
109 /* Call update by hand, so info is shown from current item too */
111 update( p_item, true, true );
113 readSettings( "Mediainfo", QSize( 600 , 480 ) );
116 MediaInfoDialog::~MediaInfoDialog()
118 writeSettings( "Mediainfo" );
121 void MediaInfoDialog::showTab( int i_tab = 0 )
123 IT->setCurrentIndex( i_tab );
127 void MediaInfoDialog::showMetaSaveButton()
129 saveMetaButton->show();
132 void MediaInfoDialog::saveMeta()
135 saveMetaButton->hide();
138 /* Function called on inputChanged-update*/
139 void MediaInfoDialog::update( input_thread_t *p_input )
141 if( !p_input || p_input->b_dead )
151 /* Launch the update in all the panels */
152 vlc_object_hold( p_input );
154 update( input_GetItem(p_input), true, true);
156 vlc_object_release( p_input );
159 void MediaInfoDialog::update( input_item_t *p_item,
164 IP->update( p_item );
167 MP->update( p_item );
168 EMP->update( p_item );
171 ISP->update( p_item );
174 void MediaInfoDialog::clear()
179 if( stats ) ISP->clear();
183 void MediaInfoDialog::close()
187 /* if dialog is closed, revert editing if not saved */
188 if( MP->isInEditMode() )
190 MP->setEditMode( false );
193 if( mainInput == false ) {
198 void MediaInfoDialog::updateButtons( int i_tab )
200 if( MP->isInEditMode() && i_tab == 0 )
201 saveMetaButton->show();
203 saveMetaButton->hide();