X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fqt4%2Fdialogs%2Fmediainfo.cpp;h=6994a03c825eb2ee0eda95b30ebabeae9a3a9ddc;hb=4792d5665b894cb162a905cf3ab6182bc3435539;hp=a80b687c7f25d0f536edfe7dfed217b48410a42d;hpb=a2a806fda6a84fb712a4ca194d33d9b2ae7a1ea2;p=vlc diff --git a/modules/gui/qt4/dialogs/mediainfo.cpp b/modules/gui/qt4/dialogs/mediainfo.cpp index a80b687c7f..6994a03c82 100644 --- a/modules/gui/qt4/dialogs/mediainfo.cpp +++ b/modules/gui/qt4/dialogs/mediainfo.cpp @@ -21,59 +21,60 @@ * along with this program; if not, write to the Free Software * 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 "components/infopanels.hpp" #include "input_manager.hpp" -#include "dialogs_provider.hpp" #include #include #include #include -static int ItemChanged( vlc_object_t *p_this, const char *psz_var, - vlc_value_t oldval, vlc_value_t newval, void *param ); MediaInfoDialog *MediaInfoDialog::instance = NULL; -MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, bool _mainInput, - bool _stats ) : - QVLCFrame( _p_intf ), mainInput(_mainInput), - stats( _stats ) +/* 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 ) : + QVLCFrame( _p_intf ) { - i_runs = 0; - p_input = NULL; - b_need_update = true; + isMainInputInfo = ( p_item == NULL ); - setWindowTitle( qtr( "Media information" ) ); - resize( 600 , 480 ); + setWindowTitle( qtr( "Media Information" ) ); /* 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 ); - /* FIXME GNOME/KDE ? */ + /* No need to use a QDialogButtonBox here */ saveMetaButton = new QPushButton( qtr( "&Save Metadata" ) ); saveMetaButton->hide(); QPushButton *closeButton = new QPushButton( qtr( "&Close" ) ); closeButton->setDefault( true ); - uriLine = new QLineEdit; - QLabel *uriLabel = new QLabel( qtr( "Location :" ) ); + QLabel *uriLabel = new QLabel( qtr( "Location:" ) ); + QLineEdit *uriLine = new QLineEdit; - 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 ); @@ -82,38 +83,40 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, bool _mainInput, 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, editMeta() ); + CONNECT( MP, editing(), saveMetaButton, show() ); - CONNECT( IT, currentChanged( int ), this, updateButtons( int ) ); + CONNECT( infoTabW, currentChanged( int ), this, updateButtons( int ) ); - /* Create the main Update function with a time (150ms) */ - if( mainInput ) { - ON_TIMEOUT( update() ); - var_AddCallback( THEPL, "item-change", ItemChanged, this ); + /* If using the General Mode */ + if( isMainInputInfo ) + { + msg_Dbg( p_intf, "Using a general info windows" ); + if( THEMIM->getInput() ) + p_item = input_GetItem( THEMIM->getInput() ); } + else + msg_Dbg( p_intf, "Using an item specific info windows" ); + + /* Call update at start, so info is shown for a running input */ + if( p_item ) + updateAllTabs( p_item ); + + readSettings( "Mediainfo", QSize( 600 , 480 ) ); } MediaInfoDialog::~MediaInfoDialog() { - if( mainInput ) { - var_DelCallback( THEPL, "item-change", ItemChanged, this ); - } - writeSettings( "mediainfo" ); + writeSettings( "Mediainfo" ); } void MediaInfoDialog::showTab( int i_tab = 0 ) { - this->show(); - IT->setCurrentIndex( i_tab ); -} - -void MediaInfoDialog::editMeta() -{ - saveMetaButton->show(); + infoTabW->setCurrentIndex( i_tab ); + show(); } void MediaInfoDialog::saveMeta() @@ -122,84 +125,37 @@ void MediaInfoDialog::saveMeta() saveMetaButton->hide(); } -static int ItemChanged( vlc_object_t *p_this, const char *psz_var, - vlc_value_t oldval, vlc_value_t newval, void *param ) +void MediaInfoDialog::updateAllTabs( input_item_t *p_item ) { - MediaInfoDialog *p_d = (MediaInfoDialog *)param; - p_d->b_need_update = VLC_TRUE; - return VLC_SUCCESS; -} + IP->update( p_item ); + MP->update( p_item ); + EMP->update( p_item ); -void MediaInfoDialog::setInput( input_item_t *p_input ) -{ - clear(); - update( p_input, true, true ); - /* if info is from current input, don't set default to edit, if user opens - * some other item, se default to edit, so it won't be updated to current item metas - * - * This really doesn't seem as clean solution as it could be - */ - input_thread_t *p_current = - MainInputManager::getInstance( p_intf )->getInput(); - MP->setEditMode( ( !p_current || p_current->b_dead || input_GetItem( p_current ) != p_input ) ? - true: false ); -} - -void MediaInfoDialog::update() -{ - /* 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 = - MainInputManager::getInstance( p_intf )->getInput(); - if( !p_input || p_input->b_dead ) - { - clear(); - return; - } - - vlc_object_yield( p_input ); - - update( input_GetItem(p_input), b_need_update, b_need_update ); - b_need_update = false; - - vlc_object_release( p_input ); -} - -void MediaInfoDialog::update( input_item_t *p_item, - bool update_info, - bool update_meta ) -{ - MP->setInput( p_item ); - if( update_info ) - IP->update( p_item ); - if( update_meta ) - { - MP->update( p_item ); - EMP->update( p_item ); - } - if( stats ) + if( isMainInputInfo ) ISP->update( p_item ); } -void MediaInfoDialog::clear() +void MediaInfoDialog::clearAllTabs() { IP->clear(); MP->clear(); EMP->clear(); - if( stats ) ISP->clear(); + 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 ); } - MP->setEditMode( false ); + + if( !isMainInputInfo ) + deleteLater(); } void MediaInfoDialog::updateButtons( int i_tab ) @@ -209,3 +165,4 @@ void MediaInfoDialog::updateButtons( int i_tab ) else saveMetaButton->hide(); } +