X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fqt4%2Fdialogs%2Fmediainfo.cpp;h=cf7ebbba3772229931ba9556390ff7b9ae4ea0db;hb=df10d15df6fff2414f8d65c09eabc8cd7d291bfe;hp=b7ae592de4361d36ed4e08b02ab49d08ae0c412e;hpb=f15e3d7d656dbea29926b7c72092c1c84f0eb212;p=vlc diff --git a/modules/gui/qt4/dialogs/mediainfo.cpp b/modules/gui/qt4/dialogs/mediainfo.cpp index b7ae592de4..cf7ebbba37 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 the VideoLAN team + * Copyright (C) 2006-2007 the VideoLAN team * $Id$ * * Authors: Clément Stenac @@ -19,81 +19,206 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ - -#include -#include + * 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 "util/qvlcframe.hpp" -#include "components/infopanels.hpp" -#include "qt4.hpp" -static int ItemChanged( vlc_object_t *p_this, const char *psz_var, - vlc_value_t oldval, vlc_value_t newval, void *param ); +#include +#include +#include +#include + MediaInfoDialog *MediaInfoDialog::instance = NULL; -MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf ) :QVLCFrame( _p_intf ) +/* 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 ) { + p_item = _p_item; + b_cleaned = true; i_runs = 0; - p_input = NULL; - setWindowTitle( qtr( "Media information" ) ); + setWindowTitle( qtr( "Media Information" ) ); + resize( 600 , 480 ); + + /* 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 ) + { + ISP = new InputStatsPanel( IT, p_intf ); + IT->addTab( ISP, qtr( "&Statistics" ) ); + } + + QGridLayout *layout = new QGridLayout( this ); - QGridLayout *layout = new QGridLayout(this); - IT = new InfoTab( this, p_intf, true ) ; - QPushButton *closeButton = new QPushButton(qtr("&Close")); + /* No need to use a QDialogButtonBox here */ + saveMetaButton = new QPushButton( qtr( "&Save Metadata" ) ); + saveMetaButton->hide(); + QPushButton *closeButton = new QPushButton( qtr( "&Close" ) ); + closeButton->setDefault( true ); - layout->addWidget(IT,0,0,1,3); - layout->addWidget(closeButton,1,2); + uriLine = new QLineEdit; + QLabel *uriLabel = new QLabel( qtr( "Location:" ) ); + + layout->addWidget( IT, 0, 0, 1, 8 ); + layout->addWidget( uriLabel, 1, 0, 1, 1 ); + layout->addWidget( uriLine, 1, 1, 1, 7 ); + layout->addWidget( saveMetaButton, 2, 6 ); + layout->addWidget( closeButton, 2, 7 ); BUTTONACT( closeButton, close() ); - ON_TIMEOUT( update() ); - var_AddCallback( THEPL, "item-change", ItemChanged, this ); - readSettings( "mediainfo" , QSize( 500, 450 ) ); + /* The tabs buttons are shown in the main dialog for space and cosmetics */ + CONNECT( saveMetaButton, clicked(), this, saveMeta() ); + + /* Let the MetaData Panel update the URI */ + CONNECT( MP, uriSet( QString ), uriLine, setText( QString ) ); + CONNECT( MP, editing(), this, showMetaSaveButton() ); + + CONNECT( IT, currentChanged( int ), this, updateButtons( int ) ); + + /* If using the General Mode */ + if( !p_item ) + { + msg_Dbg( p_intf, "Using a general windows" ); + CONNECT( THEMIM, inputChanged( input_thread_t * ), + this, update( input_thread_t * ) ); + + if( THEMIM->getInput() ) + p_item = input_GetItem( THEMIM->getInput() ); + } + + /* Call update by hand, so info is shown from current item too */ + if( p_item ) + update( p_item, true, true ); + + if( stats ) + ON_TIMEOUT( updateOnTimeOut() ); } MediaInfoDialog::~MediaInfoDialog() { - var_DelCallback( THEPL, "item-change", ItemChanged, this ); writeSettings( "mediainfo" ); } -static int ItemChanged( vlc_object_t *p_this, const char *psz_var, - vlc_value_t oldval, vlc_value_t newval, void *param ) +void MediaInfoDialog::showTab( int i_tab = 0 ) { - MediaInfoDialog *p_d = (MediaInfoDialog *)param; - p_d->need_update = VLC_TRUE; - return VLC_SUCCESS; + IT->setCurrentIndex( i_tab ); + show(); } -void MediaInfoDialog::update() +void MediaInfoDialog::showMetaSaveButton() { - // Timer runs at 150 ms, dont' update more than 2 times per second - i_runs++; - if( i_runs % 3 != 0 ) return; + saveMetaButton->show(); +} + +void MediaInfoDialog::saveMeta() +{ + MP->saveMeta(); + saveMetaButton->hide(); +} - input_thread_t *p_input = MainInputManager::getInstance( p_intf )->getInput(); +/* Function called on inputChanged-update*/ +void MediaInfoDialog::update( input_thread_t *p_input ) +{ if( !p_input || p_input->b_dead ) { - IT->clear(); + if( !b_cleaned ) + { + clear(); + b_cleaned = true; + } return; } + /* Launch the update in all the panels */ vlc_object_yield( p_input ); - vlc_mutex_lock( &p_input->input.p_item->lock ); - IT->update( p_input->input.p_item, need_update, need_update ); - need_update = false; + update( input_GetItem(p_input), true, true); - vlc_mutex_unlock( &p_input->input.p_item->lock ); vlc_object_release( p_input ); } +void MediaInfoDialog::updateOnTimeOut() +{ + /* Timer runs at 150 ms, dont' update more than 2 times per second */ + i_runs++; + if( i_runs % 4 != 0 ) return; + + /* Get Input and clear if non-existant */ + input_thread_t *p_input = THEMIM->getInput(); + + if( p_input && !p_input->b_dead ) + { + vlc_object_yield( p_input ); + update( input_GetItem(p_input), false, false); + vlc_object_release( p_input ); + } +} + +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 ); +} + +void MediaInfoDialog::clear() +{ + IP->clear(); + MP->clear(); + EMP->clear(); + if( stats ) ISP->clear(); + b_cleaned = true; +} + void MediaInfoDialog::close() { - this->toggleVisible(); + toggleVisible(); + + /* if dialog is closed, revert editing if not saved */ + if( MP->isInEditMode() ) + { + MP->setEditMode( false ); + updateButtons( 0 ); + } + if( mainInput == false ) { + deleteLater(); + } +} + +void MediaInfoDialog::updateButtons( int i_tab ) +{ + if( MP->isInEditMode() && i_tab == 0 ) + saveMetaButton->show(); + else + saveMetaButton->hide(); }