1 /*****************************************************************************
2 * mediainfo.cpp : Information about an item
3 ****************************************************************************
4 * Copyright (C) 2006-2008 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 ******************************************************************************/
29 #include "dialogs/mediainfo.hpp"
30 #include "input_manager.hpp"
33 #include <QGridLayout>
37 /* This Dialog has two main modes:
38 - General Mode that shows the current Played item, and the stats
39 - Single mode that shows the info on ONE SINGLE Item on the playlist
40 Please be Careful of not breaking one the modes behaviour... */
42 MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf,
43 input_item_t *p_item ) :
46 isMainInputInfo = ( p_item == NULL );
48 setWindowTitle( qtr( "Media Information" ) );
49 setWindowRole( "vlc-media-info" );
51 /* TabWidgets and Tabs creation */
52 infoTabW = new QTabWidget;
54 MP = new MetaPanel( infoTabW, p_intf );
55 infoTabW->addTab( MP, qtr( "&General" ) );
56 EMP = new ExtraMetaPanel( infoTabW, p_intf );
57 infoTabW->addTab( EMP, qtr( "&Extra Metadata" ) );
58 IP = new InfoPanel( infoTabW, p_intf );
59 infoTabW->addTab( IP, qtr( "&Codec Details" ) );
62 ISP = new InputStatsPanel( infoTabW, p_intf );
63 infoTabW->addTab( ISP, qtr( "&Statistics" ) );
66 QGridLayout *layout = new QGridLayout( this );
68 /* No need to use a QDialogButtonBox here */
69 saveMetaButton = new QPushButton( qtr( "&Save Metadata" ) );
70 saveMetaButton->hide();
71 QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
72 closeButton->setDefault( true );
74 QLabel *uriLabel = new QLabel( qtr( "Location:" ) );
75 QLineEdit *uriLine = new QLineEdit;
77 layout->addWidget( infoTabW, 0, 0, 1, 8 );
78 layout->addWidget( uriLabel, 1, 0, 1, 1 );
79 layout->addWidget( uriLine, 1, 1, 1, 7 );
80 layout->addWidget( saveMetaButton, 2, 6 );
81 layout->addWidget( closeButton, 2, 7 );
83 BUTTONACT( closeButton, close() );
85 /* The tabs buttons are shown in the main dialog for space and cosmetics */
86 BUTTONACT( saveMetaButton, saveMeta() );
88 /* Let the MetaData Panel update the URI */
89 CONNECT( MP, uriSet( const QString& ), uriLine, setText( const QString& ) );
90 CONNECT( MP, editing(), saveMetaButton, show() );
92 /* Display the buttonBar according to the Tab selected */
93 CONNECT( infoTabW, currentChanged( int ), this, updateButtons( int ) );
95 /* If using the General Mode */
98 msg_Dbg( p_intf, "Using a general info windows" );
100 * Connects on the various signals of input_Manager
101 * For the currently playing element
103 CONNECT( THEMIM->getIM(), infoChanged( input_item_t* ),
104 IP, update( input_item_t* ) );
105 CONNECT( THEMIM->getIM(), currentMetaChanged( input_item_t* ),
106 MP, update( input_item_t* ) );
107 CONNECT( THEMIM->getIM(), currentMetaChanged( input_item_t* ),
108 EMP, update( input_item_t* ) );
109 CONNECT( THEMIM->getIM(), statisticsUpdated( input_item_t* ),
110 ISP, update( input_item_t* ) );
112 if( THEMIM->getInput() )
113 p_item = input_GetItem( THEMIM->getInput() );
116 msg_Dbg( p_intf, "Using an item specific info windows" );
118 /* Call update at start, so info is filled up at begginning */
120 updateAllTabs( p_item );
122 readSettings( "Mediainfo", QSize( 600 , 480 ) );
125 MediaInfoDialog::~MediaInfoDialog()
127 writeSettings( "Mediainfo" );
130 void MediaInfoDialog::showTab( int i_tab = 0 )
132 infoTabW->setCurrentIndex( i_tab );
136 void MediaInfoDialog::saveMeta()
139 saveMetaButton->hide();
142 void MediaInfoDialog::updateAllTabs( input_item_t *p_item )
144 IP->update( p_item );
145 MP->update( p_item );
146 EMP->update( p_item );
148 if( isMainInputInfo ) ISP->update( p_item );
151 void MediaInfoDialog::clearAllTabs()
157 if( isMainInputInfo ) ISP->clear();
160 void MediaInfoDialog::close()
164 /* if dialog is closed, revert editing if not saved */
165 if( MP->isInEditMode() )
167 MP->setEditMode( false );
171 if( !isMainInputInfo )
175 void MediaInfoDialog::updateButtons( int i_tab )
177 if( MP->isInEditMode() && i_tab == 0 )
178 saveMetaButton->show();
180 saveMetaButton->hide();