Commit 05d26437 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt4 - MediaInfo, move the tabWidget to the Dialog class and remove it from components.

parent bad8f53f
...@@ -366,49 +366,3 @@ void InfoPanel::clear() ...@@ -366,49 +366,3 @@ void InfoPanel::clear()
InfoTree->clear(); InfoTree->clear();
} }
/***************************************************************************
* Tab widget
***************************************************************************/
InfoTab::InfoTab( QWidget *parent, intf_thread_t *_p_intf, bool _stats ) :
QTabWidget( parent ), stats( _stats ), p_intf( _p_intf )
{
MP = new MetaPanel( NULL, p_intf );
addTab( MP, qtr( "&General" ) );
EMP = new ExtraMetaPanel( NULL, p_intf );
addTab( EMP, qtr( "&Extra Metadata" ) );
IP = new InfoPanel( NULL, p_intf);
addTab(IP, qtr("&Codec Details"));
if( stats )
{
ISP = new InputStatsPanel( NULL, p_intf );
addTab(ISP, qtr("&Stats"));
}
}
InfoTab::~InfoTab()
{
}
/* This function should be called approximately twice a second.
* p_item should be locked
* Stats will always be updated */
void InfoTab::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 InfoTab::clear()
{
IP->clear();
MP->clear();
EMP->clear();
if( stats ) ISP->clear();
}
...@@ -138,23 +138,4 @@ public slots: ...@@ -138,23 +138,4 @@ public slots:
void update( input_item_t * ); void update( input_item_t * );
void clear(); void clear();
}; };
class InfoTab: public QTabWidget
{
Q_OBJECT;
public:
InfoTab( QWidget *, intf_thread_t *, bool );
virtual ~InfoTab();
void update( input_item_t *, bool, bool );
void clear();
private:
bool stats;
intf_thread_t *p_intf;
InputStatsPanel *ISP;
MetaPanel *MP;
InfoPanel *IP;
ExtraMetaPanel *EMP;
int i_runs;
};
#endif #endif
...@@ -37,8 +37,10 @@ static int ItemChanged( vlc_object_t *p_this, const char *psz_var, ...@@ -37,8 +37,10 @@ static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *param ); vlc_value_t oldval, vlc_value_t newval, void *param );
MediaInfoDialog *MediaInfoDialog::instance = NULL; MediaInfoDialog *MediaInfoDialog::instance = NULL;
MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, bool _mainInput ) : MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, bool _mainInput,
QVLCFrame( _p_intf ), mainInput(_mainInput) bool _stats ) :
QVLCFrame( _p_intf ), mainInput(_mainInput),
stats( _stats )
{ {
i_runs = 0; i_runs = 0;
p_input = NULL; p_input = NULL;
...@@ -47,17 +49,30 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, bool _mainInput ) : ...@@ -47,17 +49,30 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, bool _mainInput ) :
resize( 600 , 450 ); resize( 600 , 450 );
QGridLayout *layout = new QGridLayout(this); QGridLayout *layout = new QGridLayout(this);
IT = new InfoTab( this, p_intf, true ) ;
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("&Stats"));
}
QPushButton *closeButton = new QPushButton(qtr("&Close")); QPushButton *closeButton = new QPushButton(qtr("&Close"));
closeButton->setDefault( true ); closeButton->setDefault( true );
layout->addWidget(IT,0,0,1,3); layout->addWidget( IT, 0, 0, 1, 3);
layout->addWidget(closeButton,1,2); layout->addWidget(closeButton,1,2);
BUTTONACT( closeButton, close() ); BUTTONACT( closeButton, close() );
ON_TIMEOUT( update() );
if( mainInput ) { if( mainInput ) {
ON_TIMEOUT( update() );
var_AddCallback( THEPL, "item-change", ItemChanged, this ); var_AddCallback( THEPL, "item-change", ItemChanged, this );
} }
} }
...@@ -86,36 +101,61 @@ static int ItemChanged( vlc_object_t *p_this, const char *psz_var, ...@@ -86,36 +101,61 @@ static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
void MediaInfoDialog::setInput(input_item_t *p_input) void MediaInfoDialog::setInput(input_item_t *p_input)
{ {
IT->clear(); clear();
vlc_mutex_lock( &p_input->lock ); vlc_mutex_lock( &p_input->lock );
IT->update( p_input, true, true ); update( p_input, true, true );
vlc_mutex_unlock( &p_input->lock ); vlc_mutex_unlock( &p_input->lock );
} }
void MediaInfoDialog::update() void MediaInfoDialog::update()
{ {
msg_Dbg( p_intf, "updating" );
/* Timer runs at 150 ms, dont' update more than 2 times per second */ /* Timer runs at 150 ms, dont' update more than 2 times per second */
if( i_runs % 3 != 0 ) return; if( i_runs % 3 != 0 ) return;
i_runs++; i_runs++;
/* Get Input and clear if non-existant */
input_thread_t *p_input = input_thread_t *p_input =
MainInputManager::getInstance( p_intf )->getInput(); MainInputManager::getInstance( p_intf )->getInput();
if( !p_input || p_input->b_dead ) if( !p_input || p_input->b_dead )
{ {
IT->clear(); clear();
return; return;
} }
vlc_object_yield( p_input ); vlc_object_yield( p_input );
vlc_mutex_lock( &input_GetItem(p_input)->lock ); vlc_mutex_lock( &input_GetItem(p_input)->lock );
IT->update( input_GetItem(p_input), need_update, need_update ); update( input_GetItem(p_input), need_update, need_update );
need_update = false; need_update = false;
vlc_mutex_unlock( &input_GetItem(p_input)->lock ); vlc_mutex_unlock( &input_GetItem(p_input)->lock );
vlc_object_release( p_input ); 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();
}
void MediaInfoDialog::close() void MediaInfoDialog::close()
{ {
this->toggleVisible(); this->toggleVisible();
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#define _MEDIAINFO_DIALOG_H_ #define _MEDIAINFO_DIALOG_H_
#include "util/qvlcframe.hpp" #include "util/qvlcframe.hpp"
#include "components/infopanels.hpp"
class QTabWidget; class QTabWidget;
class InfoTab; class InfoTab;
...@@ -34,11 +35,12 @@ class MediaInfoDialog : public QVLCFrame ...@@ -34,11 +35,12 @@ class MediaInfoDialog : public QVLCFrame
{ {
Q_OBJECT; Q_OBJECT;
public: public:
MediaInfoDialog( intf_thread_t *, bool mainInput = false ); MediaInfoDialog( intf_thread_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) if( !instance)
instance = new MediaInfoDialog( p_intf, true); instance = new MediaInfoDialog( p_intf, true, true );
return instance; return instance;
} }
static void killInstance() static void killInstance()
...@@ -53,13 +55,20 @@ public: ...@@ -53,13 +55,20 @@ public:
void setInput( input_item_t * ); void setInput( input_item_t * );
private: private:
input_thread_t *p_input; input_thread_t *p_input;
InfoTab *IT; QTabWidget *IT;
static MediaInfoDialog *instance; static MediaInfoDialog *instance;
int i_runs; int i_runs;
bool mainInput; bool mainInput;
bool stats;
InputStatsPanel *ISP;
MetaPanel *MP;
InfoPanel *IP;
ExtraMetaPanel *EMP;
public slots: public slots:
void update(); void update();
void update( input_item_t *, bool, bool );
void close(); void close();
void clear();
}; };
#endif #endif
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