Commit 1b168781 authored by zorglub's avatar zorglub

* Split apart gui and input management

* Functional stats panel
parent e5ed4c8e
......@@ -45,6 +45,26 @@ void InputStatsPanel::Update( input_item_t *p_item )
{ QString str; ui.widget->setText( str.sprintf( format, ## calc ) ); }
UPDATE( read_text, "%8.0f kB", (float)(p_item->p_stats->i_read_bytes)/1000);
UPDATE( input_bitrate_text, "%6.0f kb/s", (float)(p_item->p_stats->f_input_bitrate * 8000 ));
UPDATE( demuxed_text, "%8.0f kB", (float)(p_item->p_stats->i_demux_read_bytes)/1000 );
UPDATE( stream_bitrate_text, "%6.0f kb/s", (float)(p_item->p_stats->f_demux_bitrate * 8000 ));
/* Video */
UPDATE( vdecoded_text, "%5i", p_item->p_stats->i_decoded_video );
UPDATE( vdisplayed_text, "%5i", p_item->p_stats->i_displayed_pictures );
UPDATE( vlost_frames, "%5i", p_item->p_stats->i_lost_pictures );
/* Sout */
UPDATE( sent_text, "%5i", p_item->p_stats->i_sent_packets );
UPDATE( sent_bytes_text, "%8.0f kB",
(float)(p_item->p_stats->i_sent_bytes)/1000 );
UPDATE( send_bitrate_text, "%6.0f kb/s",
(float)(p_item->p_stats->f_send_bitrate*8)*1000 );
/* Audio*/
UPDATE( adecoded_text, "%5i", p_item->p_stats->i_decoded_audio );
UPDATE( aplayed_text, "%5i", p_item->p_stats->i_played_abuffers );
UPDATE( alost_text, "%5i", p_item->p_stats->i_lost_abuffers );
vlc_mutex_unlock(& p_item->p_stats->lock );
}
......@@ -127,7 +127,6 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) :
current_item->setData( 0, Qt::UserRole,
qVariantFromValue( data ) );
addTopLevelItem( current_item );
//fprintf( stderr, "Adding %s\n", current_item->text(0).toLatin1().data() );
break;
case CONFIG_SUBCATEGORY:
if( p_item->i_value == -1 ) break;
......@@ -507,7 +506,6 @@ void PrefsPanel::setAdvanced( bool adv )
{
if( (*i)->isAdvanced() )
{
fprintf( stderr, "Showing \n" );
if( !advanced ) some_hidden = true;
(*i)->setVisible( advanced );
}
......
......@@ -43,7 +43,6 @@ class PrefsDialog : public QVLCFrame
public:
static PrefsDialog * getInstance( intf_thread_t *_p_intf )
{
fprintf( stderr, "%p\n", _p_intf );
if( !instance )
{
instance = new PrefsDialog( _p_intf );
......
......@@ -20,6 +20,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/
#include "input_manager.hpp"
#include "dialogs/streaminfo.hpp"
#include "dialogs_provider.hpp"
#include "util/qvlcframe.hpp"
......@@ -28,18 +29,22 @@
StreamInfoDialog *StreamInfoDialog::instance = NULL;
StreamInfoDialog::StreamInfoDialog( intf_thread_t *_p_intf ) :
QVLCFrame( p_intf )
StreamInfoDialog::StreamInfoDialog( intf_thread_t *_p_intf, bool _main_input ) :
QVLCFrame( _p_intf ), main_input( _main_input )
{
setWindowTitle( _("Stream information" ) );
InputStatsPanel *ISP = new InputStatsPanel( this, p_intf );
ISP = new InputStatsPanel( this, p_intf );
connect( DialogsProvider::getInstance(NULL)->fixed_timer,
SIGNAL( timeout() ), this, SLOT(update() ) );
p_input = NULL;
}
void StreamInfoDialog::update()
{
fprintf( stderr, "timer\n");
if( main_input )
p_input = MainInputManager::getInstance( p_intf )->getInput();
if( p_input && !p_input->b_dead )
ISP->Update( p_input->input.p_item );
}
StreamInfoDialog::~StreamInfoDialog()
......
......@@ -25,20 +25,24 @@
#include "util/qvlcframe.hpp"
class InputStatsPanel;
class StreamInfoDialog : public QVLCFrame
{
Q_OBJECT;
public:
static StreamInfoDialog * getInstance( intf_thread_t *p_intf )
static StreamInfoDialog * getInstance( intf_thread_t *p_intf, bool a )
{
if( !instance)
instance = new StreamInfoDialog( p_intf );
instance = new StreamInfoDialog( p_intf, a );
return instance;
}
virtual ~StreamInfoDialog();
private:
StreamInfoDialog( intf_thread_t * );
intf_thread_t *p_intf;
StreamInfoDialog( intf_thread_t *, bool );
input_thread_t *p_input;
InputStatsPanel *ISP;
bool main_input;
static StreamInfoDialog *instance;
public slots:
void update();
......
......@@ -37,7 +37,7 @@ DialogsProvider::DialogsProvider( intf_thread_t *_p_intf ) :
// idle_timer->start( 0 );
fixed_timer = new QTimer( this );
fixed_timer->start( 100 /* milliseconds */ );
fixed_timer->start( 150 /* milliseconds */ );
}
DialogsProvider::~DialogsProvider()
......@@ -90,7 +90,7 @@ void DialogsProvider::openDialog( int i_dialog )
void DialogsProvider::streaminfoDialog()
{
StreamInfoDialog::getInstance( p_intf )->toggleVisible();
StreamInfoDialog::getInstance( p_intf, true )->toggleVisible();
}
void DialogsProvider::prefsDialog()
......
......@@ -25,6 +25,10 @@
#include "dialogs_provider.hpp"
#include "qt4.hpp"
/**********************************************************************
* InputManager implementation
**********************************************************************/
InputManager::InputManager( QObject *parent, intf_thread_t *_p_intf) :
QObject( parent ), p_intf( _p_intf )
{
......@@ -104,3 +108,50 @@ void InputManager::sliderUpdate( float new_pos )
if( p_input && !p_input->b_die && !p_input->b_dead )
var_SetFloat( p_input, "position", new_pos );
}
/**********************************************************************
* MainInputManager implementation. Wrap an input manager and
* take care of updating the main playlist input
**********************************************************************/
MainInputManager * MainInputManager::instance = NULL;
MainInputManager::MainInputManager( intf_thread_t *_p_intf ) : QObject(NULL),
p_intf( _p_intf )
{
p_input = NULL;
im = new InputManager( this, p_intf );
/* Get timer updates */
connect( DialogsProvider::getInstance(p_intf)->fixed_timer,
SIGNAL(timeout() ), this, SLOT( updateInput() ) );
/* Warn our embedded IM about input changes */
connect( this, SIGNAL( inputChanged( input_thread_t * ) ),
im, SLOT( setInput( input_thread_t * ) ) );
}
void MainInputManager::updateInput()
{
vlc_mutex_lock( &p_intf->change_lock );
if( p_input && p_input->b_dead )
{
vlc_object_release( p_input );
p_input = NULL;
emit inputChanged( NULL );
}
if( !p_input )
{
playlist_t *p_playlist = (playlist_t *) vlc_object_find( p_intf,
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
assert( p_playlist );
PL_LOCK;
p_input = p_playlist->p_input;
if( p_input )
{
vlc_object_yield( p_input );
emit inputChanged( p_input );
}
PL_UNLOCK;
vlc_object_release( p_playlist );
}
vlc_mutex_unlock( &p_intf->change_lock );
}
......@@ -50,5 +50,31 @@ signals:
void statusChanged( int );
};
class MainInputManager : public QObject
{
Q_OBJECT;
public:
static MainInputManager *getInstance( intf_thread_t *_p_intf )
{
if( !instance )
instance = new MainInputManager( _p_intf );
return instance;
}
input_thread_t *getInput() { return p_input; };
InputManager *getIM() { return im; };
private:
InputManager *im;
intf_thread_t *p_intf;
input_thread_t *p_input;
static MainInputManager *instance;
MainInputManager( intf_thread_t *);
private slots:
void updateInput();
signals:
void inputChanged( input_thread_t *);
};
#endif
......@@ -23,38 +23,42 @@
#include "main_interface.hpp"
#include "input_manager.hpp"
#include "util/input_slider.hpp"
#include "util/qvlcframe.hpp">
#include "dialogs_provider.hpp"
#include <QCloseEvent>
#include <assert.h>
#include <QPushButton>
MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
MainInterface::MainInterface( intf_thread_t *_p_intf ) : QMainWindow(), p_intf( _p_intf )
{
/* Init UI */
/* All UI stuff */
QVLCFrame::fixStyle( this );
QWidget *main = new QWidget( this );
setCentralWidget( main );
setWindowTitle( _("VLC media player") );
ui.setupUi( this );
ui.setupUi( centralWidget() );
slider = new InputSlider( Qt::Horizontal, ui.sliderBox );
QVBoxLayout *box_layout = new QVBoxLayout();
box_layout->addWidget( slider );
ui.sliderBox->setLayout( box_layout );
resize( QSize( 450, 80 ) );
/* Init input manager */
p_input = NULL;
main_input_manager = new InputManager( this, p_intf );
MainInputManager::getInstance( p_intf );
/* Get timer updates */
connect( DialogsProvider::getInstance(NULL)->fixed_timer,
SIGNAL( timeout() ), this, SLOT(updateOnTimer() ) );
/* Tell input manager about the input changes */
connect( this, SIGNAL( inputChanged( input_thread_t * ) ),
main_input_manager, SLOT( setInput( input_thread_t * ) ) );
/* Connect the input manager to the GUI elements it manages */
connect( main_input_manager, SIGNAL(positionUpdated( float, int, int ) ),
connect( MainInputManager::getInstance( p_intf )->getIM(),
SIGNAL(positionUpdated( float, int, int ) ),
slider, SLOT( setPosition( float,int, int ) ) );
connect( slider, SIGNAL( sliderDragged( float ) ),
main_input_manager, SLOT( sliderUpdate( float ) ) );
connect( main_input_manager, SIGNAL( positionUpdated( float, int, int ) ),
MainInputManager::getInstance( p_intf )->getIM(),
SLOT( sliderUpdate( float ) ) );
connect( MainInputManager::getInstance( p_intf )->getIM(),
SIGNAL( positionUpdated( float, int, int ) ),
this, SLOT( setDisplay( float, int, int ) ) );
/* Actions */
......@@ -126,32 +130,6 @@ void MainInterface::updateOnTimer()
{
QApplication::quit();
}
vlc_mutex_lock( &p_intf->change_lock );
if( p_input && p_input->b_dead )
{
vlc_object_release( p_input );
p_input = NULL;
emit inputChanged( NULL );
}
if( !p_input )
{
playlist_t *p_playlist = (playlist_t *) vlc_object_find( p_intf,
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
assert( p_playlist );
PL_LOCK;
p_input = p_playlist->p_input;
if( p_input )
{
vlc_object_yield( p_input );
emit inputChanged( p_input );
}
PL_UNLOCK;
vlc_object_release( p_playlist );
}
vlc_mutex_unlock( &p_intf->change_lock );
}
void MainInterface::closeEvent( QCloseEvent *e )
......
......@@ -26,12 +26,13 @@
#include <vlc/intf.h>
#include "ui/main_interface.h"
#include "util/qvlcframe.hpp"
#include <QMainWindow>
class InputManager;
class QCloseEvent;
class InputSlider;
class MainInterface : public QVLCFrame
class MainInterface : public QMainWindow
{
Q_OBJECT;
public:
......@@ -44,6 +45,7 @@ private:
InputSlider *slider;
/// Main input associated to the playlist
input_thread_t *p_input;
intf_thread_t *p_intf;
Ui::MainInterfaceUI ui;
private slots:
......@@ -53,8 +55,6 @@ private slots:
void stop();
void prev();
void next();
signals:
void inputChanged( input_thread_t *);
};
#endif
......@@ -15,83 +15,6 @@
<property name="windowTitle" >
<string>Form</string>
</property>
<widget class="QGroupBox" name="groupBox" >
<property name="geometry" >
<rect>
<x>9</x>
<y>9</y>
<width>207</width>
<height>138</height>
</rect>
</property>
<property name="title" >
<string>Input</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="1" >
<widget class="QLabel" name="read_text" >
<property name="text" >
<string/>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QLabel" name="stream_bitrate_text" >
<property name="text" >
<string/>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLabel" name="input_bitrate_text" >
<property name="text" >
<string/>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>Input bitrate</string>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Read at media</string>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>Stream bitrate</string>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_7" >
<property name="text" >
<string>Demuxed</string>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QLabel" name="demuxed_text" >
<property name="text" >
<string/>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QGroupBox" name="groupBox_3" >
<property name="geometry" >
<rect>
......@@ -116,6 +39,9 @@
<property name="text" >
<string/>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1" >
......@@ -123,6 +49,9 @@
<property name="text" >
<string/>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1" >
......@@ -130,6 +59,9 @@
<property name="text" >
<string/>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="0" >
......@@ -179,6 +111,9 @@
<property name="text" >
<string/>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1" >
......@@ -186,6 +121,9 @@
<property name="text" >
<string/>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1" >
......@@ -193,6 +131,9 @@
<property name="text" >
<string/>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="0" >
......@@ -249,6 +190,9 @@
<property name="text" >
<string/>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="0" >
......@@ -270,6 +214,9 @@
<property name="text" >
<string/>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1" >
......@@ -277,6 +224,98 @@
<property name="text" >
<string/>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QGroupBox" name="groupBox" >
<property name="geometry" >
<rect>
<x>9</x>
<y>9</y>
<width>207</width>
<height>138</height>
</rect>
</property>
<property name="title" >
<string>Input</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="1" >
<widget class="QLabel" name="read_text" >
<property name="text" >
<string/>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QLabel" name="stream_bitrate_text" >
<property name="text" >
<string/>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLabel" name="input_bitrate_text" >
<property name="text" >
<string/>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>Input bitrate</string>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Read at media</string>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>Stream bitrate</string>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_7" >
<property name="text" >
<string>Demuxed</string>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QLabel" name="demuxed_text" >
<property name="text" >
<string/>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
......
......@@ -31,23 +31,28 @@
class QVLCFrame : public QWidget
{
public:
QVLCFrame( intf_thread_t *_p_intf ) : QWidget( NULL ), p_intf( _p_intf )
static void fixStyle( QWidget *w)
{
QStyle *style = qApp->style();
QStyle *style = qApp->style();
// Plastique is too dark.
/// theming ? getting KDE data ? ?
if( qobject_cast<QPlastiqueStyle *>(style) )
{
QPalette plt( palette() );
QPalette plt( w->palette() );
plt.setColor( QPalette::Active, QPalette::Highlight, Qt::gray );
QColor vlg = (Qt::lightGray);
vlg = vlg.toHsv();