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"
35 #include <QGridLayout>
38 #include <QPushButton>
40 /* This Dialog has two main modes:
41 - General Mode that shows the current Played item, and the stats
42 - Single mode that shows the info on ONE SINGLE Item on the playlist
43 Please be Careful of not breaking one the modes behaviour... */
45 MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf,
46 input_item_t *p_item ) :
49 isMainInputInfo = ( p_item == NULL );
51 setWindowTitle( qtr( "Media Information" ) );
52 setWindowRole( "vlc-media-info" );
54 setWindowFlags( Qt::Window | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint );
56 /* TabWidgets and Tabs creation */
57 infoTabW = new QTabWidget;
59 MP = new MetaPanel( infoTabW, p_intf );
60 infoTabW->addTab( MP, qtr( "&General" ) );
61 EMP = new ExtraMetaPanel( infoTabW, p_intf );
62 infoTabW->addTab( EMP, qtr( "&Metadata" ) );
63 IP = new InfoPanel( infoTabW, p_intf );
64 infoTabW->addTab( IP, qtr( "Co&dec" ) );
67 ISP = new InputStatsPanel( infoTabW, p_intf );
68 infoTabW->addTab( ISP, qtr( "S&tatistics" ) );
71 QGridLayout *layout = new QGridLayout( this );
73 /* No need to use a QDialogButtonBox here */
74 saveMetaButton = new QPushButton( qtr( "&Save Metadata" ) );
75 saveMetaButton->hide();
76 QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
77 closeButton->setDefault( true );
79 QLabel *uriLabel = new QLabel( qtr( "Location:" ) );
80 uriLine = new QLineEdit;
81 uriLine->setReadOnly( true );
83 layout->addWidget( infoTabW, 0, 0, 1, 8 );
84 layout->addWidget( uriLabel, 1, 0, 1, 1 );
85 layout->addWidget( uriLine, 1, 1, 1, 7 );
86 layout->addWidget( saveMetaButton, 2, 6 );
87 layout->addWidget( closeButton, 2, 7 );
89 BUTTONACT( closeButton, close() );
91 /* The tabs buttons are shown in the main dialog for space and cosmetics */
92 BUTTONACT( saveMetaButton, saveMeta() );
94 /* Let the MetaData Panel update the URI */
95 CONNECT( MP, uriSet( const QString& ), this, updateURI( const QString& ) );
96 CONNECT( MP, editing(), saveMetaButton, show() );
98 /* Display the buttonBar according to the Tab selected */
99 CONNECT( infoTabW, currentChanged( int ), this, updateButtons( int ) );
101 /* If using the General Mode */
102 if( isMainInputInfo )
104 msg_Dbg( p_intf, "Using a general info windows" );
106 * Connects on the various signals of input_Manager
107 * For the currently playing element
109 DCONNECT( THEMIM->getIM(), infoChanged( input_item_t* ),
110 IP, update( input_item_t* ) );
111 DCONNECT( THEMIM->getIM(), currentMetaChanged( input_item_t* ),
112 MP, update( input_item_t* ) );
113 DCONNECT( THEMIM->getIM(), currentMetaChanged( input_item_t* ),
114 EMP, update( input_item_t* ) );
115 DCONNECT( THEMIM->getIM(), statisticsUpdated( input_item_t* ),
116 ISP, update( input_item_t* ) );
118 if( THEMIM->getInput() )
119 p_item = input_GetItem( THEMIM->getInput() );
122 msg_Dbg( p_intf, "Using an item specific info windows" );
124 /* Call update at start, so info is filled up at begginning */
126 updateAllTabs( p_item );
128 readSettings( "Mediainfo", QSize( 600 , 480 ) );
131 MediaInfoDialog::~MediaInfoDialog()
133 writeSettings( "Mediainfo" );
136 void MediaInfoDialog::showTab( int i_tab = 0 )
138 infoTabW->setCurrentIndex( i_tab );
142 void MediaInfoDialog::saveMeta()
145 saveMetaButton->hide();
148 void MediaInfoDialog::updateAllTabs( input_item_t *p_item )
150 IP->update( p_item );
151 MP->update( p_item );
152 EMP->update( p_item );
154 if( isMainInputInfo ) ISP->update( p_item );
157 void MediaInfoDialog::clearAllTabs()
163 if( isMainInputInfo ) ISP->clear();
166 void MediaInfoDialog::close()
170 /* if dialog is closed, revert editing if not saved */
171 if( MP->isInEditMode() )
173 MP->setEditMode( false );
177 if( !isMainInputInfo )
181 void MediaInfoDialog::updateButtons( int i_tab )
183 if( MP->isInEditMode() && i_tab == 0 )
184 saveMetaButton->show();
186 saveMetaButton->hide();
189 void MediaInfoDialog::updateURI( const QString& uri )
193 /* If URI points to a local file, show the path instead of the URI */
194 char *path = make_path( qtu( uri ) );
197 location = qfu( path );
203 uriLine->setText( location );