]> git.sesse.net Git - vlc/commitdiff
* Split apart gui and input management
authorClément Stenac <zorglub@videolan.org>
Fri, 9 Jun 2006 19:17:49 +0000 (19:17 +0000)
committerClément Stenac <zorglub@videolan.org>
Fri, 9 Jun 2006 19:17:49 +0000 (19:17 +0000)
* Functional stats panel

12 files changed:
modules/gui/qt4/components/infopanels.cpp
modules/gui/qt4/components/preferences.cpp
modules/gui/qt4/dialogs/prefs_dialog.hpp
modules/gui/qt4/dialogs/streaminfo.cpp
modules/gui/qt4/dialogs/streaminfo.hpp
modules/gui/qt4/dialogs_provider.cpp
modules/gui/qt4/input_manager.cpp
modules/gui/qt4/input_manager.hpp
modules/gui/qt4/main_interface.cpp
modules/gui/qt4/main_interface.hpp
modules/gui/qt4/ui/input_stats.ui
modules/gui/qt4/util/qvlcframe.hpp

index 2529ff19c166544d84bdd2d5779bfffa4041a324..bbb2a9511079fb2f5fb263e5e352bf6748de61ae 100644 (file)
@@ -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 );
 }
index 6dce6de05d371938158fbc65aac7fccd37fe83b3..704ebe8b5f0c7ca665aeef1cd707b97079797e1b 100644 (file)
@@ -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 );
         }
index 22f5429d24d85da6b1ff0b4409ccb66b5dd1221e..ec18f8846dfbc0b7570ecfc6680b11ac4e3b01b7 100644 (file)
@@ -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 );
index 3146b5a5b1888bf43601bb7f0ffd888ab1bc02aa..f84ee9caffb9c9cb2f10d5c548c1349b7f8ef1c3 100644 (file)
@@ -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"
 
 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()
index 3073798a67d295b70743e01c63075631786b21dd..a7c99f5602a04b8fa479d0e4afea54094e8478ed 100644 (file)
 
 #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();
index cb6380225239f053d8652d16a600311334d47236..f59c0d18f78a6d4a373dab362f5639bdb1e53cab 100644 (file)
@@ -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()
index 3ccff8744d5bdad0a4a632ced5455dc5ba1359a5..ca884667c70c62929323098fbaaef711c9b8d1a0 100644 (file)
 #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 );
+}
index a1307b7b847f5fcd0e5e98bd1597929cf3503004..dd14ffa820ee44d90b32fd815e590909d510e01b 100644 (file)
@@ -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
index 5f8c7a83496c1ad8761c3d2411efbd7161b8f617..ded9e4bad8125ff159cca245a2c0c2142cca82bd 100644 (file)
 #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 )
index db095eb735b4811bb0875e66906c2a841ff4be35..44e4fbc7e5de9c9017e2aa900eae4f16fcc62981 100644 (file)
 #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
index 6701f2df36f7c84774d33c5720933025f98a4e00..28488c916dd1fa5cd457d339ee3ea5f926adc4dc 100644 (file)
   <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>
       <property name="text" >
        <string/>
       </property>
+      <property name="alignment" >
+       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+      </property>
      </widget>
     </item>
     <item row="2" column="1" >
       <property name="text" >
        <string/>
       </property>
+      <property name="alignment" >
+       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+      </property>
      </widget>
     </item>
     <item row="1" column="1" >
       <property name="text" >
        <string/>
       </property>
+      <property name="alignment" >
+       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+      </property>
      </widget>
     </item>
     <item row="2" column="0" >
       <property name="text" >
        <string/>
       </property>
+      <property name="alignment" >
+       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+      </property>
      </widget>
     </item>
     <item row="1" column="1" >
       <property name="text" >
        <string/>
       </property>
+      <property name="alignment" >
+       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+      </property>
      </widget>
     </item>
     <item row="0" column="1" >
       <property name="text" >
        <string/>
       </property>
+      <property name="alignment" >
+       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+      </property>
      </widget>
     </item>
     <item row="2" column="0" >
       <property name="text" >
        <string/>
       </property>
+      <property name="alignment" >
+       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+      </property>
      </widget>
     </item>
     <item row="1" column="0" >
       <property name="text" >
        <string/>
       </property>
+      <property name="alignment" >
+       <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+      </property>
      </widget>
     </item>
     <item row="1" column="1" >
       <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>
index 9db2ec5040c763849623d07cd970d41ee05b195a..83b40c5400d181b32add067176b5c4a770a6e02c 100644 (file)
 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();
             vlg.setHsv( vlg.hue(), vlg.saturation(), 235  );
             plt.setColor( QPalette::Active, QPalette::Window, vlg );
             plt.setColor( QPalette::Inactive, QPalette::Window, vlg );
-            setPalette( plt );
+            w->setPalette( plt );
         }
-    };
+    }
+
+    QVLCFrame( intf_thread_t *_p_intf ) : QWidget( NULL ), p_intf( _p_intf )
+    {
+        fixStyle( this );
+   };
     virtual ~QVLCFrame()   {};
 
     void toggleVisible()