]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/interface_widgets.hpp
Fixed preparsing/art fetching locking.
[vlc] / modules / gui / qt4 / components / interface_widgets.hpp
index 3516f2e2e6783c914bfc638634f112bd0b4ad87c..746b147950d82670e45905b756f31578c5dd1f27 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * interface_widgets.hpp : Custom widgets for the main interface
  ****************************************************************************
- * Copyright (C) 2006 the VideoLAN team
+ * Copyright (C) 2006-2008 the VideoLAN team
  * $Id$
  *
  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
 #ifndef _INTFWIDGETS_H_
 #define _INTFWIDGETS_H_
 
-#include <vlc/vlc.h>
-#include <vlc_interface.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "main_interface.hpp" /* Interface integration */
+#include "input_manager.hpp"  /* Speed control */
+
+#include "components/controller.hpp"
+#include "components/controller_widget.hpp"
 
-#include <vlc_aout.h>
-#include "qt4.hpp"
+//#include <vlc_aout.h> Visualizer
 
 #include <QWidget>
 #include <QFrame>
-#define VOLUME_MAX 200
+#include <QLabel>
+#include <QMouseEvent>
 
 class ResizeEvent;
 class QPalette;
 class QPixmap;
-class QLabel;
 class QHBoxLayout;
+class QMenu;
 
 /******************** Video Widget ****************/
 class VideoWidget : public QFrame
 {
     Q_OBJECT
+friend class MainInterface;
+
 public:
     VideoWidget( intf_thread_t * );
     virtual ~VideoWidget();
 
     void *request( vout_thread_t *, int *, int *,
                    unsigned int *, unsigned int * );
-    void release( void * );
-    int control( void *, int, va_list );
+    void  release( void );
+    int   control( void *, int, va_list );
 
-    int i_video_height, i_video_width;
-    vout_thread_t *p_vout;
+    virtual QSize sizeHint() const;
+
+protected:
+    virtual QPaintEngine *paintEngine() const
+    {
+        return NULL;
+    }
+
+    virtual void paintEvent(QPaintEvent *);
 
-    QSize widgetSize;
-    QSize sizeHint() const;
 private:
-    QWidget *frame;
     intf_thread_t *p_intf;
-    vlc_mutex_t lock;
+    vout_thread_t *p_vout;
+
+    QSize videoSize;
+
 signals:
-    void askResize();
-    void askVideoToShow();
-private slots:
-    void SetMinSize();
+    void askVideoWidgetToShow( unsigned int, unsigned int );
+
+public slots:
+    void SetSizing( unsigned int, unsigned int );
+
 };
 
 /******************** Background Widget ****************/
-class BackgroundWidget : public QFrame
+class BackgroundWidget : public QWidget
 {
     Q_OBJECT
 public:
     BackgroundWidget( intf_thread_t * );
     virtual ~BackgroundWidget();
-    QSize widgetSize;
-    QSize sizeHint() const;
-    bool b_need_update;
+
 private:
     QPalette plt;
     QLabel *label;
-    virtual void resizeEvent( QResizeEvent *e );
     virtual void contextMenuEvent( QContextMenuEvent *event );
     intf_thread_t *p_intf;
-    int i_runs;
+    virtual void resizeEvent( QResizeEvent * event );
+
 public slots:
     void toggle(){ TOGGLEV( this ); }
-    void update( input_thread_t * );
+    void updateArt( input_item_t* );
 };
 
+#if 0
 class VisualSelector : public QFrame
 {
     Q_OBJECT
@@ -106,146 +122,104 @@ private slots:
     void prev();
     void next();
 };
+#endif
 
-/* Advanced Button Bar */
-class QPushButton;
-class AdvControlsWidget : public QFrame
+class TimeLabel : public QLabel
 {
     Q_OBJECT
 public:
-    AdvControlsWidget( intf_thread_t *);
-    virtual ~AdvControlsWidget();
-
-    void enableInput( bool );
-    void enableVideo( bool );
-
+    TimeLabel( intf_thread_t *_p_intf );
+protected:
+    virtual void mousePressEvent( QMouseEvent *event )
+    {
+        toggleTimeDisplay();
+    }
+    virtual void mouseDoubleClickEvent( QMouseEvent *event )
+    {
+        toggleTimeDisplay();
+        emit timeLabelDoubleClicked();
+    }
 private:
     intf_thread_t *p_intf;
-    QPushButton *recordButton, *ABButton;
-    QPushButton *snapshotButton, *frameButton;
-
-    mtime_t timeA, timeB;
-
+    bool b_remainingTime;
+    void toggleTimeDisplay();
+signals:
+    void timeLabelDoubleClicked();
 private slots:
-    void snapshot();
-    void frame();
-    void fromAtoB();
-    void record();
-    void AtoBLoop( float, int, int );
+    void setDisplayPosition( float pos, int time, int length );
+    void setCaching( float );
 };
 
