X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fqt4%2Fdialogs%2Fmediainfo.cpp;h=d0062c935bbc764f98df3d6855b84178dc470fbd;hb=HEAD;hp=8286fcc196e1a502b8e23382e0bfc094ead160df;hpb=b4465b3c1004dc3817f68b5b686c77346414ae33;p=vlc diff --git a/modules/gui/qt4/dialogs/mediainfo.cpp b/modules/gui/qt4/dialogs/mediainfo.cpp index 8286fcc196..d0062c935b 100644 --- a/modules/gui/qt4/dialogs/mediainfo.cpp +++ b/modules/gui/qt4/dialogs/mediainfo.cpp @@ -1,7 +1,7 @@ /***************************************************************************** * mediainfo.cpp : Information about an item **************************************************************************** - * Copyright (C) 2006-2007 the VideoLAN team + * Copyright (C) 2006-2008 the VideoLAN team * $Id$ * * Authors: Clément Stenac @@ -22,43 +22,48 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. ******************************************************************************/ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include "dialogs/mediainfo.hpp" #include "input_manager.hpp" -#include "dialogs_provider.hpp" + +#include #include #include #include #include +#include -MediaInfoDialog *MediaInfoDialog::instance = NULL; +/* This Dialog has two main modes: + - General Mode that shows the current Played item, and the stats + - Single mode that shows the info on ONE SINGLE Item on the playlist + Please be Careful of not breaking one the modes behaviour... */ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, - input_item_t *_p_item, - bool _mainInput, - bool _stats ) : - QVLCFrame( _p_intf ), mainInput(_mainInput), - stats( _stats ) + input_item_t *p_item ) : + QVLCFrame( _p_intf ) { - i_runs = 0; - p_item = _p_item; - b_cleaned = true; + isMainInputInfo = ( p_item == NULL ); - setWindowTitle( qtr( "Media information" ) ); - resize( 600 , 480 ); + setWindowTitle( qtr( "Media Information" ) ); + setWindowRole( "vlc-media-info" ); /* TabWidgets and Tabs creation */ - IT = new QTabWidget; - MP = new MetaPanel( IT, p_intf ); - IT->addTab( MP, qtr( "&General" ) ); - EMP = new ExtraMetaPanel( IT, p_intf ); - IT->addTab( EMP, qtr( "&Extra Metadata" ) ); - IP = new InfoPanel( IT, p_intf ); - IT->addTab( IP, qtr( "&Codec Details" ) ); - if( stats ) + infoTabW = new QTabWidget; + + MP = new MetaPanel( infoTabW, p_intf ); + infoTabW->addTab( MP, qtr( "&General" ) ); + EMP = new ExtraMetaPanel( infoTabW, p_intf ); + infoTabW->addTab( EMP, qtr( "&Extra Metadata" ) ); + IP = new InfoPanel( infoTabW, p_intf ); + infoTabW->addTab( IP, qtr( "&Codec Details" ) ); + if( isMainInputInfo ) { - ISP = new InputStatsPanel( IT, p_intf ); - IT->addTab( ISP, qtr( "&Statistics" ) ); + ISP = new InputStatsPanel( infoTabW, p_intf ); + infoTabW->addTab( ISP, qtr( "&Statistics" ) ); } QGridLayout *layout = new QGridLayout( this ); @@ -69,10 +74,10 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, QPushButton *closeButton = new QPushButton( qtr( "&Close" ) ); closeButton->setDefault( true ); + QLabel *uriLabel = new QLabel( qtr( "Location:" ) ); uriLine = new QLineEdit; - QLabel *uriLabel = new QLabel( qtr( "Location :" ) ); - layout->addWidget( IT, 0, 0, 1, 8 ); + layout->addWidget( infoTabW, 0, 0, 1, 8 ); layout->addWidget( uriLabel, 1, 0, 1, 1 ); layout->addWidget( uriLine, 1, 1, 1, 7 ); layout->addWidget( saveMetaButton, 2, 6 ); @@ -81,93 +86,93 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, BUTTONACT( closeButton, close() ); /* The tabs buttons are shown in the main dialog for space and cosmetics */ - CONNECT( saveMetaButton, clicked(), this, saveMeta() ); + BUTTONACT( saveMetaButton, saveMeta() ); /* Let the MetaData Panel update the URI */ - CONNECT( MP, uriSet( QString ), uriLine, setText( QString ) ); - CONNECT( MP, editing(), this, showMetaSaveButton() ); + CONNECT( MP, uriSet( const QString& ), this, updateURI( const QString& ) ); + CONNECT( MP, editing(), saveMetaButton, show() ); + + /* Display the buttonBar according to the Tab selected */ + CONNECT( infoTabW, currentChanged( int ), this, updateButtons( int ) ); + + /* If using the General Mode */ + if( isMainInputInfo ) + { + msg_Dbg( p_intf, "Using a general info windows" ); + /** + * Connects on the various signals of input_Manager + * For the currently playing element + **/ + DCONNECT( THEMIM->getIM(), infoChanged( input_item_t* ), + IP, update( input_item_t* ) ); + DCONNECT( THEMIM->getIM(), currentMetaChanged( input_item_t* ), + MP, update( input_item_t* ) ); + DCONNECT( THEMIM->getIM(), currentMetaChanged( input_item_t* ), + EMP, update( input_item_t* ) ); + DCONNECT( THEMIM->getIM(), statisticsUpdated( input_item_t* ), + ISP, update( input_item_t* ) ); + + if( THEMIM->getInput() ) + p_item = input_GetItem( THEMIM->getInput() ); + } + else + msg_Dbg( p_intf, "Using an item specific info windows" ); - CONNECT( IT, currentChanged( int ), this, updateButtons( int ) ); + /* Call update at start, so info is filled up at begginning */ + if( p_item ) + updateAllTabs( p_item ); - CONNECT( THEMIM, inputChanged( input_thread_t * ), this, update( input_thread_t * ) ); - /* Call update by hand, so info is shown from current item too */ - update( input_GetItem(THEMIM->getInput()), true, true ); + readSettings( "Mediainfo", QSize( 600 , 480 ) ); } MediaInfoDialog::~MediaInfoDialog() { - writeSettings( "mediainfo" ); + writeSettings( "Mediainfo" ); } void MediaInfoDialog::showTab( int i_tab = 0 ) { - IT->setCurrentIndex( i_tab ); + infoTabW->setCurrentIndex( i_tab ); show(); } -void MediaInfoDialog::showMetaSaveButton() -{ - saveMetaButton->show(); -} - void MediaInfoDialog::saveMeta() { MP->saveMeta(); saveMetaButton->hide(); } -/* Function called on inputChanged-update*/ -void MediaInfoDialog::update( input_thread_t *p_input ) +void MediaInfoDialog::updateAllTabs( input_item_t *p_item ) { - if( !p_input || p_input->b_dead ) - { - if( !b_cleaned ) - { - clear(); - b_cleaned = true; - } - return; - } - - /* Launch the update in all the panels */ - vlc_object_yield( p_input ); - - update( input_GetItem(p_input), true, true); - - vlc_object_release( p_input ); -} + IP->update( p_item ); + MP->update( p_item ); + EMP->update( p_item ); -void MediaInfoDialog::update( input_item_t *p_item, - bool update_info, - bool update_meta ) -{ - if( update_info ) - IP->update( p_item ); - if( update_meta ) - { - MP->update( p_item ); - EMP->update( p_item ); - } - if( stats ) - ISP->update( p_item ); + if( isMainInputInfo ) ISP->update( p_item ); } -void MediaInfoDialog::clear() +void MediaInfoDialog::clearAllTabs() { IP->clear(); MP->clear(); EMP->clear(); - if( stats ) ISP->clear(); - b_cleaned = true; + + if( isMainInputInfo ) ISP->clear(); } void MediaInfoDialog::close() { - this->toggleVisible(); + hide(); - if( mainInput == false ) { - deleteLater(); + /* if dialog is closed, revert editing if not saved */ + if( MP->isInEditMode() ) + { + MP->setEditMode( false ); + updateButtons( 0 ); } + + if( !isMainInputInfo ) + deleteLater(); } void MediaInfoDialog::updateButtons( int i_tab ) @@ -177,3 +182,20 @@ void MediaInfoDialog::updateButtons( int i_tab ) else saveMetaButton->hide(); } + +void MediaInfoDialog::updateURI( const QString& uri ) +{ + QString location; + + /* If URI points to a local file, show the path instead of the URI */ + char *path = make_path( qtu( uri ) ); + if( path != NULL ) + { + location = qfu( path ); + free( path ); + } + else + location = uri; + + uriLine->setText( location ); +}