Commit 4792d566 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt: cleaning of the MediaInfo Dialog mess.

First, assume that the core is correct now (not sure)
Then, rename a few functions and simplify the cases.

NOTA BENE, any commit on MediaInfo or Art needs to be reviewed before commiting.
NB2: any function named update() is forbidden in new commits in Qt code, thanks.
parent 7b001a2b
...@@ -71,7 +71,6 @@ class ArtLabel : public CoverArtLabel ...@@ -71,7 +71,6 @@ class ArtLabel : public CoverArtLabel
public: public:
ArtLabel( QWidget *parent, intf_thread_t *intf ) ArtLabel( QWidget *parent, intf_thread_t *intf )
: CoverArtLabel( parent, VLC_OBJECT( intf ) ) {}; : CoverArtLabel( parent, VLC_OBJECT( intf ) ) {};
virtual ~ArtLabel() {};
void mouseDoubleClickEvent( QMouseEvent *event ) void mouseDoubleClickEvent( QMouseEvent *event )
{ {
THEDP->mediaInfoDialog(); THEDP->mediaInfoDialog();
......
...@@ -41,30 +41,26 @@ MediaInfoDialog *MediaInfoDialog::instance = NULL; ...@@ -41,30 +41,26 @@ MediaInfoDialog *MediaInfoDialog::instance = NULL;
Please be Careful of not breaking one the modes behaviour... */ Please be Careful of not breaking one the modes behaviour... */
MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf,
input_item_t *_p_item, input_item_t *p_item ) :
bool _mainInput, QVLCFrame( _p_intf )
bool _stats ) :
QVLCFrame( _p_intf ), mainInput(_mainInput),
stats( _stats )
{ {
p_item = _p_item; isMainInputInfo = ( p_item == NULL );
b_cleaned = true;
i_runs = 0;
setWindowTitle( qtr( "Media Information" ) ); setWindowTitle( qtr( "Media Information" ) );
/* TabWidgets and Tabs creation */ /* TabWidgets and Tabs creation */
IT = new QTabWidget; infoTabW = new QTabWidget;
MP = new MetaPanel( IT, p_intf );
IT->addTab( MP, qtr( "&General" ) ); MP = new MetaPanel( infoTabW, p_intf );
EMP = new ExtraMetaPanel( IT, p_intf ); infoTabW->addTab( MP, qtr( "&General" ) );
IT->addTab( EMP, qtr( "&Extra Metadata" ) ); EMP = new ExtraMetaPanel( infoTabW, p_intf );
IP = new InfoPanel( IT, p_intf ); infoTabW->addTab( EMP, qtr( "&Extra Metadata" ) );
IT->addTab( IP, qtr( "&Codec Details" ) ); IP = new InfoPanel( infoTabW, p_intf );
if( stats ) infoTabW->addTab( IP, qtr( "&Codec Details" ) );
if( isMainInputInfo )
{ {
ISP = new InputStatsPanel( IT, p_intf ); ISP = new InputStatsPanel( infoTabW, p_intf );
IT->addTab( ISP, qtr( "&Statistics" ) ); infoTabW->addTab( ISP, qtr( "&Statistics" ) );
} }
QGridLayout *layout = new QGridLayout( this ); QGridLayout *layout = new QGridLayout( this );
...@@ -75,10 +71,10 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, ...@@ -75,10 +71,10 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf,
QPushButton *closeButton = new QPushButton( qtr( "&Close" ) ); QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
closeButton->setDefault( true ); 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( uriLabel, 1, 0, 1, 1 );
layout->addWidget( uriLine, 1, 1, 1, 7 ); layout->addWidget( uriLine, 1, 1, 1, 7 );
layout->addWidget( saveMetaButton, 2, 6 ); layout->addWidget( saveMetaButton, 2, 6 );
...@@ -91,24 +87,23 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, ...@@ -91,24 +87,23 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf,
/* Let the MetaData Panel update the URI */ /* Let the MetaData Panel update the URI */
CONNECT( MP, uriSet( QString ), uriLine, setText( QString ) ); CONNECT( MP, uriSet( QString ), uriLine, setText( QString ) );
CONNECT( MP, editing(), this, showMetaSaveButton() ); CONNECT( MP, editing(), saveMetaButton, show() );
CONNECT( IT, currentChanged( int ), this, updateButtons( int ) ); CONNECT( infoTabW, currentChanged( int ), this, updateButtons( int ) );
/* If using the General Mode */ /* If using the General Mode */
if( !p_item ) if( isMainInputInfo )
{ {
msg_Dbg( p_intf, "Using a general windows" ); msg_Dbg( p_intf, "Using a general info windows" );
CONNECT( THEMIM, inputChanged( input_thread_t * ),
this, update( input_thread_t * ) );
if( THEMIM->getInput() ) if( THEMIM->getInput() )
p_item = input_GetItem( THEMIM->getInput() ); p_item = input_GetItem( THEMIM->getInput() );
} }
else
msg_Dbg( p_intf, "Using an item specific info windows" );
/* Call update by hand, so info is shown from current item too */ /* Call update at start, so info is shown for a running input */
if( p_item ) if( p_item )
update( p_item, true, true ); updateAllTabs( p_item );
readSettings( "Mediainfo", QSize( 600 , 480 ) ); readSettings( "Mediainfo", QSize( 600 , 480 ) );
} }
...@@ -120,69 +115,37 @@ MediaInfoDialog::~MediaInfoDialog() ...@@ -120,69 +115,37 @@ MediaInfoDialog::~MediaInfoDialog()
void MediaInfoDialog::showTab( int i_tab = 0 ) void MediaInfoDialog::showTab( int i_tab = 0 )
{ {
IT->setCurrentIndex( i_tab ); infoTabW->setCurrentIndex( i_tab );
show(); show();
} }
void MediaInfoDialog::showMetaSaveButton()
{
saveMetaButton->show();
}
void MediaInfoDialog::saveMeta() void MediaInfoDialog::saveMeta()
{ {
MP->saveMeta(); MP->saveMeta();
saveMetaButton->hide(); saveMetaButton->hide();
} }
/* Function called on inputChanged-update*/ void MediaInfoDialog::updateAllTabs( input_item_t *p_item )
void MediaInfoDialog::update( input_thread_t *p_input )
{ {
if( !p_input || p_input->b_dead ) IP->update( p_item );
{ MP->update( p_item );
if( !b_cleaned ) EMP->update( p_item );
{
clear();
b_cleaned = true;
}
return;
}
/* Launch the update in all the panels */
vlc_object_hold( p_input );
update( input_GetItem(p_input), true, true);
vlc_object_release( p_input ); if( isMainInputInfo )
}
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 ); ISP->update( p_item );
} }
void MediaInfoDialog::clear() void MediaInfoDialog::clearAllTabs()
{ {
IP->clear(); IP->clear();
MP->clear(); MP->clear();
EMP->clear(); EMP->clear();
if( stats ) ISP->clear(); if( isMainInputInfo ) ISP->clear();
b_cleaned = true;
} }
void MediaInfoDialog::close() void MediaInfoDialog::close()
{ {
toggleVisible(); hide();
/* if dialog is closed, revert editing if not saved */ /* if dialog is closed, revert editing if not saved */
if( MP->isInEditMode() ) if( MP->isInEditMode() )
...@@ -190,9 +153,9 @@ void MediaInfoDialog::close() ...@@ -190,9 +153,9 @@ void MediaInfoDialog::close()
MP->setEditMode( false ); MP->setEditMode( false );
updateButtons( 0 ); updateButtons( 0 );
} }
if( mainInput == false ) {
if( !isMainInputInfo )
deleteLater(); deleteLater();
}
} }
void MediaInfoDialog::updateButtons( int i_tab ) void MediaInfoDialog::updateButtons( int i_tab )
...@@ -202,3 +165,4 @@ void MediaInfoDialog::updateButtons( int i_tab ) ...@@ -202,3 +165,4 @@ void MediaInfoDialog::updateButtons( int i_tab )
else else
saveMetaButton->hide(); saveMetaButton->hide();
} }
...@@ -29,31 +29,24 @@ ...@@ -29,31 +29,24 @@
#include "components/info_panels.hpp" #include "components/info_panels.hpp"
class QTabWidget; class QTabWidget;
class InfoTab;
class QLineEdit;
class MediaInfoDialog : public QVLCFrame class MediaInfoDialog : public QVLCFrame
{ {
Q_OBJECT; Q_OBJECT;
public: public:
MediaInfoDialog( intf_thread_t *, MediaInfoDialog( intf_thread_t *,
input_item_t *, input_item_t * );
bool stats = true,
bool mainInput = false );
static MediaInfoDialog * getInstance( intf_thread_t *p_intf ) static MediaInfoDialog * getInstance( intf_thread_t *p_intf )
{ {
if( !instance) instance = new MediaInfoDialog( p_intf, if( !instance) instance = new MediaInfoDialog( p_intf, NULL );
NULL,
true,
true );
return instance; return instance;
} }
static void killInstance() static void killInstance()
{ {
if( instance ) delete instance; if( instance ) delete instance;
instance= NULL; instance = NULL;
} }
virtual ~MediaInfoDialog(); virtual ~MediaInfoDialog();
...@@ -64,32 +57,25 @@ public: ...@@ -64,32 +57,25 @@ public:
#endif #endif
private: private:
input_item_t *p_item;
static MediaInfoDialog *instance; static MediaInfoDialog *instance;
bool isMainInputInfo;
bool mainInput; QTabWidget *infoTabW;
bool stats;
bool b_cleaned;
int i_runs;
QTabWidget *IT;
InputStatsPanel *ISP; InputStatsPanel *ISP;
MetaPanel *MP; MetaPanel *MP;
InfoPanel *IP; InfoPanel *IP;
ExtraMetaPanel *EMP; ExtraMetaPanel *EMP;
QPushButton *saveMetaButton; QPushButton *saveMetaButton;
QLineEdit *uriLine;
public slots:
void update( input_thread_t * );
void update( input_item_t *, bool, bool );
private slots: private slots:
void close(); void updateAllTabs( input_item_t * );
void clear(); void clearAllTabs();
virtual void close();
void saveMeta(); void saveMeta();
void showMetaSaveButton();
void updateButtons( int i_tab ); void updateButtons( int i_tab );
}; };
......
...@@ -202,16 +202,16 @@ void InputManager::customEvent( QEvent *event ) ...@@ -202,16 +202,16 @@ void InputManager::customEvent( QEvent *event )
UpdateName(); UpdateName();
break; break;
case MetaChanged_Type: case MetaChanged_Type:
UpdateMeta();
UpdateName(); /* Needed for NowPlaying */ UpdateName(); /* Needed for NowPlaying */
// UpdateMeta(); UpdateArt(); /* Art is part of meta in the core */
UpdateArt();
break; break;
case InfoChanged_Type: case InfoChanged_Type:
// UpdateInfo(); UpdateInfo();
break; break;
case ItemTitleChanged_Type: case ItemTitleChanged_Type:
UpdateNavigation(); UpdateNavigation();
UpdateName(); /* Display the name of the Chapter */ UpdateName(); /* Display the name of the Chapter, if exists */
break; break;
case ItemRateChanged_Type: case ItemRateChanged_Type:
UpdateRate(); UpdateRate();
...@@ -230,11 +230,6 @@ void InputManager::customEvent( QEvent *event ) ...@@ -230,11 +230,6 @@ void InputManager::customEvent( QEvent *event )
} }
} }
void InputManager::UpdateStats()
{
emit statisticsUpdated( input_GetItem( p_input ) );
}
void InputManager::UpdatePosition() void InputManager::UpdatePosition()
{ {
/* Update position */ /* Update position */
...@@ -376,12 +371,27 @@ void InputManager::UpdateVout() ...@@ -376,12 +371,27 @@ void InputManager::UpdateVout()
} }
} }
void InputManager::UpdateArt() inline void InputManager::UpdateArt()
{ {
/* Update Art meta */ /* Update Art meta */
emit artChanged( input_GetItem( p_input ) ); emit artChanged( input_GetItem( p_input ) );
} }
inline void InputManager::UpdateStats()
{
emit statisticsUpdated( input_GetItem( p_input ) );
}
inline void InputManager::UpdateMeta()
{
emit metaChanged( input_GetItem( p_input ) );
}
inline void InputManager::UpdateInfo()
{
emit infoChanged( input_GetItem( p_input ) );
}
/* User update of the slider */ /* User update of the slider */
void InputManager::sliderUpdate( float new_pos ) void InputManager::sliderUpdate( float new_pos )
{ {
......
...@@ -115,6 +115,8 @@ private: ...@@ -115,6 +115,8 @@ private:
void UpdatePosition(); void UpdatePosition();
void UpdateTeletext(); void UpdateTeletext();
void UpdateArt(); void UpdateArt();
void UpdateInfo();
void UpdateMeta();
void UpdateVout(); void UpdateVout();
void UpdateStats(); void UpdateStats();
...@@ -154,9 +156,11 @@ signals: ...@@ -154,9 +156,11 @@ signals:
void chapterChanged( bool ); void chapterChanged( bool );
/// Statistics are updated /// Statistics are updated
void statisticsUpdated( input_item_t* ); void statisticsUpdated( input_item_t* );
void infoChanged( input_item_t* );
void metaChanged( input_item_t* );
void artChanged( input_item_t* );
/// Play/pause status /// Play/pause status
void statusChanged( int ); void statusChanged( int );
void artChanged( input_item_t* );
/// Teletext /// Teletext
void teletextPossible( bool ); void teletextPossible( bool );
void teletextActivated( bool ); void teletextActivated( bool );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment