Commit 7db11385 authored by Clément Stenac's avatar Clément Stenac

A bit of cleanup in the info stuff

parent 4b94daab
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* $Id$ * $Id$
* *
* Authors: Clément Stenac <zorglub@videolan.org> * Authors: Clément Stenac <zorglub@videolan.org>
* Jean-Baptiste Kempf <jb@videolan.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -29,6 +30,10 @@ ...@@ -29,6 +30,10 @@
#include <QHeaderView> #include <QHeaderView>
#include <QList> #include <QList>
/************************************************************************
* Single panels
************************************************************************/
InputStatsPanel::InputStatsPanel( QWidget *parent, intf_thread_t *_p_intf ) : InputStatsPanel::InputStatsPanel( QWidget *parent, intf_thread_t *_p_intf ) :
QWidget( parent ), p_intf( _p_intf ) QWidget( parent ), p_intf( _p_intf )
{ {
...@@ -39,9 +44,8 @@ InputStatsPanel::~InputStatsPanel() ...@@ -39,9 +44,8 @@ InputStatsPanel::~InputStatsPanel()
{ {
} }
void InputStatsPanel::Update( input_item_t *p_item ) void InputStatsPanel::update( input_item_t *p_item )
{ {
vlc_mutex_lock( &p_item->p_stats->lock ); vlc_mutex_lock( &p_item->p_stats->lock );
#define UPDATE( widget,format, calc... ) \ #define UPDATE( widget,format, calc... ) \
...@@ -75,7 +79,7 @@ void InputStatsPanel::Update( input_item_t *p_item ) ...@@ -75,7 +79,7 @@ void InputStatsPanel::Update( input_item_t *p_item )
vlc_mutex_unlock(& p_item->p_stats->lock ); vlc_mutex_unlock(& p_item->p_stats->lock );
} }
void InputStatsPanel::Clear() void InputStatsPanel::clear()
{ {
} }
...@@ -87,29 +91,30 @@ MetaPanel::MetaPanel( QWidget *parent, intf_thread_t *_p_intf ) : ...@@ -87,29 +91,30 @@ MetaPanel::MetaPanel( QWidget *parent, intf_thread_t *_p_intf ) :
MetaPanel::~MetaPanel() MetaPanel::~MetaPanel()
{ {
} }
void MetaPanel::Update( input_item_t *p_item) void MetaPanel::update( input_item_t *p_item )
{ {
} }
void MetaPanel::Clear() void MetaPanel::clear()
{ {
} }
char* MetaPanel::GetURI() char* MetaPanel::getURI()
{ {
char *URI; char *URI;
return URI; return URI;
} }
char* MetaPanel::GetName() char* MetaPanel::getName()
{ {
char *Name; char *Name;
return Name; return Name;
} }
InfoPanel::InfoPanel( QWidget *parent, intf_thread_t *_p_intf ) : InfoPanel::InfoPanel( QWidget *parent, intf_thread_t *_p_intf ) :
QWidget( parent ), p_intf( _p_intf ) QWidget( parent ), p_intf( _p_intf )
{ {
resize(400, 500); // resize(400, 500);
QGridLayout *layout = new QGridLayout(this); QGridLayout *layout = new QGridLayout(this);
InfoTree = new QTreeWidget(this); InfoTree = new QTreeWidget(this);
QList<QTreeWidgetItem *> items; QList<QTreeWidgetItem *> items;
...@@ -117,15 +122,14 @@ InfoPanel::InfoPanel( QWidget *parent, intf_thread_t *_p_intf ) : ...@@ -117,15 +122,14 @@ InfoPanel::InfoPanel( QWidget *parent, intf_thread_t *_p_intf ) :
layout->addWidget(InfoTree, 0, 0 ); layout->addWidget(InfoTree, 0, 0 );
InfoTree->setColumnCount( 1 ); InfoTree->setColumnCount( 1 );
InfoTree->header()->hide(); InfoTree->header()->hide();
InfoTree->resize(400, 400); // InfoTree->resize(400, 400);
} }
InfoPanel::~InfoPanel() InfoPanel::~InfoPanel()
{ {
} }
void InfoPanel::Update( input_item_t *p_item) void InfoPanel::update( input_item_t *p_item)
{ {
InfoTree->clear(); InfoTree->clear();
QTreeWidgetItem *current_item = NULL; QTreeWidgetItem *current_item = NULL;
...@@ -151,7 +155,53 @@ void InfoPanel::Update( input_item_t *p_item) ...@@ -151,7 +155,53 @@ void InfoPanel::Update( input_item_t *p_item)
} }
} }
void InfoPanel::Clear() void InfoPanel::clear()
{ {
InfoTree->clear();
} }
/***************************************************************************
* Tab widget
***************************************************************************/
InfoTab::InfoTab( QWidget *parent, intf_thread_t *_p_intf, bool _stats ) :
QTabWidget( parent ), stats( _stats ), p_intf( _p_intf )
{
// setGeometry(0, 0, 400, 500);
MP = new MetaPanel(NULL, p_intf);
addTab(MP, qtr("&Meta"));
if( stats )
{
ISP = new InputStatsPanel( NULL, p_intf );
addTab(ISP, qtr("&Stats"));
}
IP = new InfoPanel(NULL, p_intf);
addTab(IP, qtr("&Info"));
}
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 );
if( stats )
ISP->update( p_item );
}
void InfoTab::clear()
{
IP->clear();
MP->clear();
if( stats ) ISP->clear();
}
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <vlc_meta.h> #include <vlc_meta.h>
#include <QWidget> #include <QWidget>
#include <QTabWidget>
#include "ui/input_stats.h" #include "ui/input_stats.h"
...@@ -44,10 +44,9 @@ public: ...@@ -44,10 +44,9 @@ public:
private: private:
intf_thread_t *p_intf; intf_thread_t *p_intf;
Ui::InputStats ui; Ui::InputStats ui;
public slots: public slots:
void Update( input_item_t * ); void update( input_item_t * );
void Clear(); void clear();
}; };
class MetaPanel: public QWidget class MetaPanel: public QWidget
...@@ -60,11 +59,11 @@ private: ...@@ -60,11 +59,11 @@ private:
intf_thread_t *p_intf; intf_thread_t *p_intf;
public slots: public slots:
void Update( input_item_t * ); void update( input_item_t * );
void Clear(); void clear();
char* GetURI(); char* getURI();
char* GetName(); char* getName();
}; };
class InfoPanel: public QWidget class InfoPanel: public QWidget
...@@ -78,8 +77,25 @@ private: ...@@ -78,8 +77,25 @@ private:
QTreeWidget *InfoTree; QTreeWidget *InfoTree;
public slots: 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;
int i_runs;
}; };
#endif #endif
...@@ -30,17 +30,18 @@ ...@@ -30,17 +30,18 @@
#include "components/infopanels.hpp" #include "components/infopanels.hpp"
#include "qt4.hpp" #include "qt4.hpp"
/* This is the dialog Windows */ static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *param );
StreamInfoDialog *StreamInfoDialog::instance = NULL; StreamInfoDialog *StreamInfoDialog::instance = NULL;
StreamInfoDialog::StreamInfoDialog( intf_thread_t *_p_intf, bool _main_input ) : StreamInfoDialog::StreamInfoDialog( intf_thread_t *_p_intf ) :QVLCFrame( _p_intf )
QVLCFrame( _p_intf ), main_input( _main_input )
{ {
i_runs = 0;
setWindowTitle( _("Stream information" ) ); setWindowTitle( _("Stream information" ) );
QGridLayout *layout = new QGridLayout(this); QGridLayout *layout = new QGridLayout(this);
setGeometry(0,0,470,550); setGeometry(0,0,470,550);
IT = new InfoTab( this, p_intf) ; IT = new InfoTab( this, p_intf, true ) ;
QPushButton *closeButton = new QPushButton(qtr("&Close")); QPushButton *closeButton = new QPushButton(qtr("&Close"));
layout->addWidget(IT,0,0,1,3); layout->addWidget(IT,0,0,1,3);
layout->addWidget(closeButton,1,2); layout->addWidget(closeButton,1,2);
...@@ -48,50 +49,47 @@ StreamInfoDialog::StreamInfoDialog( intf_thread_t *_p_intf, bool _main_input ) : ...@@ -48,50 +49,47 @@ StreamInfoDialog::StreamInfoDialog( intf_thread_t *_p_intf, bool _main_input ) :
BUTTONACT( closeButton, close() ); BUTTONACT( closeButton, close() );
ON_TIMEOUT( update() ); ON_TIMEOUT( update() );
p_input = NULL; p_input = NULL;
}
void StreamInfoDialog::update() var_AddCallback( THEPL, "item-change", ItemChanged, this );
{
IT->update();
} }
StreamInfoDialog::~StreamInfoDialog() StreamInfoDialog::~StreamInfoDialog()
{ {
var_DelCallback( THEPL, "item-change", ItemChanged, this );
} }
void StreamInfoDialog::close() static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *param )
{ {
this->toggleVisible(); StreamInfoDialog *p_d = (StreamInfoDialog *)param;
p_d->need_update = VLC_TRUE;
return VLC_SUCCESS;
} }
/* This is the tab Widget Inside the windows*/ void StreamInfoDialog::update()
InfoTab::InfoTab( QWidget *parent, intf_thread_t *_p_intf ) :
QTabWidget( parent ), p_intf( _p_intf )
{ {
setGeometry(0, 0, 400, 500); // Timer runs at 150 ms, dont' update more than 2 times per second
i_runs++;
if( i_runs % 3 != 0 ) return;
input_thread_t *p_input = MainInputManager::getInstance( p_intf )->getInput();
if( !p_input || p_input->b_dead )
{
IT->clear();
return;
}
ISP = new InputStatsPanel( NULL, p_intf ); vlc_object_yield( p_input );
MP = new MetaPanel(NULL, p_intf); vlc_mutex_lock( &p_input->input.p_item->lock );
IP = new InfoPanel(NULL, p_intf);
addTab(MP, qtr("&Meta")); IT->update( p_input->input.p_item, need_update, need_update );
addTab(ISP, qtr("&Stats")); need_update = false;
addTab(IP, qtr("&Info"));
}
InfoTab::~InfoTab() vlc_mutex_unlock( &p_input->input.p_item->lock );
{ vlc_object_release( p_input );
} }
void InfoTab::update() void StreamInfoDialog::close()
{ {
if( p_intf ) this->toggleVisible();
p_input = MainInputManager::getInstance( p_intf )->getInput();
if( p_input && !p_input->b_dead )
{
ISP->Update( p_input->input.p_item );
// FIXME should not be updated here
IP->Update( p_input->input.p_item );
}
} }
...@@ -27,45 +27,26 @@ ...@@ -27,45 +27,26 @@
#include <QTabWidget> #include <QTabWidget>
#include <QBoxLayout> #include <QBoxLayout>
class InfoTab;
class InputStatsPanel;
class MetaPanel;
class InfoPanel;
class InfoTab: public QTabWidget
{
Q_OBJECT;
public:
InfoTab( QWidget *, intf_thread_t * );
virtual ~InfoTab();
private:
intf_thread_t *p_intf;
input_thread_t *p_input;
InputStatsPanel *ISP;
MetaPanel *MP;
InfoPanel *IP;
public slots:
void update();
};
class StreamInfoDialog : public QVLCFrame class StreamInfoDialog : public QVLCFrame
{ {
Q_OBJECT; Q_OBJECT;
public: public:
static StreamInfoDialog * getInstance( intf_thread_t *p_intf, bool a ) static StreamInfoDialog * getInstance( intf_thread_t *p_intf )
{ {
if( !instance) if( !instance)
instance = new StreamInfoDialog( p_intf, a ); instance = new StreamInfoDialog( p_intf);
return instance; return instance;
} }
virtual ~StreamInfoDialog(); virtual ~StreamInfoDialog();
bool need_update;
private: private:
StreamInfoDialog( intf_thread_t *, bool ); StreamInfoDialog( intf_thread_t * );
input_thread_t *p_input; input_thread_t *p_input;
InfoTab *IT; InfoTab *IT;
bool main_input;
static StreamInfoDialog *instance; static StreamInfoDialog *instance;
int i_runs;
public slots: public slots:
void update(); void update();
void close(); void close();
......
...@@ -154,7 +154,7 @@ void DialogsProvider::quit() ...@@ -154,7 +154,7 @@ void DialogsProvider::quit()
void DialogsProvider::streaminfoDialog() void DialogsProvider::streaminfoDialog()
{ {
StreamInfoDialog::getInstance( p_intf, true )->toggleVisible(); StreamInfoDialog::getInstance( p_intf )->toggleVisible();
} }
void DialogsProvider::streamingDialog() void DialogsProvider::streamingDialog()
......
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