-/* Button Bar */
-class InputSlider;
-class QSlider;
-class QGridLayout;
-class VolumeClickHandler;
-class SoundSlider;
-class QAbstractSlider;
-
-class ControlsWidget : public QFrame
+class SpeedLabel : public QLabel
 {
     Q_OBJECT
 public:
-    /* p_intf, advanced control visible or not, blingbling or not */
-    ControlsWidget( intf_thread_t *, MainInterface*, bool, bool );
-//    QSize sizeHint() const;
-    virtual ~ControlsWidget();
-
-    QPushButton *playlistButton;
-    void setStatus( int );
-    void enableInput( bool );
-    void enableVideo( bool );
-public slots:
-    void setNavigation( int );
-    void updateOnTimer();
-protected:
-    friend class MainInterface;
-    friend class VolumeClickHandler;
-private:
-    intf_thread_t       *p_intf;
-    QFrame              *discFrame;
-    QGridLayout         *controlLayout;
-    InputSlider         *slider;
-    QPushButton         *prevSectionButton, *nextSectionButton, *menuButton;
-    QPushButton         *playButton, *fullscreenButton;
-    QPushButton         *slowerButton, *fasterButton;
-    AdvControlsWidget   *advControls;
-    QLabel              *volMuteLabel;
-    QAbstractSlider     *volumeSlider;
-
-    bool                 b_advancedVisible;
-private slots:
-    void play();
-    void stop();
-    void prev();
-    void next();
-    void updateVolume( int );
-    void fullscreen();
-    void extSettings();
-    void faster();
-    void slower();
-    void toggleAdvanced();
-signals:
-    void advancedControlsToggled( bool );
-};
+    SpeedLabel( intf_thread_t *, const QString );
 
-class VolumeClickHandler : public QObject
-{
-public:
-    VolumeClickHandler( intf_thread_t *_p_intf, ControlsWidget *_m ) :QObject(_m)
-    {m = _m; p_intf = _p_intf; }
-    virtual ~VolumeClickHandler() {};
-    bool eventFilter( QObject *obj, QEvent *e )
+protected:
+    virtual void mouseDoubleClickEvent ( QMouseEvent * event )
     {
-        if (e->type() == QEvent::MouseButtonPress  )
-        {
-            aout_VolumeMute( p_intf, NULL );
-            audio_volume_t i_volume;
-            aout_VolumeGet( p_intf, &i_volume );
-            m->updateVolume( i_volume *  VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
-            return true;
-        }
-        return false;
+        THEMIM->getIM()->setRate( INPUT_RATE_DEFAULT );
     }
+private slots:
+    void showSpeedMenu( QPoint );
+    void setRate( int );
 private:
-    ControlsWidget *m;
     intf_thread_t *p_intf;
+    QMenu *speedControlMenu;
+    SpeedControlWidget *speedControl;
 };
 
-#include <QLabel>
-#include <QMouseEvent>
-class TimeLabel : public QLabel
-{
-    Q_OBJECT
-    void mousePressEvent( QMouseEvent *event )
-    {
-        emit timeLabelClicked();
-    }
-    void mouseDoubleClickEvent( QMouseEvent *event )
-    {
-        emit timeLabelDoubleClicked();
-    }
-signals:
-    void timeLabelClicked();
-    void timeLabelDoubleClicked();
-};
-
-
 /******************** Speed Control Widgets ****************/
 class SpeedControlWidget : public QFrame
 {
     Q_OBJECT
 public:
-    SpeedControlWidget( intf_thread_t *);
-    virtual ~SpeedControlWidget();
+    SpeedControlWidget( intf_thread_t *, QWidget * );
     void updateControls( int );
 private:
     intf_thread_t *p_intf;
     QSlider *speedSlider;
-    QPushButton *normalSpeedButton;
+
+public slots:
+    void activateOnState();
+
 private slots:
     void updateRate( int );
     void resetRate();
 };
 
+class CoverArtLabel : public QLabel
+{
+    Q_OBJECT
+public:
+    CoverArtLabel( QWidget *parent,
+                   vlc_object_t *p_this,
+                   input_item_t *p_input = NULL );
+    virtual ~CoverArtLabel();
+
+private:
+    input_item_t *p_input;
+    vlc_object_t *p_this;
+
+    QString prevArt;
+
+public slots:
+    void requestUpdate() { emit updateRequested(); };
+    void update( input_item_t* p_item )
+    {
+        if( p_input ) vlc_gc_decref( p_input );
+        if( ( p_input = p_item ) )
+            vlc_gc_incref( p_input );
+        requestUpdate();
+    }
+
+private slots:
+    void doUpdate();
+    void downloadCover();
+
+signals:
+    void updateRequested();
+};
+
 #endif